How to programmatically detect audio tracks on Web
This article describes how you can use the AudioTrack API, a sub-API of the MediaTrack API, to detect audio tracks. Implementing this functionality is a common use-case for developers who want to build their own UI to visualize the available audio languages.
Usage
Listen for the addtrack event
on player.audioTracks
to detect every MediaTrack that is added to the player.
function handleAddTrackEvent(addTrackEvent) {
const audioTrack = addTrackEvent.track;
}
player.audioTracks.addEventListener('addtrack', handleAddTrackEvent);