简体   繁体   English

iOS AVAudioRecorder记录而不会停止背景音频

[英]iOS AVAudioRecorder record without stopping background audio

I need to allow my app to record audio without stopping background music player. 我需要允许我的应用在不停止背景音乐播放器的情况下录制音频。

I'm using AVAudioRecorder. 我正在使用AVAudioRecorder。

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];

However, anytime [audioplayer record] is called, the background music will stop playing. 但是,无论何时调用[audioplayer record],背景音乐都会停止播放。

What can I do so that background music doesn't stop playing? 我该怎么做才能使背景音乐不停止播放?

Thanks. 谢谢。

You need to add the MixWithOthers Category Option as well: 您还需要添加MixWithOthers类别选项:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
                                 withOptions:AVAudioSessionCategoryOptionMixWithOthers
                                       error:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM