Fixed seekableDuration for time ranges with non-numeric duration (#709) (#728)

This commit is contained in:
Alexander Nazarov 2017-09-07 04:12:34 +03:00 committed by Matt Apperson
parent 4bf2b2c45f
commit f73b7a0484

View File

@ -195,7 +195,7 @@ static NSString *const timedMetadata = @"timedMetadata";
@"atValue": [NSNumber numberWithLongLong:currentTime.value],
@"atTimescale": [NSNumber numberWithInt:currentTime.timescale],
@"target": self.reactTag,
@"seekableDuration": [NSNumber numberWithFloat:CMTimeGetSeconds([self playerItemSeekableTimeRange].duration)],
@"seekableDuration": [self calculateSeekableDuration],
});
}
}
@ -225,6 +225,16 @@ static NSString *const timedMetadata = @"timedMetadata";
return [NSNumber numberWithInteger:0];
}
- (NSNumber *)calculateSeekableDuration
{
CMTimeRange timeRange = [self playerItemSeekableTimeRange];
if (CMTIME_IS_NUMERIC(timeRange.duration))
{
return [NSNumber numberWithFloat:CMTimeGetSeconds(timeRange.duration)];
}
return [NSNumber numberWithInteger:0];
}
- (void)addPlayerItemObservers
{
[_playerItem addObserver:self forKeyPath:statusKeyPath options:0 context:nil];