Javascript examples for DOM HTML Element:Audio
The addTextTrack() method creates and returns a new TextTrack object, which is added to the list of text tracks.
Value | Description |
---|---|
kind | Specifies the kind of text track. |
label | A string for the text track to identify the text track for the users |
language | A two-letter language code to identify the language of the text track. |
Possible values for kind:
A TextTrack Object, representing the new text track
The following code shows how to Add a new text track to the audio:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>//from w ww . ja v a 2s. co m <button onclick="myFunction()">Test</button> <script> var x = document.getElementById("myAudio"); function myFunction() { var y = x.addTextTrack("caption"); y.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true)); } </script> </body> </html>