AVAudioSessionCategoryPlayAndRecord不检测静音开关

时间:2011-11-06 21:08:55

标签: iphone switch-statement avaudiosession mute

我正在使用AVAudioSessionCategoryPlayAndRecord来检测用户吹入麦克风,因为我希望其他声音继续播放。但是,如果静音开关打开,我不想播放任何音频,但我仍想录音。

显然,我可以使用一些IF-THEN逻辑并将其更改为AVAudioSessionCategoryRecord,如果静音开关打开,但我无法检测到(from the looks of another user,之前工作的解决方案似乎没有在iOS5上工作。

所以我的问题有两部分:

  1. 有没有人想出如何检测iOS 5上的静音开关?

  2. 如果没有,有没有办法操纵AVAudioSessionCategoryPlayAndRecord来检测静音开关(According to Apple,AVAudioSessionCategoryPlayAndRecord不受静音开关的影响)

1 个答案:

答案 0 :(得分:3)

自iOS 5以来,我们将无法再检测静音开关状态......

Apple的回答是接受的答案:Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?