AudioTrack object
Represents an audio track on a video element.
![]() ![]() |
Syntax
var oAudioTrack = oVideo.audioTracks[0];
DOM Information
Inheritance Hierarchy
The AudioTrack does not inherit from any class or interface.Members
The AudioTrack object has these types of members:
Properties
The AudioTrack object has these properties.
| Property | Access type | Description |
|---|---|---|
|
Read/write |
Gets or sets whether a track is enabled. | |
|
Read-only |
Returns the TextTrackCue, VideoTrack, or AudioTrack identifier. | |
|
Read-only |
Gets or sets the BCP47 language tag of an AudioTrack, VideoTrack or TextTrack if available, or an empty string if not. | |
|
Read-only |
Gets the source buffer associated with the audio or video track. |
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.8.10.10
Remarks
The sourceBuffer property is not available in versions before to Internet Explorer 11
Audio tracks are represented on a video element as an AudioTrackList object, which contains one or more audio tracks. The audioTracks property is used to get the AudioTrackList object, and individual audio tracks are retrieved with indexes into the object.
Examples
The following example shows how to get all the audio tracks on a video element, and display the language attribute and enabled status. The example also uses the the loadeddata event to check whether the video element itself has fully loaded. See the sample online.
<!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>
See also

