Skip to content

Commit

Permalink
remove observers before adding thus preventing multiple observers for…
Browse files Browse the repository at this point in the history
… the same notification
  • Loading branch information
jalieven committed Oct 24, 2017
1 parent f73b7a0 commit 2ae99bd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ios/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,17 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
- (void)attachListeners
{
// listen for end of file
[[NSNotificationCenter defaultCenter] removeObserver:self
name:AVPlayerItemDidPlayToEndTimeNotification
object:[_player currentItem]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[_player currentItem]];

[[NSNotificationCenter defaultCenter] removeObserver:self
name:AVPlayerItemPlaybackStalledNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackStalled:)
name:AVPlayerItemPlaybackStalledNotification
Expand Down

0 comments on commit 2ae99bd

Please sign in to comment.