AVAudioSessionCategoryPlayAndRecord 未检测到静音开关

发布于 2024-12-14 06:21:34 字数 698 浏览 4 评论 0原文

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

显然,如果静音开关打开,我可以使用一些 IF-THEN 逻辑并将其更改为 AVAudioSessionCategoryRecord,但我无法检测到这一点(从另一个用户的外观来看,之前的解决方案似乎不起作用在 iOS5 上工作)。

所以我的问题有两个部分:

  1. 有人知道如何检测 iOS 5 上的静音开关吗?

  2. 如果没有,有没有办法操作 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:

  1. Has anyone figured out how to detect the mute switch on iOS 5?

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

粉红×色少女 2024-12-21 06:21:34

自 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文