Looking for the old docs? Go here

API

Audio Tracks

An overview of using and configuring audio tracks.

INFO

Audio tracks are currently supported by the HLS Provider and Dash Provider. They can not be added programatically.

The 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:

    
    

The selected property can be used to set the current audio track like so:

    
    

Once set, the underlying provider will update the audio track.

The 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.
    
    

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.
    
    
INFO

If you’re using React check out the useAudioOptions hook for building menus.

The 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:

    
    

The following audio track related events are available on the player:

    
    

Previous