Mute and UnMute in Objective-C on iOS

笑着哭i 提交于 2019-12-12 04:43:16

问题


Hi guys ive been trying to find a way to mute and unmute (that is play audio) via Objective-C in-code, regardless of whether the app is in mute mode or not (physical mute toggled)

I see Instagram does that, where you can press the mute icon even if your phone is mute, and it will play video audio.


回答1:


You want to look at audio session categories

With this code you can play audio when the Ring/Silent switch to silent.

NSError *setCategoryError = nil;
BOOL success = [[AVAudioSession sharedInstance]
            setCategory: AVAudioSessionCategoryPlayback
                  error: &setCategoryError];

if (!success) { /* handle the error in setCategoryError */ }


来源:https://stackoverflow.com/questions/25944330/mute-and-unmute-in-objective-c-on-ios

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