Skip to main content
Version: 11.7.0

How to programmatically enable or disable audio tracks on Web

This article describes how you can use the AudioTrack API, a sub-API of the MediaTrack API, to enable or disable audio tracks. Implementing this functionality is a common use-case for developers who want to build their own UI to toggle audio languages on and off.

Once you have programmatically selected a track, you can set its enabled property (or method) to true or false. Because only one audio track can play at a time, enabling an audio track automatically disables all other audio tracks. Note that this does not apply to text tracks: multiple text tracks can be active at the same time.

Usage

The Web SDK exposes the audio tracks through player.audioTracks, which contains MediaTrack objects with an enabled property.

// enable a specific audio track
player.audioTracks[indexOfRequestedAudioTrack].enabled = true;