Javascript examples for DOM HTML Element:Audio
The audioTracks property returns a AudioTrackList object, which represents the available audio tracks for the audio.
Each available audio track is represented by an AudioTrack Object.
Type | Description |
---|---|
AudioTrackList Object | Represents the available audio tracks for the audio. |
AudioTrack Object | Represents an audio track. |
The AudioTrackList Object has the following method and properties:
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> <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 . j ava 2s . co m <button onclick="myFunction()">get the number of available audio tracks</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").audioTracks.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>