Merge pull request #800 from tablexi/allow-progress-update-interval-to-work-on-ios

Allow setting progressUpdateInterval to work on iOS
This commit is contained in:
Hampton Maxwell 2018-05-29 16:11:44 -07:00 committed by GitHub
commit 6c139a7821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,10 +124,11 @@ static NSString *const timedMetadata = @"timedMetadata";
return (kCMTimeRangeZero);
}
- (void)addPlayerTimeObserver
-(void)addPlayerTimeObserver
{
const Float64 progressUpdateIntervalMS = _progressUpdateInterval / 1000;
// @see endScrubbing in AVPlayerDemoPlaybackViewController.m of https://developer.apple.com/library/ios/samplecode/AVPlayerDemo/Introduction/Intro.html
// @see endScrubbing in AVPlayerDemoPlaybackViewController.m
// of https://developer.apple.com/library/ios/samplecode/AVPlayerDemo/Introduction/Intro.html
__weak RCTVideo *weakSelf = self;
_timeObserver = [_player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(progressUpdateIntervalMS, NSEC_PER_SEC)
queue:NULL
@ -738,6 +739,11 @@ static NSString *const timedMetadata = @"timedMetadata";
- (void)setProgressUpdateInterval:(float)progressUpdateInterval
{
_progressUpdateInterval = progressUpdateInterval;
if (_timeObserver) {
[self removePlayerTimeObserver];
[self addPlayerTimeObserver];
}
}
- (void)removePlayerLayer