Get AVAudioSessionRouteChangeNotification when app enter background

28 views Asked by At

A camera app needs to continue playing background music while recording. The app uses the following code to set the audio session category:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord mode:AVAudioSessionModeVideoRecording options:AVAudioSessionCategoryOptionMixWithOthers error:nil];

Upon entering the background and opening another camera app, the app receives the AVAudioSessionRouteChangeNotification, the route changing reason is AVAudioSessionRouteChangeReasonCategoryChange, and then AVAudioSession.sharedInstance.currentRoute's input becomes nil.It appears to be some form of system resource contention where the microphone resource is being occupied by another active app.

What settings did I set incorrectly, or when and how should I restore certain AVAudioSession settings?

0

There are 0 answers