Skip to content

docs: multi-audio-track API design#1636

Open
ronald-urbina wants to merge 2 commits into
videojs:mainfrom
ronald-urbina:docs/audio-track-api-design
Open

docs: multi-audio-track API design#1636
ronald-urbina wants to merge 2 commits into
videojs:mainfrom
ronald-urbina:docs/audio-track-api-design

Conversation

@ronald-urbina

@ronald-urbina ronald-urbina commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Adds a design doc for the multi-audio-track consumer API (issue #1261). SPF already handles audio renditions internally — this doc covers how to surface them through the existing feature/predicate/selector pattern used by streamType and textTrack, and explains why the text track DOM path doesn't apply to audio (MSE vs elements). Meant as a team read before we start coding.

start to resolve 1261


Note

Low Risk
Documentation-only change with no runtime or API surface modifications.

Overview
Adds internal/design/audio-track-api.md, a draft design for exposing SPF’s internal HLS audio renditions as a stable consumer API (issue #1261).

The doc proposes mirroring textTrackFeature / streamType: MediaTracksLayer on SimpleHlsMedia, a SimpleHlsMediaTracks extension syncing SPF presentation / selectedAudioTrackId with DOM audioTracks, a new audioTrackFeature with selectAudioTrack, and inclusion in all four feature presets—without changing SPF internals or scoping HlsJsMedia / NativeHlsMedia in this effort.

Reviewed by Cursor Bugbot for commit 72a33b2. Bugbot is set up for automated code reviews on this repo. Configure here.

@netlify

netlify Bot commented Jun 1, 2026

Copy link
Copy Markdown

👷 Deploy request for vjs10-site pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 72a33b2

@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown

@ronald-urbina is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a697759. Configure here.

Comment thread internal/design/audio-track-api.md Outdated
**Adapter (`SimpleHlsMedia`, in core).** `SimpleHlsMedia` is the boundary where SPF internals meet the rest of the stack. It gains an `audioTracks` read-only property (returning a list of track objects with `id`, `label`, `language`, `kind`, and `enabled`), a `selectAudioTrack(id)` method, and fires an `audiotrackschange` event whenever the track list or active selection changes.

Internally it uses SPF's `effect()` to watch `presentation` and `selectedAudioTrackId` signals and dispatch the event when either changes. The effect is created fresh on each `src` assignment and torn down on `destroy()`, matching the engine lifecycle.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect cleanup missing on src

Medium Severity

The adapter effect() is only described as torn down on destroy(), but SimpleHlsMediaMixin recreates the engine on every src assignment via #engine.destroy() without calling adapter destroy(). Implementations that follow the doc literally would leave prior effects subscribed and leak watchers plus duplicate audiotrackschange dispatches after each source change.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a697759. Configure here.

Comment thread internal/design/audio-track-api.md Outdated

Internally it uses SPF's `effect()` to watch `presentation` and `selectedAudioTrackId` signals and dispatch the event when either changes. The effect is created fresh on each `src` assignment and torn down on `destroy()`, matching the engine lifecycle.

The track shape maps SPF's `AudioTrack` fields to a clean public surface: `name` becomes `label`, `language` carries over, and `enabled` is derived by comparing each track's `id` to `selectedAudioTrackId`. SPF's `AudioTrack` has no `kind` field — the property defaults to `'main'`, appropriate for HLS audio renditions today.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved presentation track enumeration

Medium Severity

The design has the adapter effect() react to presentation changes to build audioTracks, but presentation is often only { url } until parsing finishes. Enumerating selectionSets without narrowing to a resolved presentation (as existing SPF helpers do) can throw at runtime and leaves the doc silent on returning an empty list while unresolved.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a697759. Configure here.

Comment thread internal/design/audio-track-api.md Outdated

## Proposed Architecture

**Adapter (`SimpleHlsMedia`, in core).** `SimpleHlsMedia` is the boundary where SPF internals meet the rest of the stack. It gains an `audioTracks` read-only property (returning a list of track objects with `id`, `label`, `language`, `kind`, and `enabled`), a `selectAudioTrack(id)` method, and fires an `audiotrackschange` event whenever the track list or active selection changes.

@luwes luwes Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for new API's on the media, they're covered by
https://github.com/muxinc/media-elements/tree/main/packages/media-tracks

Look for the hls.js implementation at #1609

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

@ronald-urbina ronald-urbina requested a review from luwes June 2, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Feature: Implement Multi Audio Tracks API for Supported Media Components

2 participants