textTracks property

Returns a list of TextTrack objects from a video object.

This property is read-only.

HTML5 A vocabulary and associated APIs for HTML and XHTMLInternet Explorer 10

 

Syntax

JavaScript
textTracks = object.textTracks

 

Property values

Type: TextTrackList

List of TextTrack objects

Standards information

Remarks

The following example displays a list of text tracks associated with a video.

Note  To create timed text files in both Web Video Text Track (WebVTT) and Timed Text Markup Language (TTML) formats, see HTML5 Video Caption Maker on the Windows Internet Explorer test drive site.

Examples

The example uses two HTML5 events, "DOMContentLoaded" and "onloadeddata" to first check whether the video element has fully loaded, and then whether the video and audio content has loaded.



</head>
<body>
<video id="video1" controls>
<source src="video.mp4">
  <!-- The English text track is used by default -->
  <track id="entrack" label="English subtitles" kind="captions" src="entrack.vtt" srclang="en" default>
  <track id="sptrack" label="Spanish subtitles" kind="captions" src="estrack.vtt" srclang="es">
  <track id="detrack" label="German subtitles" kind="captions" src="detrack.vtt" srclang="es">
  HTML5 Video not supported 
</video>
<div id="display"></div>

  <script type="text/javascript">
     var allTracks = document.getElementById("video1").textTracks; // get list of tracks          
     for (var i = 0; i < allTracks.length; i++) {
       document.getElementById("display").innerHTML += (allTracks[i].label + "<br/>");  //append track label
     }
  </script>
</body>
</html>


See also

video
How to use HTML5 to play video files on your webpage
Make your videos accessible with Timed Text Tracks

 

 

Show:
© 2014 Microsoft