Commit edf3a8c5 authored by Don Nguyen's avatar Don Nguyen
Browse files

Remove observer of player before calling playerWithPlayerItem

It makes no sense if we move observer after calling calling playerWithPlayerItem because this is where the exception raises
parent b6dc7c46
Loading
Loading
Loading
Loading
+4 −3
Changes for RCTVideo.m: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -223,13 +223,14 @@ static NSString *const playbackRate = @"rate";
  [_playerViewController.view removeFromSuperview];
  _playerViewController = nil;

  _player = [AVPlayer playerWithPlayerItem:_playerItem];
  _player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    
  if (_playbackRateObserverRegistered) {
    [_player removeObserver:self forKeyPath:playbackRate context:nil];
    _playbackRateObserverRegistered = NO;
  }

  _player = [AVPlayer playerWithPlayerItem:_playerItem];
  _player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
  
  [_player addObserver:self forKeyPath:playbackRate options:0 context:nil];
  _playbackRateObserverRegistered = YES;