Audio textTracksProperty

Audio 对象参考手册Audio Object

Example

Get the number of available text tracks:

var x = document.getElementById("myAudio").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.

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

audioObject.textTracks

Return Value

Type Description
TextTrackList object

Represents the available text tracks of the audio.

Properties of the TextTrackList object:

  • length - Gets the number of available text tracks in the audio
  • [index] - Gets the TextTrack object by index

Note: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 as a TextTrackCueList object
  • addCue(cue) - Adds a cue to the cues list
  • removeCue(cue) - Removes a cue from the cues list


Audio 对象参考手册Audio Object Other Extensions