AudioTrackList object
Represents a list of AudioTrack objects. A video element can have one or more associated audio tracks and the audioTracks property returns the list.
![]() ![]() |
Syntax
var audiotracks = videoElm.audioTracks;
DOM Information
Inheritance Hierarchy
The AudioTrackList does not inherit from any class or interface.Members
The AudioTrackList object has these types of members:
Events
The AudioTrackList object has these events.
| Event | Description |
|---|---|
| addtrack |
Occurs when a track is added to the track list on a video object. |
| onchange |
Occurs when an AudioTrack or VideoTrack in the AudioTrackList or VideoTrackList associated with a video is enabled or disabled. |
| onremovetrack |
Fires when an AudioTrack or VideoTrack is removed from the AudioTrackList or VideoTrackList. |
Methods
The AudioTrackList object has these methods.
| Method | Description |
|---|---|
| addEventListener |
Registers an event handler for the specified event type. |
| dispatchEvent |
Sends an event to the current element. |
| getTrackById |
Returns the first track with the specified id in a track list. |
| item |
Returns a track from a list that corresponds with the given index based on track order. |
| removeEventListener |
Removes an event handler that the addEventListener method registered. |
Properties
The AudioTrackList object has these properties.
| Property | Access type | Description |
|---|---|---|
|
Read-only |
Returns the number of tracks in TextTrackList, VideoTrackList, TextTrackCueList, or AudioTrackList objects. |
Standards information
Remarks
The following example gets an AudioTrackList associated with a video object and displays the language and enabled status of each AudioTrack .
Examples
<!DOCTYPE html > <html > <head> <title>Multiple AudioTracks example</title> </head> <body> <h1>Multiple AudioTracks example</h1> <video id="video1" controls > <source src="multi-lang-movie.mp4" > </video> <br /> <div id="display"></div> <script> // elements we'll need var display = document.getElementById("display"); var video = document.getElementById("video1"); // When audio is loaded, display language and enabled status at startup video.addEventListener("loadeddata", function () { var oAudioTracks = video.audioTracks; for (var i = 0; i < oAudioTracks.length; i++) { // Step through audio track list var audioTrack = oAudioTracks[i]; // Get tracks display.innerHTML += "<br/>" + "Track " + i; display.innerHTML += " Language: " + audioTrack.language; display.innerHTML += " is " + ((audioTrack.enabled) ? "enabled" : "not enabled"); } },false); </script> </body> </html>

