本文介绍了在iOS上的Objective-C中静音和取消静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我一直在尝试找到一种通过Objective-C编码进行静音和取消静音(即播放音频)的方法,而不管该应用程序是否处于静音模式(切换了物理静音)
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)
我看到Instagram做到了,即使您的手机处于静音状态,您也可以在其中按下静音图标,它将播放视频音频.
I see Instagram does that, where you can press the mute icon even if your phone is mute, and it will play video audio.
推荐答案
您要查看音频会话类别
使用此代码,您可以在铃声/静音"切换为静音时播放音频.
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 */ }
这篇关于在iOS上的Objective-C中静音和取消静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!