This topic has not yet been rated - Rate this topic

length property

Returns the number of tracks in a TextTrackList, TextTrackCueList, or AudioTrackList list object.

This property is read-only.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.8.10.12Internet Explorer 10

Syntax

JavaScript
numTracks = object.length

Property values

Type: Integer

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.

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.



  <script type="text/javascript">                
    function getLanguages() {
      oAudioTracks = document.getElementById("video1").audioTracks;
      document.getElementById("display").innerHTML = "";
      for (var i = 0; i < oAudioTracks.length; i++) {
        document.getElementById("display").innerHTML += "Track " + i + " Language: " + oAudioTracks[i].language + " is   " + ((oAudioTracks[i].enabled == true) ? "enabled" : "not enabled")+"<br/>";
      }
    }      
  </script>
  </head>
  <body>
    <video id="video1" src="multi-lang-movie.mp4" controls >HTML5 video not supported </video>
    <br />
    <button onclick="getLanguages();">Get language status</button>
    <div id="display"></div>
  </body>
</html>


See also

TextTrackList
TextTrackCueList
AudioTrackList

 

 

Send comments about this topic to Microsoft

Build date: 11/27/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.