使用AVAudioSessionCategoryPlayAndRecord启用铃声/静音开关

编程入门 行业动态 更新时间:2024-10-24 16:21:20
本文介绍了使用AVAudioSessionCategoryPlayAndRecord启用铃声/静音开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我想使用AVAudioSessionCategoryPlayAndRecord同时播放和录制音频时,如何使物理振铃/静音开关再次工作?我只是在任何地方都找不到答案.

How do I make physical ring/silent switch work again when I want to play and record audio at the same time using AVAudioSessionCategoryPlayAndRecord? I just cannot find an answer to that anywhere.

推荐答案

AVAudioSessionCategoryPlayAndRecord专为以音频为中心的应用程序而设计,该应用程序的目的是播放音乐.设置此类别后,静音开关或屏幕锁定将不会使音频静音. VOIP应用程序和音乐应用程序都希望这种行为.

AVAudioSessionCategoryPlayAndRecord is designed for audio-centric apps, where the purpose of the app is to play music. When this category is set, audio will not be silenced by the mute switch or the screen lock. VOIP apps and music apps desire this behavior.

如果您想通过静音开关使音频静音,则在不录制时需要将类别切换为AVAudioSessionCategoryAmbient或AVAudioSessionCategorySoloAmbient.

If you want audio to be silenced by the mute switch, you'll need to switch the category to AVAudioSessionCategoryAmbient or AVAudioSessionCategorySoloAmbient when not recording.

如果您有权访问WWDC开发人员视频,建议您观看"WWDC 2010会话412 iPhone OS的音频开发第1部分".

If you have access to the WWDC developer videos, I'd suggest watching "WWDC 2010 session 412 Audio Development for iPhone OS part 1".

更多推荐

使用AVAudioSessionCategoryPlayAndRecord启用铃声/静音开关

本文发布于:2023-11-27 10:12:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637650.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静音   铃声   AVAudioSessionCategoryPlayAndRecord

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!