我正在开发一个VoIP应用程序,该应用程序使用MPVolumeView来允许用户调整系统音量。在iOS 9.1发布之前,这一切都很好,很棒。然后,我发现如果我将AVAudioSession
模式设置为AVAudioSessionModeVoiceChat
,MPVolumeView
滑块就会崩溃。(即滑块不再调整系统音量。)如果我将模式改为AvAudioSessionModeDefault
,MPVolumeView
就会像预期的那样工作,但麦克风会记录来自iPad扬声器的音频。(换句话说,语音处理被关闭了--我需要VoIP调用。)在iOS 9.1之前,我可以将AudioSession模式设置为AVAudioSessionModeDefault
,然后在AudioComponentDescription中将componentSubType设置为kAudioUnitSubType_VoiceProcessingIO
,一切正常。不幸的是,情况似乎已不再如此。有没有人知道如何保持语音处理,并让MPVolumeView工作岗位iOS 9.1?
下面是我设置AVAudioSession的代码:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
// Make sure the session on this thread matches.
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth error:nil];
// Here is the main connundrum: I want to set AVAudioSessionModeDefault so that the MPVolumeView will work,
// but when I do that the mic picks up the audio from the speaker and plays it back creating an unwanted feeback loop.
// If I set the mode to AVAudioSessionModeVoiceChat the voice processing (primarily the AEC) fixes the feeback loop,
// but then the MPVolumeView no longers works. (It no longer adjusts the system volume.
//Question: How can I have BOTH the voice processing AND the MPVolumeView adjust the system volume?
if(!appDelegate.viewController.voiceChatMode)
[audioSession setMode:AVAudioSessionModeDefault error:nil];
else
[audioSession setMode:AVAudioSessionModeVoiceChat error:nil];
[audioSession setPreferredIOBufferDuration:0.005 error:nil];
[audioSession setActive:YES error:nil];
发布于 2016-01-06 23:26:19
在与苹果的技术支持部门交谈后,他们直截了当地回答:
根据核心音频工程,与MPVolumeView不再调整系统的音量问题是一个已知的问题(r. 17292753),目前登录在我们的错误数据库。
恐怕我不知道怎么解决这个问题。否则,关于VoIP支持,建议聊天应用程序没有音量滑块,而是依靠手机的音量按钮。
所以你就有了。希望他们很快就能修好。
https://stackoverflow.com/questions/34346209
复制相似问题