iphone audio streaming
i'm developing an application which uses audio streaming. For streaming audio from internet i'm using the AudioStreamer class. The audio streamer has four state isPlaying, isPaused ,isWaiting, and isIdle . My problem is that when the audio streamer is in the state "isWaiting" and at that time if i get a phone call Audio queue fails givi开发者_开发知识库ng the error "Audio queue start failed." Any has solution for this? help....
An interruption - such as receiving a call - will deactivate the Audio Session. It's up to you to, in your interruption handler, re-activate the Audio Session by calling AudioSessionSetActive(true).
Look here for details of the interruption handler.
Having said that, I'll assume that you're using mattgallagher's library. The thing to do is put a breakpoint in AudioStreamer.m on line 949 (the line after "err = AudioQueueStart(audioQueue, NULL);" in -[AudioStreamer pause].
If err == kAudioSessionNotActiveError then my theory's right, and you need to call restart the audio session. Perhaps something like this (but I've only only ever glanced through this code so perhaps there's a better way of solving the problem):
else if (state == AS_PAUSED)
{
err = AudioQueueStart(audioQueue, NULL);
if (err) {
err = AudioSessionSetActive(true);
if (err) {
[self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
return;
} else {
err = AudioQueueStart(audioQueue, NULL);
if (err) {
[self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
return;
}
}
}
}
精彩评论