Audio tracks
Playdeck exposes the alternate-audio renditions a provider publishes —
PlayerState.audioTracks — and one command to choose from them,
selectAudioTrack. Not every provider can: capabilities.selectAudioTrack
says so per source, and Player.AudioTrackMenu renders nothing until it
resolves available.
The state
One field: audioTracks, a readonly AudioTrack[] — each entry
{ id, label, language, active }. Unlike a quality's selectedQualityId or
a text track's selectedTextTrackId, there is no sibling selection field
elsewhere on player state: selection lives on the entry itself, as active.
hls.js's own audio-tracks controller enforces at most one active track on
the engine itself; the native provider enforces the same exclusivity on
selection, since the DOM's own AudioTrackList — unlike VideoTrackList —
permits more than one track enabled at once. A menu reads the active entry's
id to mark the current selection rather than a field of its own.
Which providers publish audio tracks
| Provider | selectAudioTrack |
Where the tracks come from |
|---|---|---|
| hls.js | available with alternate audio |
hls.js's own audio-tracks controller, from the manifest |
| native | available where the browser exposes AudioTrackList, unavailable (browser) otherwise |
HTMLMediaElement.audioTracks (Firefox and Safari; Chrome exposes none) |
| vimeo | unavailable, reason provider |
not exposed by the SDK |
| youtube | unavailable, reason provider |
not exposed by the iframe API |
| wistia | unavailable, reason provider |
not exposed by the SDK |
The HLS provider answers from hls.js's own audio tracks while its hls.js
engine is running, and falls back to the media element's AudioTrackList —
the same surface the native provider reads — when it falls through to a
native HLS engine instead. See the Capabilities matrix guide for the
full account.
Selecting an audio track
Two ways, both driving the same command: controller.selectAudioTrack(id)
directly, or Player.AudioTrackMenu, which wires the whole list up for you.
Player.AudioTrackMenu
A preset assembly over Player.SettingsMenu / Player.MenuRadioGroup /
Player.MenuRadioItem, in the same shape Player.QualityMenu and
Player.PlaybackRateMenu take over the same primitives: it renders nothing
until capabilities.selectAudioTrack resolves available, lists
audioTracks, marks the active entry, and issues selectAudioTrack when a
row is chosen.
No Auto row. Unlike QualityMenu, an audio track carries no
auto-selection concept — every row names a real track, so there is nothing
for an Auto row to stand in for.
It renders no data-playdeck-part of its own — every attribute a reader can
style or query comes from the primitives it composes
(settings-menu-trigger, settings-menu, menu-radio-group,
menu-radio-item), the same Contract the other menu parts publish
through.
Pass children to fully customize the trigger/content; omit them for the default track list.
Accessibility
The trigger carries aria-label="Audio track", overridable the same way
any other primitive's default label is — pass your own aria-label (or
replace the trigger's children entirely). Each row is role="menuitemradio"
with aria-checked reflecting the track it was built from. Keyboard
operation — Tab to the trigger, Enter or Space to open it, arrow keys to
move roving focus among the rows, Enter or Space to choose one, Escape to
close — comes from SettingsMenu, the same primitive every other menu in
this package composes, rather than anything AudioTrackMenu implements
itself.
Out of scope
A standalone audio-track button, outside a menu, does not exist.
selectAudioTrack and audioTracks are exposed only through
Player.AudioTrackMenu and the menu primitives it is built from.