Skip to content

fix: emit spec progress event from HTML5 adapter - #110

Merged
luwes merged 2 commits into
masterfrom
fix/html5-progress-event
Nov 3, 2026
Merged

luwes merged 2 commits into
masterfrom
fix/html5-progress-event

Conversation

@luwes

@luwes luwes commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

The HTML5 adapter only emitted 'buffered', which isn't in the spec, so player.on('progress') never fired. That event's percent is also video.buffered.length, the number of buffered time ranges, not a fraction (#79).

Change

src/adapters/html.js now also emits progress, with how far the media has buffered:

{ seconds: 12.4, duration: 30.1, percent: 0.41 }
  • seconds: the end of the last buffered range. seconds and duration are 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.
  • duration and percent are null when the duration is unknown or infinite, for example live streams.
  • No event is sent while nothing is buffered yet.

buffered is unchanged. Existing embedders listen for it, so it is still emitted on every media progress event with its original payload, { percent: <number of buffered ranges> }. progress is an addition, so nothing changes for current listeners. New code should use progress.

Tests

  • A new test checks that buffered still fires with its original integer payload.
  • The test.fail() for this bug is now a regular test. It checks the payload shape, that seconds <= duration, and that percent === seconds / duration.
  • The test server gains ?throttle=1, which sends media in 32 KB chunks every 100 ms. The test uses it together with preload="none". Otherwise the small local file arrives in one go, and Chrome sometimes fires no progress events at all. Before throttling the test failed about 1 run in 8. With throttling it passed 20 of 20 runs.
  • The HTML5 tests passed 180 of 180 runs across 3 rounds. One earlier local round was unusually slow, about 3 minutes, and showed only 59 of 60 in its summary. I couldn't reproduce that, so I'm noting it here in case CI shows the same thing.

Related: #47, a closed report that player.on('progress') never fired.

Closes #79

luwes added 2 commits November 2, 2026 20:54
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.
@luwes
luwes merged commit e485f5d into master Nov 3, 2026
1 check passed
@luwes
luwes deleted the fix/html5-progress-event branch November 3, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML5 adapter progress percent bug

1 participant