English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML Audio/How to use the video DOM addTextTrack() method, online instance demonstration of using HTML audio/Detailed information about the video DOM addTextTrack() method, browser compatibility, syntax definition, and its attribute values, etc.
HTML Audio/Video DOM Reference Manual
Add a new text track to the video:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Video addTextTrack() method usage-Basic Tutorial(oldtoolbag.com)</<title> </<head> <body> <button onclick="addNewTextTrack()" type="button">Add a new text track: </button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video1); function addNewTextTrack() { text1=myVid.addTextTrack("caption"); text1.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true)); } </script> </body> </html>Test to see ‹/›
The addTextTrack() method creates and returns a new TextTrack object.
A new TextTrack object will be added to the audio/in the list of text tracks of the video element.
IEFirefoxOperaChromeSafari
All mainstream browsers do not support the addTextTrack() method.
audio|video.addTextTrack(kind,label,language)
Values | Description |
---|---|
kind | Specifies the type of the text track. Possible Values:
|
label | A string value, specifies the label for the text track. Used to identify the text track for the user. |
language | two-letter language codes specify the language of the text track. For a list of all available language codes, please refer to our Language Code Reference Manual. |
Type | Description |
---|---|
TextTrack Object | Represents a new text track. |