AudioTrack object

Represents an audio track on a video element.

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

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.

PropertyAccess typeDescription

enabled

Read/write

Gets or sets whether an AudioTrack is enabled.

label

Read/write

Gets or sets the label attribute to create a user readable title for a text track.

language

Read-only

Gets the BCP47 language tag of an AudioTrack or TextTrack if available, or an empty string if not.

sourceBuffer

Read-only

Gets the source buffer associated with the audio track.

 

Standards information

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.

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 Windows Internet Explorer to use the latest standards. For more information about document compatibility, see Defining Document Compatibility.

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

AudioTrackList
audioTracks
DOMContentLoaded
onloadeddata
video

 

 

Show:
© 2014 Microsoft