Javascript examples for DOM HTML Element:Video
The addTextTrack() method creates and returns a new TextTrack object which is used in the list of text tracks for the video element.
Value | Description |
---|---|
kind | kind of text track. Possible values: "subtitles" "caption" "descriptions" "chapters" ?"metadata" |
label | A string label for the text track to identify the text track |
language | A two-letter language code that specifies the language of the text track. |
A TextTrack Object, representing the new text track
The following code shows how to Add a new text track to the video:
<!DOCTYPE html> <html> <body> <video id="myVideo" width="320" height="240" controls> <source src="your.mp4" type="video/mp4"> <source src="your.ogg" type="video/ogg"> Your browser does not support the video tag. </video>/*from w w w . j a v a2s .c o m*/ <button onclick="myFunction()">Test</button> <script> var x = document.getElementById("myVideo"); function myFunction() { var y = x.addTextTrack("caption"); y.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","", true)); } </script> </body> </html>