HTML Audio/Video DOMtextTracksProperty

HTML audio/video 标签参考手册HTML Audio/Video DOM Reference

Examples

Get the number of available text tracks:

myVid=document.getElementById("video1");
alert(myVid.textTracks.length);

Try it Yourself »

Definition and Usage

The textTracks property returns a TextTrackList object.

The TextTrackList object represents the available text tracks of the audio/video.

Each available text track is represented by a TextTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Opera, Chrome, and Safari 6 support the textTracks property.

Note:Internet Explorer 9 and earlier versions do not support the textTracks property.


Syntax

audio|video.textTracks

Return Value

Type Description
TextTrackList object Represents the available text tracks of the audio/video.

TextTrackList object:

  • length - Get the number of available text tracks in the audio/video
  • [index] - Get the TextTrack object according to the index

Note:The index of the first available text trackindexis 0.

TextTrack object Represents a text track.

Properties of the TextTrack object:

  • kind - Get the type of the text track (can be "subtitles", "caption", "descriptions", "chapters", or "metadata")
  • label - Get the label of the text track
  • language - Get the language of the text track
  • mode - Get or set whether the track is active ("disabled"|"hidden"|"showing")
  • cues - Get the cues list of the TextTrackCueList object
  • activeCues - Get the current active text track cues in the form of a TextTrackCueList object
  • addCue(cueaddCue() - Add a cue to the cues list
  • removeCue(cueremoveCue() - Remove a cue from the cues list


HTML audio/video 标签参考手册HTML Audio/Video DOM Reference Other Extensions