Skip to content

Commit

Permalink
Merge pull request #832 from jalieven/upstream
Browse files Browse the repository at this point in the history
Preventing multiple observers for the same notification
  • Loading branch information
cobarx committed Jun 4, 2018
2 parents cc823e3 + 2ae99bd commit 88f6e7d
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 @@ -462,10 +462,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 88f6e7d

Please sign in to comment.