Audio Tracks Events

These API calls are used to listen to or update the audio track if multiple audio tracks of a video are provided.



.on('audioTracks')

Fires when the list of available audio tracks is updated

This occurs shortly after a playlist item starts playing.

{
    "tracks": [
        {
            "autoselect": true,
            "defaulttrack": true,
            "groupid": "aac",
            "language": "en",
            "name": "English",
            "hlsjsIndex": 0
        },
        {
            "autoselect": true,
            "defaulttrack": false,
            "groupid": "aac",
            "language": "sp",
            "name": "Spanish",
            "hlsjsIndex": 1
        },
        {
            "autoselect": false,
            "defaulttrack": false,
            "groupid": "aac",
            "language": "en",
            "name": "Commentary (eng)",
            "hlsjsIndex": 2
        }
    ],
    "currentTrack": 0,
    "type": "audioTracks"
}

Property Description
currentTrack number Index of the currently active audio track
tracks array Track information based on the M3U8 manifest

See: tracks[]
type string Category of player event

This value is always audioTracks.

tracks[]

Property Description
autoselect boolean No explicit preference is chosen, can be chosen based on system language
defaulttrack boolean Identifies if the track should be chosen by default
groupid string Audio group identifier in HLS used to organize and manage different audio renditions of the same content
hlsjsIndex number Zero-index internal identifier used by hls.js to track the audio tracks
language string Two-letter language code for the audio track
name string Label given to the audio track


.on('audioTrackChanged')

Fires when the active audio track is changed.

This occurs in response to a track change caused by a user selecting a track or a script calling setCurrentAudioTrack().

{
    "tracks": [
        {
            "autoselect": true,
            "defaulttrack": true,
            "groupid": "aac",
            "language": "en",
            "name": "English",
            "hlsjsIndex": 0
        },
        {
            "autoselect": true,
            "defaulttrack": false,
            "groupid": "aac",
            "language": "sp",
            "name": "Spanish",
            "hlsjsIndex": 1
        },
        {
            "autoselect": false,
            "defaulttrack": false,
            "groupid": "aac",
            "language": "en",
            "name": "Commentary (eng)",
            "hlsjsIndex": 2
        }
    ],
    "currentTrack": 1,
    "type": "audioTrackChanged"
}

Property Description
currentTrack number Index of the currently active audio track
tracks array Track information based on the M3U8 manifest

See: tracks[]
type string Category of player event

This value is always audioTrackChanged

tracks[]

Property Description
autoselect boolean No explicit preference is chosen, can be chosen based on system language
defaulttrack boolean Identifies if the track should be chosen by default
groupid string Audio group identifier in HLS used to organize and manage different audio renditions of the same content
hlsjsIndex number Zero-index internal identifier used by hls.js to track the audio tracks
language string Two-letter language code for the audio track
name string Label given to the audio track