I am developing a project that has both streaming audio and playing sound from a file. I use AudioStreamer for streaming audio and I use avaudioplayer to play from a file. Both streaming and playback work fine until the application is interrupted by a phone call or SMS. But when call / sms arrives after rejecting the call, when I try to restart the streaming, I get the error "Audio Queue Error". This only happens when I used avaudioplayer at least once and after that I used streaming. When an obeject avaudioplayer is not created, in this case there is no problem resuming streaming after rejecting the call. I guess something is wrong with the audio course.
Help is much appreciated.
Update:
The code I'm using is below
void interruptionListenerCallback (void *inUserData, UInt32 interruptionState) { // This callback, being outside the implementation block, needs a reference //to the AudioPlayer object AudioStreamer *player = (AudioStreamer *)[streamerArray objectAtIndex:0]; if (interruptionState == kAudioSessionBeginInterruption) { NSLog(@"kAudioSessionBeginInterruption 1"); [player pause]; interruptedOnPlayback = YES; } else if (interruptionState == kAudioSessionEndInterruption) { NSLog(@"kAudioSessionEndInterruption 2"); AudioSessionSetActive( true ); [player start]; interruptedOnPlayback = NO; } }
as you can see that I am using AudioSessionSetActive (true), it works fine until the avaudioplayer object is created. The problem only occurs when I use the streamer after creating the Avaudioplayer object, and if the application is interrupted by a phone call
or sms, I get an error. Audio Queue Queue Error ?!
iphone
mobapps99
source share