feat(spf): Added autoplay support - #1880
Conversation
|
@spuppo-mux is attempting to deploy a commit to the Mux Team on Vercel. A member of the Team first needs to authorize it. |
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5f7ccb1. Configure here.
cjpillsbury
left a comment
There was a problem hiding this comment.
I'm down. We may want to revisit this, but this also may be good enough for now (and maybe even the "right" solution overall).

Summary
autoplayhad no effect on the SPF HLS adapter unlesspreloadwas also set.Root cause: the adapter never bridged
autoplayto the engine's load activation. Withpreloadunset ornone, the engine loads nothing untilloadActivatedflips true — butloadActivatedonly flips on a DOMplay/seekingevent, and nothing plays until data has loaded. Settingpreloadsidestepped it by loading independently, which is why autoplay only "worked" alongside a preload value.Part of #1795 (media API extensions on the SPF adapter).
Fix
trackLoadTriggersnow treatsel.autoplayas an upfront commitment to load, alongside the existing "already playing / mid-seek on entry" checks. When the attached media element has autoplay on entry to monitoring,loadActivatedis set to true immediately (no play / seeking listeners attached) rather than waiting for a play event that preload="none" would never let fire.The browser's autoplay policy (muted-gating, unmuted blocking) is untouched. SPF just gets far enough for the browser to make its own call.
Autoplay is read straight off
context.mediaElement, with no state slot and no adapter/engine changes. The element is already the source of truth:<simple-hls-video autoplay>reflects the attribute onto the inner<video>(via CustomMediaElement), and the low-level engine harness setsvideo.autoplaydirectly before attach.Repro
Go to Sandbox on
/?platform=html&styling=css&preset=simple-hls-video&skin=default&source=hls-multi-audio&autoplay=1&muted=1&loop=0&preload=none&locale=en(simple-hls muted autoplay, no preload) and validate that before the changes this does not autoplay but after this changes it does.Example: On another branch, this does not autoplay even though autoplay is on https://v10-sandbox-git-fork-spuppo-mux-feat-spf-adapter-med-3b75be-mux.vercel.app/?platform=html&styling=css&preset=simple-hls-video&skin=default&source=hls-multi-audio&autoplay=1&muted=1&loop=0&preload=none&locale=en
Go to the same path on this deployment and it should work.
https://v10-sandbox-kvd3wy019-mux.vercel.app/?platform=html&styling=css&preset=simple-hls-video&skin=default&source=hls-multi-audio&autoplay=1&muted=1&loop=0&preload=none&locale=en
Same for https://v10-sandbox-kvd3wy019-mux.vercel.app/spf-segment-loading/?muted=true&autoplay=true&preload=none
Some other cases:
Testing
Notes
Note
Medium Risk
Changes when segment loading starts via
loadActivated, which gates HLS load behavior, but the scope is narrow and covered by new unit tests.Overview
trackLoadTriggersnow treatsel.autoplaylike an upfront commitment to load, not onlyplay/seekingor an already-playing element. When the attached media element has autoplay on entry,loadActivatedis set totrueimmediately andplay/seekinglisteners are not attached, sopreload="none"no longer blocks loading while waiting for aplayevent that never comes.Tests add
autoplayto the fake video helper and assert the new on-entry activation path and that listeners stay detached.Reviewed by Cursor Bugbot for commit 87df1aa. Bugbot is set up for automated code reviews on this repo. Configure here.