From f244f662b6cee6ca66c411105fed3eb12b8e1ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 28 Apr 2016 14:29:09 +0200 Subject: [PATCH] Add observer for _player rate --- RCTVideo.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RCTVideo.m b/RCTVideo.m index 9514c18a..14dbf5bc 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -8,6 +8,7 @@ static NSString *const statusKeyPath = @"status"; static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp"; static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; static NSString *const readyForDisplayKeyPath = @"readyForDisplay"; +static NSString *const playbackRate = @"rate"; @implementation RCTVideo { @@ -220,6 +221,7 @@ static NSString *const readyForDisplayKeyPath = @"readyForDisplay"; _player = [AVPlayer playerWithPlayerItem:_playerItem]; _player.actionAtItemEnd = AVPlayerActionAtItemEndNone; + [_player addObserver:self forKeyPath:playbackRate options:0 context:nil]; const Float64 progressUpdateIntervalMS = _progressUpdateInterval / 1000; // @see endScrubbing in AVPlayerDemoPlaybackViewController.m of https://developer.apple.com/library/ios/samplecode/AVPlayerDemo/Introduction/Intro.html @@ -628,6 +630,7 @@ static NSString *const readyForDisplayKeyPath = @"readyForDisplay"; - (void)removeFromSuperview { [_player pause]; + [_player removeObserver:self forKeyPath:playbackRate]; _player = nil; [self removePlayerLayer];