Latest web development tutorials

HTML DOM Audio addTextTrack () method

Audio Object Reference Audio Object

Examples

Adding a new text to the audio track:

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

try it"

Definition and Usage

addTextTrack () method is used to create and return a new text track.

TextTrack new object is added to the audio elements in text track list.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

At present, all major browsers do not support addTextTrack () method.


grammar

audioObject .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.


Audio Object Reference Audio Object