Advertisement
Home Open Editor ❯

HTML Audio/Video DOM addTextTrack() Method

Example

var vid = document.getElementById("demo");

function myFunction() { 
  var txt = vid.addTextTrack("caption");
  txt.addCue(new TextTrackCue("Demo text", 01.000, 05.000, "", "", "", true));
}

Try this code ❯

Meaning

The addTextTrack() method creates and returns a new TextTrack object. The new TextTrack object is added to the list of text tracks for the audio/video element.


Standard Syntax

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


Advertisement

Parameter Value

Type Description
kind Specifies the kind of text track.

Possible values:

  • "subtitles"
  • "caption"
  • "descriptions"
  • "chapters"
  • "metadata"
label Specifying the label for the text track.
language Specifies two-letter language code of the text track.
Home Open Editor ❯
Advertisement