add seekableDuration (#285)
This commit is contained in:
parent
3130bce6bd
commit
83dd4c3ba9
16
RCTVideo.m
16
RCTVideo.m
@ -110,6 +110,17 @@ static NSString *const playbackRate = @"rate";
|
|||||||
return(kCMTimeInvalid);
|
return(kCMTimeInvalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (CMTimeRange)playerItemSeekableTimeRange
|
||||||
|
{
|
||||||
|
AVPlayerItem *playerItem = [_player currentItem];
|
||||||
|
if (playerItem.status == AVPlayerItemStatusReadyToPlay)
|
||||||
|
{
|
||||||
|
return [playerItem seekableTimeRanges].firstObject.CMTimeRangeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (kCMTimeRangeZero);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Cancels the previously registered time observer. */
|
/* Cancels the previously registered time observer. */
|
||||||
-(void)removePlayerTimeObserver
|
-(void)removePlayerTimeObserver
|
||||||
@ -173,14 +184,15 @@ static NSString *const playbackRate = @"rate";
|
|||||||
CMTime currentTime = _player.currentTime;
|
CMTime currentTime = _player.currentTime;
|
||||||
const Float64 duration = CMTimeGetSeconds(playerDuration);
|
const Float64 duration = CMTimeGetSeconds(playerDuration);
|
||||||
const Float64 currentTimeSecs = CMTimeGetSeconds(currentTime);
|
const Float64 currentTimeSecs = CMTimeGetSeconds(currentTime);
|
||||||
if( currentTimeSecs >= 0 && currentTimeSecs <= duration) {
|
if( currentTimeSecs >= 0) {
|
||||||
[_eventDispatcher sendInputEventWithName:@"onVideoProgress"
|
[_eventDispatcher sendInputEventWithName:@"onVideoProgress"
|
||||||
body:@{
|
body:@{
|
||||||
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(currentTime)],
|
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(currentTime)],
|
||||||
@"playableDuration": [self calculatePlayableDuration],
|
@"playableDuration": [self calculatePlayableDuration],
|
||||||
@"atValue": [NSNumber numberWithLongLong:currentTime.value],
|
@"atValue": [NSNumber numberWithLongLong:currentTime.value],
|
||||||
@"atTimescale": [NSNumber numberWithInt:currentTime.timescale],
|
@"atTimescale": [NSNumber numberWithInt:currentTime.timescale],
|
||||||
@"target": self.reactTag
|
@"target": self.reactTag,
|
||||||
|
@"seekableDuration": [NSNumber numberWithFloat:CMTimeGetSeconds([self playerItemSeekableTimeRange].duration)],
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user