Merge branch 'master' into master
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onPlaybackStalled;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onPlaybackResume;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onPlaybackRateChange;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onVideoExternalPlaybackChange;
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
@@ -12,6 +12,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty";
|
||||
static NSString *const readyForDisplayKeyPath = @"readyForDisplay";
|
||||
static NSString *const playbackRate = @"rate";
|
||||
static NSString *const timedMetadata = @"timedMetadata";
|
||||
static NSString *const externalPlaybackActive = @"externalPlaybackActive";
|
||||
|
||||
static int const RCTVideoUnset = -1;
|
||||
|
||||
@@ -35,6 +36,7 @@ static int const RCTVideoUnset = -1;
|
||||
/* Required to publish events */
|
||||
RCTEventDispatcher *_eventDispatcher;
|
||||
BOOL _playbackRateObserverRegistered;
|
||||
BOOL _isExternalPlaybackActiveObserverRegistered;
|
||||
BOOL _videoLoadStarted;
|
||||
|
||||
bool _pendingSeek;
|
||||
@@ -76,6 +78,7 @@ static int const RCTVideoUnset = -1;
|
||||
_eventDispatcher = eventDispatcher;
|
||||
|
||||
_playbackRateObserverRegistered = NO;
|
||||
_isExternalPlaybackActiveObserverRegistered = NO;
|
||||
_playbackStalled = NO;
|
||||
_rate = 1.0;
|
||||
_volume = 1.0;
|
||||
@@ -342,12 +345,19 @@ static int const RCTVideoUnset = -1;
|
||||
[_player removeObserver:self forKeyPath:playbackRate context:nil];
|
||||
_playbackRateObserverRegistered = NO;
|
||||
}
|
||||
if (_isExternalPlaybackActiveObserverRegistered) {
|
||||
[_player removeObserver:self forKeyPath:externalPlaybackActive context:nil];
|
||||
_isExternalPlaybackActiveObserverRegistered = NO;
|
||||
}
|
||||
|
||||
_player = [AVPlayer playerWithPlayerItem:_playerItem];
|
||||
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
|
||||
|
||||
[_player addObserver:self forKeyPath:playbackRate options:0 context:nil];
|
||||
_playbackRateObserverRegistered = YES;
|
||||
|
||||
[_player addObserver:self forKeyPath:externalPlaybackActive options:0 context:nil];
|
||||
_isExternalPlaybackActiveObserverRegistered = YES;
|
||||
|
||||
[self addPlayerTimeObserver];
|
||||
|
||||
@@ -659,6 +669,12 @@ static int const RCTVideoUnset = -1;
|
||||
_playbackStalled = NO;
|
||||
}
|
||||
}
|
||||
else if([keyPath isEqualToString:externalPlaybackActive]) {
|
||||
if(self.onVideoExternalPlaybackChange) {
|
||||
self.onVideoExternalPlaybackChange(@{@"isExternalPlaybackActive": [NSNumber numberWithBool:_player.isExternalPlaybackActive],
|
||||
@"target": self.reactTag});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
@@ -1328,6 +1344,10 @@ static int const RCTVideoUnset = -1;
|
||||
[_player removeObserver:self forKeyPath:playbackRate context:nil];
|
||||
_playbackRateObserverRegistered = NO;
|
||||
}
|
||||
if (_isExternalPlaybackActiveObserverRegistered) {
|
||||
[_player removeObserver:self forKeyPath:externalPlaybackActive context:nil];
|
||||
_isExternalPlaybackActiveObserverRegistered = NO;
|
||||
}
|
||||
_player = nil;
|
||||
|
||||
[self removePlayerLayer];
|
||||
|
@@ -57,6 +57,7 @@ RCT_EXPORT_VIEW_PROPERTY(onReadyForDisplay, RCTBubblingEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onPlaybackStalled, RCTBubblingEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onPlaybackResume, RCTBubblingEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTBubblingEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onVideoExternalPlaybackChange, RCTBubblingEventBlock);
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
|
Reference in New Issue
Block a user