Fix Airplay crash issue (#186)
* Update UriAudioSource.m * Fix issue when starting route is Airplay and no seekableTimeRanges available Co-authored-by: snaebjornl <snaebjorn.lilliendahl@ruv.is>
This commit is contained in:
parent
c13efc0cbd
commit
02d1b78a36
|
@ -50,16 +50,19 @@
|
||||||
|
|
||||||
- (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)) {
|
||||||
CMTimeRange seekableRange = [_playerItem.seekableTimeRanges.lastObject CMTimeRangeValue];
|
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
||||||
CMTime relativePosition = CMTimeAdd(position, seekableRange.start);
|
if (seekableRange) {
|
||||||
[_playerItem seekToTime:relativePosition toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:completionHandler];
|
CMTimeRange range = [seekableRange CMTimeRangeValue];
|
||||||
|
position = CMTimeAdd(position, range.start);
|
||||||
|
}
|
||||||
|
[_playerItem seekToTime:position toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:completionHandler];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CMTime)duration {
|
- (CMTime)duration {
|
||||||
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
|
||||||
if (seekableRange) {
|
if (seekableRange) {
|
||||||
CMTimeRange seekableDuration = [seekableRange CMTimeRangeValue];;
|
CMTimeRange seekableDuration = [seekableRange CMTimeRangeValue];
|
||||||
return seekableDuration.duration;
|
return seekableDuration.duration;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue