当我想使用AVAudioSessionCategoryPlayAndRecord同时播放和录制音频时,如何使物理振铃/静音开关再次工作?我只是在任何地方都找不到答案.
How do I make physical ring/silent switch work again when I want to play and record audio at the same time using AVAudioSessionCategoryPlayAndRecord? I just cannot find an answer to that anywhere.
推荐答案AVAudioSessionCategoryPlayAndRecord专为以音频为中心的应用程序而设计,该应用程序的目的是播放音乐.设置此类别后,静音开关或屏幕锁定将不会使音频静音. VOIP应用程序和音乐应用程序都希望这种行为.
AVAudioSessionCategoryPlayAndRecord is designed for audio-centric apps, where the purpose of the app is to play music. When this category is set, audio will not be silenced by the mute switch or the screen lock. VOIP apps and music apps desire this behavior.
如果您想通过静音开关使音频静音,则在不录制时需要将类别切换为AVAudioSessionCategoryAmbient或AVAudioSessionCategorySoloAmbient.
If you want audio to be silenced by the mute switch, you'll need to switch the category to AVAudioSessionCategoryAmbient or AVAudioSessionCategorySoloAmbient when not recording.
如果您有权访问WWDC开发人员视频,建议您观看"WWDC 2010会话412 iPhone OS的音频开发第1部分".
If you have access to the WWDC developer videos, I'd suggest watching "WWDC 2010 session 412 Audio Development for iPhone OS part 1".
更多推荐
使用AVAudioSessionCategoryPlayAndRecord启用铃声/静音开关
发布评论