diff --git a/ios/ReactNativeAudioStreaming.h b/ios/ReactNativeAudioStreaming.h index b03c55f..60807fc 100644 --- a/ios/ReactNativeAudioStreaming.h +++ b/ios/ReactNativeAudioStreaming.h @@ -8,6 +8,7 @@ @property (nonatomic, strong) STKAudioPlayer *audioPlayer; @property (nonatomic, readwrite) BOOL isPlayingWithOthers; +@property (nonatomic, readwrite) NSString *lastUrlString; @property (nonatomic, retain) NSString *currentSong; - (void)play; diff --git a/ios/ReactNativeAudioStreaming.m b/ios/ReactNativeAudioStreaming.m index ba87731..6ee60dc 100644 --- a/ios/ReactNativeAudioStreaming.m +++ b/ios/ReactNativeAudioStreaming.m @@ -28,6 +28,7 @@ - (ReactNativeAudioStreaming *)init [self registerAudioInterruptionNotifications]; [self registerRemoteControlEvents]; [self setNowPlayingInfo:true]; + self.lastUrlString = @""; [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(tick:) userInfo:nil repeats:YES]; @@ -70,12 +71,13 @@ - (void)dealloc if (!self.audioPlayer) { return; } - if (self.audioPlayer.state == STKAudioPlayerStatePaused) { + if (self.audioPlayer.state == STKAudioPlayerStatePaused && [self.lastUrlString isEqualToString:streamUrl]) { [self.audioPlayer resume]; } else { [self.audioPlayer play:streamUrl]; } - + + self.lastUrlString = streamUrl; [self setNowPlayingInfo:true]; }