Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML Audio/Video DOM addTextTrack() Method

HTML Audio/Video DOM addTextTrack() Method

HTML audio/video Tag Reference HTML Audio/Video DOM Reference

Example

Add a new text track to a video:

text1=myVid.addTextTrack("caption");

text1.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true));

Try it »


Definition and Usage

The addTextTrack() method creates and returns a new TextTrack object.

The new TextTrack object is added to the list of text tracks of the video/audio element.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

No major browsers support the addTextTrack() method.


Syntax

audio|video

.addTextTrack(

kind

,

label

,

language

)

Parameters

Value Description
kind Specifies the type of the text track.

Possible values:

  • "subtitles"
  • "caption"
  • "descriptions"
  • "chapters"
  •  "metadata"
  • | | *label* | A string specifying a label for the text track. Used to identify the text track for the user. | | *language* | A two-letter language code specifying the language of the text track. For all available language codes, please refer to our [Language Code Reference](ref-language-codes.html). |

    Return Value

    Type Description
    TextTrack object Represents the new text track.

    HTML audio/video Tag Reference HTML Audio/Video DOM Reference