Video textTracksProperty

Video 对象参考手册Video Object

Examples

Get the number of available text tracks:

var x = document.getElementById("myVideo").textTracks.length;

Try it Yourself »

Definition and Usage

The textTracks property returns a TextTrackList object.

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

Each available text track is represented by a TextTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

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


Syntax

videoObject.textTracks

Return Value

Type Description
TextTrackList object

Represents the available text tracks for an audio/video.

Properties of the TextTrackList object:

  • length - Gets the number of available text tracks in the audio/video
  • [index] - Gets the TextTrack object based on the index

Notes:The index of the first available text track is 0.

TextTrack object

Represents a text track.

Properties of the TextTrack object:

  • kind - Gets the type of the text track (can be "subtitles", "caption", "descriptions", "chapters", or "metadata")
  • label - Gets the label of the text track
  • language - Gets the language of the text track
  • mode - Gets or sets whether the track is active ("disabled"|"hidden"|"showing")
  • cues - Gets the cues list of the TextTrackCueList object
  • activeCues - Gets the currently active text track cues in the form of a TextTrackCueList object
  • addCue(cue) - Adds a cue to the cues list
  • removeCue(cue) - Removes a cue from the cues list


Video 对象参考手册Video Object Other Extensions