feat(spf): expose media tracks on the SPF media adapter - #1826
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 22c5af0. Configure here.
cjpillsbury
left a comment
There was a problem hiding this comment.
A few callouts, mostly minor or non-blocking with one testing ask. Otherwise and overall, looks 😎.
| }); | ||
|
|
||
| // Drain microtasks (effects) and the queued DOM track/rendition events. | ||
| const flush = () => new Promise((resolve) => setTimeout(resolve, 0)); |
There was a problem hiding this comment.
suggestion(non-blocking): consider tying this more directly to the effect() timing so it's more resilient, something like:
const flush = async () => {
const sig = signal(0);
return new Promise((resolve) => {
effect(() => {
resolve(sig.get());
});
sig.set(sig.get() + 1);
});
}| * Dedupe tracks by a key function, keeping the first occurrence of each key. | ||
| * Keys are compared field-by-field ({@link sameKey}). | ||
| */ | ||
| function dedupe<T, K extends object>({ |
There was a problem hiding this comment.
thought(non-blocking): This could probably be refactored to more directly use Object.entries() in a reduce or similiar instead of seen + kept but this is probably also fine.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1efea49 to
3bba439
Compare

Part 1 of #1795 (video+audio → streamType → live → parity/autoplay).
What:
SimpleHlsMedianow projects the SPF engine's video renditions and audio tracks onto the standard videoTracks / videoRenditions / audioTracks DOM surface (read, write, events) so a quality menu binds to it with no adapter-specific code, matchingHlsJsMedia.How:
SPF - New
@videojs/spf/media-tracksmodule Provides mapping from SPF Media Tracks (AudioTrack and VideoTrack lists) into MediaTrack API model.dedupedAudioTracksanddedupedVideoTracks- the distinct tracks of a presentation, deduped by properties (video: width+height+bandwidth; audio: language+name).toUserAudioTrackSelectionandtoUserVideoTrackSelection- build the user*TrackSelection partials the engine's track-switching matches on.isSameVideoTrackandisSameAudioTrack- compare two tracks by their dedupe key.frameRateToNumber, plus theVideoDedupeKey/AudioDedupeKeyshapes.Mainly deduped lists of tracks grouped by certain keys. These same keys are used to create userAudioTrackSelection and userVideoTrackSelection using the existing SPF logic. Also provides a utility function to translate from the FrameRate model to a number (as used in API). This module uses SPF model and is purposely DOM-free.
Core - A projection mixin (
SimpleHlsMediaMediaTracksMixin):dedupedVideoTracksand one audioTrack per item indedupedAudioTracks, reflecting engine selection.userVideoTrackSelectionandaudioTrackSelectionusing toUser*TrackSelection functions.Design decisions:
@videojs/core, but to do that we would need an independant@videojs/media-trackpackage. Therefore, the mixin is added to core'sdom/media/simple-hlswhich depends onspf/media-tracksandspf/hls. Tried to keep dom related vocabulary to the mixin and SPF model vocabulary in the new module.Test plan:
Note
Medium Risk
Touches playback track switching and bidirectional sync between DOM and engine signals; mistakes could mis-report quality/audio or cause selection loops, though behavior is heavily tested.
Overview
SimpleHlsMedianow mirrorsHlsJsMedia: the SPF engine’s presentation is projected ontovideoTracks/videoRenditions/audioTracks, and UI-driven changes write back touserVideoTrackSelectionanduserAudioTrackSelection.A new
@videojs/spf/media-tracksexport provides DOM-free helpers—dedupedVideoTracks/dedupedAudioTracks(multi-CDN collapse by resolution+bandwidth or language+name),toUser*TrackSelection, property-basedisSame*matching, andfind*TrackByIdfor engine-resolved ids that may not appear in the deduped list.SimpleHlsMediaMediaTracksMixin(stacked withMediaTracksMixinonSimpleHlsMedia) uses SPF effects to rebuild lists when track ids change, reflectactive/enabledfrom engine selection, pin manual quality (selectedIndex, Auto clears the pin), handle non-exclusive audioenabledwith a guard against feedback loops, clear pins when the manifest URL changes (but keep pins on same-URL live reload), and tear down ondestroy.Unit tests cover the SPF transforms and the DOM projection (dedup, failover reflection, source change, destroy).
Reviewed by Cursor Bugbot for commit 6813123. Bugbot is set up for automated code reviews on this repo. Configure here.