Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

录制音频上传到服务器,然后在ios中插放没有声音 #2

Open
lovederh opened this issue May 21, 2019 · 1 comment
Open

Comments

@lovederh
Copy link

HI, 我在使用此插件远程调用服务端的音频文件播放时遇到问题,同样的在android上是可以正常播放的。请问如何处理
image
调试发现走的是红框内的代码,感觉好像没有初始化呢
image

@lovederh
Copy link
Author

对NatAudio.m文件第红框内做了如下修改,我的项目目前可以了

if ([self.path isEqualToString:path]) {
            if (self.avplayer.rate == 0) {
                self.songItem = [[AVPlayerItem alloc]initWithURL:url];
                self.avplayer = [[AVPlayer alloc]initWithPlayerItem:self.songItem];
                [self.avplayer addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
                [self.avplayer play];
                callback(nil,nil);
            }else{
                [self.avplayer pause];
                self.avplayer.rate = 0.0;
                [self.avplayer removeObserver:self forKeyPath:@"status"];
                self.songItem = [[AVPlayerItem alloc]initWithURL:url];
                [self.avplayer replaceCurrentItemWithPlayerItem: self.songItem];
                [self.avplayer addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
                callback(nil,nil);
            }
            return;
        } 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant