Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4

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.

EventDescription
addtrack

Occurs when a track is added to the track list on a video object.

onchange

Occurs when an AudioTrack in the AudioTrackList associated with a video is enabled or disabled.

onremovetrack

Fires when an AudioTrack is removed from the AudioTrackList.

 

Methods

The AudioTrackList object has these methods.

MethodDescription
addEventListener

Registers an event handler for the specified event type.

addEventListener

Registers an event handler for the specified event type.

addEventListener

Registers an event handler for the specified event type.

dispatchEvent

Sends an event to the current element.

dispatchEvent

Sends an event to the current element.

dispatchEvent

Sends an event to the current element.

getTrackById

Returns the first AudioTrack with the specified id in an AudioTrackList.

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.

removeEventListener

Removes an event handler that the addEventListener method registered.

removeEventListener

Removes an event handler that the addEventListener method registered.

 

Properties

The AudioTrackList object has these properties.

PropertyAccess typeDescription

length

Read-only

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

 

Standards information

Remarks

The following example gets an AudioTrackList associated with a video object and displays the language and enabled status of each AudioTrack .

Note  If you are developing locally or on an intranet and have rendering issues for HTML5, you can add a "meta http-equiv-'X-UA-Compatible' content= " meta command, followed by "IE=edge" to the <head> block of a webpage to force a Windows Store app using JavaScript to use the latest standards. For more information about document compatibility, see Defining Document Compatibility. See the sample online.

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>


 

 

Show:
© 2014 Microsoft