Javascript examples for DOM HTML Element:Audio
The textTracks property returns a TextTrackList object, which represents the available text tracks for the audio.
Each available text track is represented by an TextTrack Object.
Type | Description |
---|---|
TextTrackList Object | Represents the available text tracks for the the audio. |
TextTrack Object | Represents a text track. |
TextioTrackList Object has the following properties:
The first available TextTrack object is index 0
TextTrack Object has the following Properties:
The following code shows how to get the number of available text tracks:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> <track src="demo_sub.vtt"> Your browser does not support the audio element. </audio>//from w w w . j a va 2 s. c o m <p>Click the button to get the number of available text tracks.</p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").textTracks.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>