使用AVAudioSessionCategoryPlayAndRecord启用铃声/静音开关 [英] Enable ring/silent switch with AVAudioSessionCategoryPlayAndRecord

查看:144
本文介绍了使用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启用铃声/静音开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆