An overview of using and configuring audio tracks.
Audio tracks are currently only supported by the HLS Provider and must be included the HLS playlist. They can not be added programatically.
Tracks ListSection titled Tracks List
audioTracks property on the player returns an
AudioTrackList object that
Similar to text tracks, the returned list is live; that is, as tracks are added to and removed from the player, the list’s contents change dynamically. Once you have a reference to the list, you can monitor it for changes to detect when new tracks are added or existing ones are removed by listening to list events.
AudioTrack interface contains the following shape:
SelectingSection titled Selecting
selected property can be used to set the current audio track like so:
Once set, the underlying provider will update the audio track.
List EventsSection titled List Events
AudioTrackList object is an
EventTarget which dispatches the following events:
add: Fired when an audio track has been added to the list.
remove: Fired when an audio track has been removed from the list.
change: Fired when the selected audio track changes.
Media StateSection titled Media State
The following audio track related properties are available on the media store:
audioTracks: An array containing the current list of AudioTrack objects.
audioTrack: The current AudioTrack object or null if none is available.
If you’re using React check out the
useAudioOptions hook for building menus.
Remote ControlSection titled Remote Control
changeAudioTrack method on the media remote can be used to dispatch
media-audio-track-change-request request events to update the current audio track like so:
Media EventsSection titled Media Events
The following audio track related events are available on the player: