length property
Returns the number of tracks in TextTrackList, VideoTrackList, TextTrackCueList, or AudioTrackList objects.
This property is read-only.
![]() ![]() |
Syntax
| JavaScript |
|---|
numTracks = object.length |
Property values
Type: number
Number of tracks represented by the list object.
Standards information
Remarks
The maximum number of audio tracks a video can contain has not been defined in the World Wide Web Consortium (W3C) specification.
VideoTrackList support not supported in versions before Internet Explorer 11.
Examples
The following example uses the length property to get the number of audioTracks associated with a video object, and then displays the language and enabled status of each.
<!DOCTYPE html > <html > <head> <title>AudioTracks example</title> </head> <body> <h1>AudioTrack languages example</h1> <video id="video1" src="multi-lang-movie.mp4" controls >HTML5 video not supported </video> <br /> <button id="mybutton">Get language status</button> <div id="display"></div> <script> document.getElementById("mybutton").addEventListener("click", function () { var oAudioTracks = document.getElementById("video1").audioTracks; var display = document.getElementById("display"); display.innerHTML = ""; for (var i = 0; i < oAudioTracks.length; i++) { display.innerHTML += "Track " + i; display.innerHTML += " Language: " + oAudioTracks[i].language; display.innerHTML += " is " + ((oAudioTracks[i].enabled == true) ? "enabled" : "not enabled") + "<br/>"; } },false); </script> </body> </html>
See also
Show:

