Problems with displaying/seeking time when track has Infinity duration
Closed this issue · 1 comments
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 is NaN
. 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 the duration
value. If there is no known buffered time value, we will pass 0.
We can store the highestKnownBufferedTime
in state when we handle the progress
event by extracting the end
value at the last index of the bufferedRanges
array and returning the max of that and the previous max value.
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.