Latest web development tutorials

HTML DOM Video addTextTrack () method

Video Object Reference Video Object

Examples

Adding a new text to the video track:

var x = document.getElementById ( "myVideo");
var y = x.addTextTrack ( "caption");
y.addCue (new TextTrackCue ( "Test text", 01.000, 04.000, "", "", "", true));

try it"

Definition and Usage

addTextTrack () method creates and returns the new text track.

TextTrack new object is added to the video / audio elements of the text track list.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers do not support addTextTrack () method.


grammar

videoObject .addTextTrack (kind, label, language )

Parameter Value

value description
kind

It specifies the type of text track.

Possible values:

  • "Subtitles"
  • "Caption"
  • "Descriptions"
  • "Chapters"
  • "Metadata"
label String value for the specified label text track. For a user to identify the text track.
language

Two-letter language code, the language provisions of the text track.

To view all available language codes, see our language codes reference manual .

technical details

return value: TextTrack object that represents the new text track.


Video Object Reference Video Object