简体   繁体   中英

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.

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

However, anytime [audioplayer record] is called, the background music will stop playing.

What can I do so that background music doesn't stop playing?

Thanks.

You need to add the MixWithOthers Category Option as well:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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