Prevent onLoad event during seeking
This commit is contained in:
parent
f51b929159
commit
4174d5a713
@ -25,6 +25,7 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
/* Required to publish events */
|
/* Required to publish events */
|
||||||
RCTEventDispatcher *_eventDispatcher;
|
RCTEventDispatcher *_eventDispatcher;
|
||||||
BOOL _playbackRateObserverRegistered;
|
BOOL _playbackRateObserverRegistered;
|
||||||
|
BOOL _videoLoadStarted;
|
||||||
|
|
||||||
bool _pendingSeek;
|
bool _pendingSeek;
|
||||||
float _pendingSeekTime;
|
float _pendingSeekTime;
|
||||||
@ -316,6 +317,7 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_videoLoadStarted = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (AVPlayerItem*)playerItemForSource:(NSDictionary *)source
|
- (AVPlayerItem*)playerItemForSource:(NSDictionary *)source
|
||||||
@ -352,18 +354,12 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||||
{
|
{
|
||||||
if (object == _playerItem) {
|
if (object == _playerItem) {
|
||||||
|
|
||||||
// When timeMetadata is read the event onTimedMetadata is triggered
|
// When timeMetadata is read the event onTimedMetadata is triggered
|
||||||
if ([keyPath isEqualToString: timedMetadata])
|
if ([keyPath isEqualToString:timedMetadata]) {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
NSArray<AVMetadataItem *> *items = [change objectForKey:@"new"];
|
NSArray<AVMetadataItem *> *items = [change objectForKey:@"new"];
|
||||||
if (items && ![items isEqual:[NSNull null]] && items.count > 0) {
|
if (items && ![items isEqual:[NSNull null]] && items.count > 0) {
|
||||||
|
|
||||||
NSMutableArray *array = [NSMutableArray new];
|
NSMutableArray *array = [NSMutableArray new];
|
||||||
for (AVMetadataItem *item in items) {
|
for (AVMetadataItem *item in items) {
|
||||||
|
|
||||||
NSString *value = item.value;
|
NSString *value = item.value;
|
||||||
NSString *identifier = item.identifier;
|
NSString *identifier = item.identifier;
|
||||||
|
|
||||||
@ -405,11 +401,12 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
|| (preferredTransform.tx == 0 && preferredTransform.ty == 0))
|
|| (preferredTransform.tx == 0 && preferredTransform.ty == 0))
|
||||||
{
|
{
|
||||||
orientation = @"landscape";
|
orientation = @"landscape";
|
||||||
} else
|
} else {
|
||||||
orientation = @"portrait";
|
orientation = @"portrait";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(self.onVideoLoad) {
|
if (self.onVideoLoad && _videoLoadStarted) {
|
||||||
self.onVideoLoad(@{@"duration": [NSNumber numberWithFloat:duration],
|
self.onVideoLoad(@{@"duration": [NSNumber numberWithFloat:duration],
|
||||||
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)],
|
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)],
|
||||||
@"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse],
|
@"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse],
|
||||||
@ -426,7 +423,7 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
@"textTracks": [self getTextTrackInfo],
|
@"textTracks": [self getTextTrackInfo],
|
||||||
@"target": self.reactTag});
|
@"target": self.reactTag});
|
||||||
}
|
}
|
||||||
|
_videoLoadStarted = NO;
|
||||||
|
|
||||||
[self attachListeners];
|
[self attachListeners];
|
||||||
[self applyModifiers];
|
[self applyModifiers];
|
||||||
|
Loading…
Reference in New Issue
Block a user