I am trying to solve the AVAudioSession problem since many hours ago and did not get success!
I found many guys who talked about problems with endInterruption, but none of them talked about this error:
Unable to reactivate the audio session after the interruption ended: Error Domain=NSOSStatusErrorDomain Code=560161140 "The operation couldn't be completed. (OSStatus error 560161140.)"
I tried converting this code to ASCII to check the results of the audio code, but nothing is related to this number.
My code to start the session:
- (void) setupAudioSession { mySession = [AVAudioSession sharedInstance]; [mySession setDelegate: self]; NSError *audioSessionError = nil; [mySession setCategory: AVAudioSessionCategoryPlayback error: &audioSessionError]; if (audioSessionError != nil) { NSLog (@"Error setting audio session category: %@", [audioSessionError description]); return; }
}
And the code of the endInterruption method:
- (void) endInterruptionWithFlags: (NSUInteger) flags { if (flags & AVAudioSessionInterruptionFlags_ShouldResume) { NSError *endInterruptionError = nil; [[AVAudioSession sharedInstance] setActive: YES error: &endInterruptionError]; if (endInterruptionError != nil) { NSLog (@"Unable to reactivate the audio session after the interruption ended: %@", [endInterruptionError description]); return; } else { NSLog (@"Audio session reactivated after interruption."); if (interruptedWhilePlaying) { self.interruptedWhilePlaying = NO;
}
Most of this code was extracted from the Apple Mixer host example. And it is strange that the sample works great!
Can you find out what is wrong?
Thanks.
source share