In an app I have a player object that has an AVQueuePlayer property to play audio files. In my player object I have all the code necessary to handle AVAudioSessionInterruptionNotification as below:
- (void)p_audioSessionInterruption:(NSNotification *)notification
{
NSUInteger interruptionType = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
if (interruptionType == AVAudioSessionInterruptionTypeBegan) {
if (self.isPlaying) {
self.interruptedWhilePlaying = YES;
[self p_pauseAfterInterruption];
}
return;
}
if (interruptionType == AVAudioSessionInterruptionTypeEnded) {
if (self.interruptedWhilePlaying) {
self.interruptedWhilePlaying = NO;
[self p_playAfterInterruption];
}
return;
}
}
The self.isPlaying is a read-only property that is:
- (BOOL)isPlaying
{
return self.queueplayer.rate != 0;
}
In iOS 8 this all seems to be working just fine. In iOS 9, though, it seems "something" get called prior to handling the notification and alters the AVQueuePlayer rate property to 0. So when checking if playing in the AVAudioSessionInterruptionTypeBegan case the player does not gets paused after interruption and when interruption ends the interruptedWhilePlaying property is NO so does not gets resumed.
I have added KVO observation to rate property of AVQueuePlayer trying to find out what changes the rate but could not find anything enlightening. I provide the observeValueForKeyPath stacktrace in the screenshot.
Any help would be much appreciated. Thank you in advance.