Skip to content

Commit

Permalink
Merge pull request #9 from brettpappas/patch-4
Browse files Browse the repository at this point in the history
Better handling of resume/play function
  • Loading branch information
tlenclos committed Aug 5, 2016
2 parents 74b1a30 + e079e9c commit fa4ad8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions ios/ReactNativeAudioStreaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions ios/ReactNativeAudioStreaming.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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];
}

Expand Down

0 comments on commit fa4ad8d

Please sign in to comment.