AVAudioSessionCategoryPlayAndRecord 未检测到静音开关
我正在使用 AVAudioSessionCategoryPlayAndRecord 来检测向麦克风吹气的用户,因为我希望其他声音继续播放。但是,如果静音开关打开,我不想播放任何音频,但我仍然想录音。
显然,如果静音开关打开,我可以使用一些 IF-THEN 逻辑并将其更改为 AVAudioSessionCategoryRecord,但我无法检测到这一点(从另一个用户的外观来看,之前的解决方案似乎不起作用在 iOS5 上工作)。
所以我的问题有两个部分:
有人知道如何检测 iOS 5 上的静音开关吗?
如果没有,有没有办法操作 AVAudioSessionCategoryPlayAndRecord 来检测静音开关(根据 Apple 、AVAudioSessionCategoryPlayAndRecord不受静音开关影响)
I'm using AVAudioSessionCategoryPlayAndRecord to detect the user blowing into the mic since I want other sounds to keep playing. However, if the mute switch is on, I don't want any audio to play but I still want to record.
Obviously I could just use some IF-THEN logic and change it to AVAudioSessionCategoryRecord if the mute switch is on, but I'm having trouble detecting that (from the looks of another user, the solution that worked before doesn't seem to work on iOS5).
So my question has two parts:
Has anyone figured out how to detect the mute switch on iOS 5?
If not, is there a way to manipulate AVAudioSessionCategoryPlayAndRecord to detect the mute switch (According to Apple, AVAudioSessionCategoryPlayAndRecord is not affected by the mute switch)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自 iOS 5 以来,我们将无法再检测静音开关状态...
Apple 的答案位于已接受的答案中:使用 AVAudioPlayer 检测 iPhone 的响铃/静音/静音开关不起作用?
We won't be able to detect the silent switch state anymore since iOS 5...
The answer from Apple is there on the accepted answer : Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?