Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the property audioTracks that returns the AudioTrackList object in html5

Shulou Source: shulou.com Published: 2022-06-03 15:05:05 11月12日 Update

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:

Tags: Objects attributes quantity browsers support browsing examples tags articles types audio and video subscript mainstream finished more comments knowledge empty characters industry grammar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Shulou Tech Info Microsoft Redmi