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:
snaeji 2020-09-20 16:30:53 +00:00 committed by GitHub
parent c13efc0cbd
commit 02d1b78a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -50,16 +50,19 @@
- (void)seek:(CMTime)position completionHandler:(void (^)(BOOL))completionHandler {
if (!completionHandler || (_playerItem.status == AVPlayerItemStatusReadyToPlay)) {
CMTimeRange seekableRange = [_playerItem.seekableTimeRanges.lastObject CMTimeRangeValue];
CMTime relativePosition = CMTimeAdd(position, seekableRange.start);
[_playerItem seekToTime:relativePosition toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:completionHandler];
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
if (seekableRange) {
CMTimeRange range = [seekableRange CMTimeRangeValue];
position = CMTimeAdd(position, range.start);
}
[_playerItem seekToTime:position toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:completionHandler];
}
}
- (CMTime)duration {
NSValue *seekableRange = _playerItem.seekableTimeRanges.lastObject;
if (seekableRange) {
CMTimeRange seekableDuration = [seekableRange CMTimeRangeValue];;
CMTimeRange seekableDuration = [seekableRange CMTimeRangeValue];
return seekableDuration.duration;
}
else {