Loading RCTVideo.m +22 −0 Changes for RCTVideo.m: 22 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ static NSString *const statusKeyPath = @"status"; (([_prevProgressUpdateTime timeIntervalSinceNow] * -1000.0) >= _progressUpdateInterval)) { [_eventDispatcher sendInputEventWithName:RNVideoEventProgress body:@{ @"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(video.currentTime)], @"playableDuration": [self calculatePlayableDuration], @"target": self.reactTag }]; Loading @@ -76,6 +77,27 @@ static NSString *const statusKeyPath = @"status"; } } /*! * Calculates and returns the playable duration of the current player item using its loaded time ranges. * * \returns The playable duration of the current player item in seconds. */ - (NSNumber *)calculatePlayableDuration { AVPlayerItem *video = _player.currentItem; if (video.status == AVPlayerItemStatusReadyToPlay) { __block CMTimeRange effectiveTimeRange; [video.loadedTimeRanges enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { CMTimeRange timeRange = [obj CMTimeRangeValue]; if (CMTimeRangeContainsTime(timeRange, video.currentTime)) { effectiveTimeRange = timeRange; *stop = YES; } }]; return [NSNumber numberWithFloat:CMTimeGetSeconds(CMTimeRangeGetEnd(effectiveTimeRange))]; } return [NSNumber numberWithFloat:CMTimeGetSeconds(kCMTimeInvalid)]; } - (void)stopProgressTimer { [_progressUpdateTimer invalidate]; Loading Loading
RCTVideo.m +22 −0 Changes for RCTVideo.m: 22 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ static NSString *const statusKeyPath = @"status"; (([_prevProgressUpdateTime timeIntervalSinceNow] * -1000.0) >= _progressUpdateInterval)) { [_eventDispatcher sendInputEventWithName:RNVideoEventProgress body:@{ @"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(video.currentTime)], @"playableDuration": [self calculatePlayableDuration], @"target": self.reactTag }]; Loading @@ -76,6 +77,27 @@ static NSString *const statusKeyPath = @"status"; } } /*! * Calculates and returns the playable duration of the current player item using its loaded time ranges. * * \returns The playable duration of the current player item in seconds. */ - (NSNumber *)calculatePlayableDuration { AVPlayerItem *video = _player.currentItem; if (video.status == AVPlayerItemStatusReadyToPlay) { __block CMTimeRange effectiveTimeRange; [video.loadedTimeRanges enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { CMTimeRange timeRange = [obj CMTimeRangeValue]; if (CMTimeRangeContainsTime(timeRange, video.currentTime)) { effectiveTimeRange = timeRange; *stop = YES; } }]; return [NSNumber numberWithFloat:CMTimeGetSeconds(CMTimeRangeGetEnd(effectiveTimeRange))]; } return [NSNumber numberWithFloat:CMTimeGetSeconds(kCMTimeInvalid)]; } - (void)stopProgressTimer { [_progressUpdateTimer invalidate]; Loading