Update UriAudioSource.m (#181)
This commit is contained in:
parent
c48bf4c2b0
commit
65912ec4e0
|
@ -50,21 +50,38 @@
|
|||
|
||||
- (void)seek:(CMTime)position completionHandler:(void (^)(BOOL))completionHandler {
|
||||
if (!completionHandler || (_playerItem.status == AVPlayerItemStatusReadyToPlay)) {
|
||||
[_playerItem seekToTime:position toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:completionHandler];
|
||||
CMTimeRange seekableRange = [_playerItem.seekableTimeRanges.lastObject CMTimeRangeValue];
|
||||
CMTime relativePosition = CMTimeAdd(position, seekableRange.start);
|
||||
[_playerItem seekToTime:relativePosition toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:completionHandler];
|
||||
}
|
||||
}
|
||||
|
||||
- (CMTime)duration {
|
||||
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
||||
if (seekableRange) {
|
||||
CMTimeRange seekableDuration = [seekableRange CMTimeRangeValue];;
|
||||
return seekableDuration.duration;
|
||||
}
|
||||
else {
|
||||
return _playerItem.duration;
|
||||
}
|
||||
return kCMTimeInvalid;
|
||||
}
|
||||
|
||||
- (void)setDuration:(CMTime)duration {
|
||||
}
|
||||
|
||||
- (CMTime)position {
|
||||
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
||||
if (seekableRange) {
|
||||
CMTimeRange range = [seekableRange CMTimeRangeValue];
|
||||
return CMTimeSubtract(_playerItem.currentTime, range.start);
|
||||
} else {
|
||||
return _playerItem.currentTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (CMTime)bufferedPosition {
|
||||
NSValue *last = _playerItem.loadedTimeRanges.lastObject;
|
||||
if (last) {
|
||||
|
|
Loading…
Reference in New Issue