HTML 5 Audio/Video DOM addTextTrack() method

Instance

Add a new text track to the video:

text1=myVid.addTextTrack("caption");
text1.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true));

Try It Yourself

Definition and Usage

The addTextTrack() method creates and returns a new text track.

A new TextTrack object will be added to the list of text tracks of the video/audio element.

Browser Support

All major browsers do not support the addTextTrack() method.

Syntax

audio|video.addTextTrack(kind,label,language)

Parameters

Values Description
kind

Specifies the type of the text track.

Possible Values:

  • "subtitles"
  • "caption"
  • "descriptions"
  • "chapters"
  • "metadata"
label A string value that specifies the label for the text track. It is used to identify the text track for the user.
language

two-letter language codes, which specify the language of the text track.

To view all available language codes, please refer to ourLanguage Code Reference Manual.

Return Value

Type Description
TextTrack Object Represents a new text track.