API
Audio Tracks
An overview of using and configuring audio tracks.
Audio tracks are currently supported by the HLS Provider and Dash Provider. They can not be added programatically.
Tracks List
Section titled Tracks ListThe read-only audioTracks
property on the player returns an AudioTrackList
object that
contains AudioTrack
objects
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.
The AudioTrack
interface contains the following shape:
Selecting
Section titled SelectingThe selected
property can be used to set the current audio track like so:
Once set, the underlying provider will update the audio track.
List Events
Section titled List EventsThe 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 State
Section titled Media StateThe 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 Control
Section titled Remote ControlThe 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 Events
Section titled Media EventsThe following audio track related events are available on the player: