Repository navigation
fix: emit spec progress event from HTML5 adapter - #110
Merged
Merged
Conversation
The HTML5 adapter emitted 'buffered', which is not in the spec, so
player.on('progress') never fired. Its "percent" was video.buffered.length,
the number of buffered time ranges, not a fraction (#79).
Emit 'progress' with how far the media has buffered: seconds (end of the
last buffered range) and duration, as SPEC.rst defines, plus percent (0-1)
as the README documents. duration and percent are null when the duration
is unknown or infinite.
The test server gains ?throttle=1 to send media slowly, so the progress
test sees a real download instead of the local file arriving at once.
Existing embedders listen for the HTML5 adapter's 'buffered' event, so it
stays, with its original payload ({ percent: <number of buffered ranges> }).
'progress' is emitted in addition, not instead.
Adds a test that the legacy event still fires with that payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The HTML5 adapter only emitted
'buffered', which isn't in the spec, soplayer.on('progress')never fired. That event'spercentis alsovideo.buffered.length, the number of buffered time ranges, not a fraction (#79).Change
src/adapters/html.jsnow also emitsprogress, with how far the media has buffered:seconds: the end of the last buffered range.secondsanddurationare the payload SPEC.rst defines.percent:seconds / duration, capped at 1, which is what the README documents. The spec and README disagree, so it sends both.durationandpercentarenullwhen the duration is unknown or infinite, for example live streams.bufferedis unchanged. Existing embedders listen for it, so it is still emitted on every mediaprogressevent with its original payload,{ percent: <number of buffered ranges> }.progressis an addition, so nothing changes for current listeners. New code should useprogress.Tests
bufferedstill fires with its original integer payload.test.fail()for this bug is now a regular test. It checks the payload shape, thatseconds <= duration, and thatpercent === seconds / duration.?throttle=1, which sends media in 32 KB chunks every 100 ms. The test uses it together withpreload="none". Otherwise the small local file arrives in one go, and Chrome sometimes fires noprogressevents at all. Before throttling the test failed about 1 run in 8. With throttling it passed 20 of 20 runs.Related: #47, a closed report that
player.on('progress')never fired.Closes #79