Audio textTracks attribute

Definition and usage

textTracks The 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.

Example

Get the number of available text tracks:

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

Try it yourself

Syntax

audioObject.textTracks

Return value

Type Description
TextTrackList object

Represents the available text tracks of the audio.

Properties of the TextTrackList object:

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

Note:The first available TextTrack object is at index 0.

TextTrack object

Represents the text track.

Properties and methods of the TextTrack object:

  • kind - Get the type of the text track
  • label - Get the label of the text track
  • language - Get the language of the text track
  • mode - Get or set whether the track is in an active state ("disabled"|"hidden"|"showing")
  • cues - Get the cue list as a TextTrackCueList object
  • activeCues - Get the current active text track cues as a TextTrackCueList object
  • addCue(cue) - Add hint to hint list
  • removeCue(cue) - Remove hint from hint list

Possible values for the 'kind' attribute:

  • subtitles
  • caption
  • descriptions
  • chapters
  • metadata

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support