Enable ring/silent switch with AVAudioSessionCategoryPlayAndRecord

感情迁移 提交于 2020-01-07 04:55:12

问题


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.


回答1:


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.

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.

If you have access to the WWDC developer videos, I'd suggest watching "WWDC 2010 session 412 Audio Development for iPhone OS part 1".



来源:https://stackoverflow.com/questions/15881207/enable-ring-silent-switch-with-avaudiosessioncategoryplayandrecord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!