English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The AudioTrack interface represents a single track from an HTML media element, <audio> or <video>. The most common use of the AudioTrack object is to switch its enabled attribute to mute and unmute the track.
HTML Audio/Video DOM Reference Manual
Get the number of available audio tracks:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Video audioTracks attribute usage-Basic tutorial(oldtoolbag.com)</<title> </<head> <body> <button onclick="getAudioTracks()" type="button">Get the number of available audio tracks: </button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video1"); function getAudioTracks() { alert(myVid.audioTracks.length); } </script> </body> </html>Test to see ‹/›
The audioTracks property returns an AudioTrackList object.
The AudioTrackList object represents audio/The available audio tracks of the video.
Each available track is represented by an AudioTrack object.
IEFirefoxOperaChromeSafari
All mainstream browsers do not support the audioTracks property.
audio|video.audioTracks
Type | Description |
---|---|
AudioTrackList object | Represents audio/The available audio tracks of the video. AudioTrackList object:
Note:The first available AudioTrack object'sIndexis 0. |
AudioTrack object | Represents the audio track. Properties of AudioTrack object:
|