Get duration directly from asset

It is more reliable because the current item directly will return NaN depending on what's loaded.
This commit is contained in:
David Chavez
2019-01-30 20:39:19 +01:00
committed by GitHub
parent debc1c519f
commit e96cbf6337
@@ -85,7 +85,10 @@ class AVPlayerWrapper: AVPlayerWrapperProtocol {
}
var duration: TimeInterval {
if let seconds = currentItem?.duration.seconds, !seconds.isNaN {
if let seconds = currentItem?.asset.duration.seconds, !seconds.isNaN {
return seconds
}
else if let seconds = currentItem?.duration.seconds, !seconds.isNaN {
return seconds
}
else if let seconds = currentItem?.loadedTimeRanges.first?.timeRangeValue.duration.seconds,