Update UriAudioSource.m (#181)
This commit is contained in:
parent
c48bf4c2b0
commit
65912ec4e0
|
@ -50,19 +50,36 @@
|
||||||
|
|
||||||
- (void)seek:(CMTime)position completionHandler:(void (^)(BOOL))completionHandler {
|
- (void)seek:(CMTime)position completionHandler:(void (^)(BOOL))completionHandler {
|
||||||
if (!completionHandler || (_playerItem.status == AVPlayerItemStatusReadyToPlay)) {
|
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 {
|
- (CMTime)duration {
|
||||||
|
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
||||||
|
if (seekableRange) {
|
||||||
|
CMTimeRange seekableDuration = [seekableRange CMTimeRangeValue];;
|
||||||
|
return seekableDuration.duration;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return _playerItem.duration;
|
return _playerItem.duration;
|
||||||
|
}
|
||||||
|
return kCMTimeInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDuration:(CMTime)duration {
|
- (void)setDuration:(CMTime)duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CMTime)position {
|
- (CMTime)position {
|
||||||
|
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
||||||
|
if (seekableRange) {
|
||||||
|
CMTimeRange range = [seekableRange CMTimeRangeValue];
|
||||||
|
return CMTimeSubtract(_playerItem.currentTime, range.start);
|
||||||
|
} else {
|
||||||
return _playerItem.currentTime;
|
return _playerItem.currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CMTime)bufferedPosition {
|
- (CMTime)bufferedPosition {
|
||||||
|
|
Loading…
Reference in New Issue