Javascript examples for DOM HTML Element:Video
The audioTracks property returns a AudioTrackList object, which represents the available audio tracks for the video.
Each available audio track is represented by an AudioTrack Object.
Type | Description |
---|---|
AudioTrackList Object | Represents the available audio tracks for the video. |
AudioTrack Object | Represents an audio track. |
AudioTrackList Object:
The first available AudioTrack object is index 0
AudioTrack Object Properties:
The following code shows how to get the number of available audio tracks:
<!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 ww w.j av a 2 s . c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myVideo").audioTracks.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>