Re: AudioSessionSetActive(true) at end of audio interruption fails when called from background app
Re: AudioSessionSetActive(true) at end of audio interruption fails when called from background app
- Subject: Re: AudioSessionSetActive(true) at end of audio interruption fails when called from background app
- From: Rinoy Pazhekattu <email@hidden>
- Date: Mon, 29 Apr 2013 14:25:02 -0400
Yes, my app can restart if it is in the background and a phone call or other interruption happens, but since it only does playback, the category I'm using is AVAudioSessionCategoryPlayback. This is the code I use to restart the audio session when an interruption ends and it seems to work fine:
NSError * interruptionError;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:YES error:&interruptionError];
You should check the audio category when the interruption ends, when I check I get AVAudioSessionCategoryPlayback so it makes sense that my app can restart while yours can't if it does recording. Alternatively, you could try setting the audio category to AVAudioSessionCategoryPlayAndRecord but I wouldn't recommend this since the interruption handling method probably defaults the category to AVAudioSessionCategoryPlayback when the interruption ends and Apple may not want it to be changed to a category that records.
Rinoy