Merge remote-tracking branch 'upstream/master'

This commit is contained in:
tobias 2016-06-02 07:48:36 +02:00
commit 8bc165ca48
2 changed files with 14 additions and 2 deletions

View File

@ -22,6 +22,7 @@ static NSString *const playbackRate = @"rate";
/* Required to publish events */ /* Required to publish events */
RCTEventDispatcher *_eventDispatcher; RCTEventDispatcher *_eventDispatcher;
BOOL _playbackRateObserverRegistered;
bool _pendingSeek; bool _pendingSeek;
float _pendingSeekTime; float _pendingSeekTime;
@ -51,6 +52,7 @@ static NSString *const playbackRate = @"rate";
if ((self = [super init])) { if ((self = [super init])) {
_eventDispatcher = eventDispatcher; _eventDispatcher = eventDispatcher;
_playbackRateObserverRegistered = NO;
_playbackStalled = NO; _playbackStalled = NO;
_rate = 1.0; _rate = 1.0;
_volume = 1.0; _volume = 1.0;
@ -241,9 +243,16 @@ static NSString *const playbackRate = @"rate";
[_playerViewController.view removeFromSuperview]; [_playerViewController.view removeFromSuperview];
_playerViewController = nil; _playerViewController = nil;
if (_playbackRateObserverRegistered) {
[_player removeObserver:self forKeyPath:playbackRate context:nil];
_playbackRateObserverRegistered = NO;
}
_player = [AVPlayer playerWithPlayerItem:_playerItem]; _player = [AVPlayer playerWithPlayerItem:_playerItem];
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone; _player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[_player addObserver:self forKeyPath:playbackRate options:0 context:nil]; [_player addObserver:self forKeyPath:playbackRate options:0 context:nil];
_playbackRateObserverRegistered = YES;
const Float64 progressUpdateIntervalMS = _progressUpdateInterval / 1000; const Float64 progressUpdateIntervalMS = _progressUpdateInterval / 1000;
// @see endScrubbing in AVPlayerDemoPlaybackViewController.m of https://developer.apple.com/library/ios/samplecode/AVPlayerDemo/Introduction/Intro.html // @see endScrubbing in AVPlayerDemoPlaybackViewController.m of https://developer.apple.com/library/ios/samplecode/AVPlayerDemo/Introduction/Intro.html
@ -697,7 +706,10 @@ static NSString *const playbackRate = @"rate";
- (void)removeFromSuperview - (void)removeFromSuperview
{ {
[_player pause]; [_player pause];
[_player removeObserver:self forKeyPath:playbackRate]; if (_playbackRateObserverRegistered) {
[_player removeObserver:self forKeyPath:playbackRate context:nil];
_playbackRateObserverRegistered = NO;
}
_player = nil; _player = nil;
[self removePlayerLayer]; [self removePlayerLayer];

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-video", "name": "react-native-video",
"version": "0.8.0-rc", "version": "0.8.0",
"description": "A <Video /> element for react-native", "description": "A <Video /> element for react-native",
"main": "Video.js", "main": "Video.js",
"license": "MIT", "license": "MIT",