I\'m developing a project which has both audio streaming and playing audio from file. For audio streaming i\'m using AudioStreamer and for playing from file i\'m using avaud
You need to make the audio session active yourself after the interruption.
I don't know AVAudioPlayer, but if you were using the audio queue services directly, you could have something like this as your interruption handler:
void interruptionListener(void * inClientData, UInt32 inInterruptionState) {
if (inInterruptionState == kAudioSessionEndInterruption) {
OSStatus rc = AudioSessionSetActive(true);
if (rc) {
NSLog(@"AudioSessionSetActive(true) returned %d", rc);
}
}
}
and pass that into your AudioSessionInitialize() call.
You can restart the session lazily, too:
-(void)startPlaying {
OSStatus rc = AudioQueueStart(queue, NULL);
if (rc) {
NSLog(@"startPlaying AudioQueueStart returned %d.", rc);
if (rc == kAudioSessionNotActiveError) {
rc = AudioSessionSetActive(true);
if (rc) {
NSLog(@"startPlaying - AudioSessionSetActive(true) returned %.d", rc);
} else {
NSLog(@"startPlaying - restarted Audio Session");
}
}
}
}
I had the same problem, in more detail the error message was "hwiu" (hardware in use) or 1752656245. But I was using the MPMoviePlayerController
before starting the audioStreamer.
I only had to stop the MPMoviePlayerController
([moviePlayer stop]) before releasing it in the moviePlayBackDidFinish
method.
the stop should release some hardware componants.
I hope it helps