Skip to content

actually persist playback rate across source swaps - #10

Merged
karngyan merged 1 commit into
mainfrom
fix-rate-across-swaps
Jun 26, 2026
Merged

actually persist playback rate across source swaps#10
karngyan merged 1 commit into
mainfrom
fix-rate-across-swaps

Conversation

@karngyan

Copy link
Copy Markdown
Collaborator

what

Follow-up to #8. The playback-rate-across-swaps fix in 0.1.1 was a no-op.

el.defaultPlaybackRate = r was set on the <mux-video> custom element, but mux-video does not proxy defaultPlaybackRate to its inner <video> (it proxies playbackRate ~38x in its base; defaultPlaybackRate appears only in its React typedefs). So the HTML load() algorithm still reset playbackRate to the inner element's defaultPlaybackRate (1.0) on every source swap, and the rate dropped to 1x moving to the next lesson.

how

  • Track the chosen rate in a desiredRate closure var.
  • Re-assert el.playbackRate = desiredRate from syncFromEl whenever it drifts. syncFromEl runs on canplay / loadedmetadata / timeupdate / ratechange, so the correction lands as soon as the new source is ready.
  • Report desiredRate as state.rate so the brief reset never surfaces to the UI — or gets persisted by a consumer that mirrors rate to storage.
  • setRate updates desiredRate and patches rate immediately. Dropped the dead defaultPlaybackRate writes.

verification

  • pnpm test (45) / pnpm typecheck / pnpm lint / pnpm build — all clean
  • Provider/mux-video integration isn't unit-testable here (jsdom can't register the real custom element), so this needs a manual browser check: set 1.5x, go to the next lesson, confirm it stays 1.5x.

changeset: patch (→ 0.1.2)

The 0.1.1 fix set el.defaultPlaybackRate, but mux-video does not proxy
that property to its inner <video>, so loading a new source still reset
playbackRate to 1x. Track the chosen rate in desiredRate and re-assert it
on the element from syncFromEl (fires on canplay/loadedmetadata/
timeupdate, so it corrects as soon as the new source is ready). Report
desiredRate as state.rate so the transient reset never surfaces to the UI
or gets persisted by a consumer.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
kino 5e106f4 Commit Preview URL

Branch Preview URL
Jun 26 2026, 11:16 PM

@karngyan
karngyan merged commit fcc6f05 into main Jun 26, 2026
2 checks passed
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.

1 participant