diff --git a/ios/ReactNativeAudioStreaming.m b/ios/ReactNativeAudioStreaming.m index 0f30e11..acc8f4f 100644 --- a/ios/ReactNativeAudioStreaming.m +++ b/ios/ReactNativeAudioStreaming.m @@ -45,7 +45,7 @@ - (void)dealloc #pragma mark - Pubic API RCT_EXPORT_METHOD(play:(NSString *) streamUrl options:(NSDictionary *)options) { - + if(![self activate]) return; @try { @@ -237,6 +237,16 @@ - (void)unregisterAudioInterruptionNotifications object:nil]; } +- (void) manageInterruption: (Boolean) isStop { + if(isStop) { + if (self.audioPlayer) { + [self.audioPlayer pause]; + } + } else { + [self.audioPlayer play]; + } +} + - (void)onAudioInterruption:(NSNotification *)notification { // Get the AVAudioSessionInterruptionTypeKey enum @@ -247,12 +257,12 @@ - (void)onAudioInterruption:(NSNotification *)notification { { case AVAudioSessionInterruptionTypeBegan: NSLog(@"Audio Session Interruption case started."); - [self stop]; + [self manageInterruption:true]; break; case AVAudioSessionInterruptionTypeEnded: NSLog(@"Audio Session Interruption case ended."); - [self play:self.lastUrlString options:self.lastOptions]; + [self manageInterruption:false]; break; default: