From edf3a8c5799f2bf2440b1e4d1dfb19b907f7f238 Mon Sep 17 00:00:00 2001 From: Don Nguyen Date: Fri, 27 May 2016 15:56:16 +0700 Subject: [PATCH] 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 --- RCTVideo.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index 7e48fb4d..4221fe76 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -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;