How to use the property audioTracks that returns the AudioTrackList object in html5
Editor to share with you how to use the property audioTracks that returns the AudioTrackList object in html5. I hope you will get something after reading this article. Let's discuss it together.
Example
Get the number of available tracks:
MyVid=document.getElementById ("video1"); alert (myVid.audioTracks.length)
Definition and usage
The audioTracks property returns the AudioTrackList object.
The AudioTrackList object represents the available tracks for audio and video.
Each available track is represented by an AudioTrack object.
Browser support
The audioTracks attribute is not supported by any major browser.
Grammar
Audio | video.audioTracks type description AudioTrackList object
Represents the available tracks for audio and video.
AudioTrackList object:
AudioTracks.length-or the number of available tracks
AudioTracks.getTrackById (id)-get the AudioTrack object through id
AudioTracks [index]-get the AudioTrack object through index
Note: the subscript of the first available AudioTrack object is 0.
AudioTrack object
Represents the track.
Properties of the AudioTrack object:
Id-get the id of the track
Kind-gets the type of track (can be "alternative", "description", "main", "translation", "commentary", or "" (empty string))
Label-get the label of the track
Language-the language of access to audio tracks
Enabled-gets or sets whether the track is active (true | false)
Example
Get the number of available audio tracks: