AVPlayer 在 iOS 中阻止 Voip 或 webrtc

AVPlayer blocks Voip or webrtc in iOS

在P2P视频通话中,我使用AVPlayer播放mp3url,mp3播放了,但是远程和本地音频的声音都没有了。 所以我需要断开耳机并重新连接。

我该怎么办?我什至使用

NSError *error;

AVAudioSession *session = [AVAudioSession sharedInstance];

[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];

[session setMode:AVAudioSessionModeVoiceChat error:&error];

[session setActive:YES error:&error];

但还是没有运气。我应该使用什么解决方法?

Try creating new object of AVAudioSession, don't use sharedInstance of AVAudioSession and then check.