Closed benwiley4000 closed 5 years ago
Going to track currentTime
instead of bufferedRanges
since in practice these values seem to be roughly the same but the max buffered value increases sporadically, making playback progress look kind of crazy.
I noticed some issues while testing #373. If we are playing an unbounded media stream with
Infinity
duration, we have an undesirable time progress display:As we can see for the duration the minute count is
Infinity
and the second count isNaN
. The current time display is unaffected.However if we begin seeking the currentTime ends up displaying the same way:
And as soon as we try to set the
currentTime
to the seek time, we encounter a runtime error:Solution
When the track duration is
Infinity
, instead of storing that as the duration, we should use the highest known buffered time value and pass that through context as theduration
value. If there is no known buffered time value, we will pass 0.We can store the
highestKnownBufferedTime
in state when we handle theprogress
event by extracting theend
value at the last index of thebufferedRanges
array and returning the max of that and the previous max value.