Implemented onReadyForDisplay for iOS when using controls
This commit is contained in:
parent
cc7db91490
commit
420332e078
@ -354,8 +354,6 @@ static int const RCTVideoUnset = -1;
|
||||
[self setMaxBitRate:_maxBitRate];
|
||||
|
||||
[_player pause];
|
||||
[_playerViewController.view removeFromSuperview];
|
||||
_playerViewController = nil;
|
||||
|
||||
if (_playbackRateObserverRegistered) {
|
||||
[_player removeObserver:self forKeyPath:playbackRate context:nil];
|
||||
@ -598,7 +596,10 @@ static int const RCTVideoUnset = -1;
|
||||
} else
|
||||
return [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
|
||||
if([keyPath isEqualToString:readyForDisplayKeyPath] && [change objectForKey:NSKeyValueChangeNewKey] && self.onReadyForDisplay) {
|
||||
self.onReadyForDisplay(@{@"target": self.reactTag});
|
||||
return;
|
||||
}
|
||||
if (object == _playerItem) {
|
||||
// When timeMetadata is read the event onTimedMetadata is triggered
|
||||
if ([keyPath isEqualToString:timedMetadata]) {
|
||||
@ -690,12 +691,6 @@ static int const RCTVideoUnset = -1;
|
||||
_playerBufferEmpty = NO;
|
||||
self.onVideoBuffer(@{@"isBuffering": @(NO), @"target": self.reactTag});
|
||||
}
|
||||
} else if (object == _playerLayer) {
|
||||
if([keyPath isEqualToString:readyForDisplayKeyPath] && [change objectForKey:NSKeyValueChangeNewKey]) {
|
||||
if([change objectForKey:NSKeyValueChangeNewKey] && self.onReadyForDisplay) {
|
||||
self.onReadyForDisplay(@{@"target": self.reactTag});
|
||||
}
|
||||
}
|
||||
} else if (object == _player) {
|
||||
if([keyPath isEqualToString:playbackRate]) {
|
||||
if(self.onPlaybackRateChange) {
|
||||
@ -1283,7 +1278,9 @@ static int const RCTVideoUnset = -1;
|
||||
{
|
||||
if( _player )
|
||||
{
|
||||
_playerViewController = [self createPlayerViewController:_player withPlayerItem:_playerItem];
|
||||
if (!_playerViewController) {
|
||||
_playerViewController = [self createPlayerViewController:_player withPlayerItem:_playerItem];
|
||||
}
|
||||
// to prevent video from being animated when resizeMode is 'cover'
|
||||
// resize mode must be set before subview is added
|
||||
[self setResizeMode:_resizeMode];
|
||||
@ -1293,6 +1290,8 @@ static int const RCTVideoUnset = -1;
|
||||
[viewController addChildViewController:_playerViewController];
|
||||
[self addSubview:_playerViewController.view];
|
||||
}
|
||||
|
||||
[_playerViewController addObserver:self forKeyPath:readyForDisplayKeyPath options:NSKeyValueObservingOptionNew context:nil];
|
||||
|
||||
[_playerViewController.contentOverlayView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
|
||||
}
|
||||
@ -1488,6 +1487,7 @@ static int const RCTVideoUnset = -1;
|
||||
[self removePlayerLayer];
|
||||
|
||||
[_playerViewController.contentOverlayView removeObserver:self forKeyPath:@"frame"];
|
||||
[_playerViewController removeObserver:self forKeyPath:readyForDisplayKeyPath];
|
||||
[_playerViewController.view removeFromSuperview];
|
||||
_playerViewController = nil;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user