Version: 2.67.0

Using MediaTrack API | How to programmatically detect audio tracks

This article describes how you can use the API to detect audio tracks.

The AudioTrack API, which is a sub-API of the MediaTrack API, can be used to implement this functionality. Implementing this functionality is a common use-case for developers who want to build their own UI to visualize the available audio languages.

Table of contents


Web SDKAndroid SDKAndroid TV SDKiOS SDKtvOS Chromecast SDK YesYesYesYesYesYes

Code examples

The code examples below how to implement the detection of audio tracks across SDK.


The Web SDK leverages the MediaTrack API.

function handleAddTrackEvent(addTrackEvent) {
var audioTrack = addTrackEvent.track;
player.audioTracks.addEventListener('addtrack', handleAddTrackEvent);

Android (TV) SDK

The Android SDK leverages the MediaTrack API.

EventListener<AddTrackEvent> handleAddTrackEvent= new EventListener<AddTrackEvent>() {
public void handleEvent(AddTrackEvent addTrackEvent) {
MediaTrack audioTrack = addTrackEvent.getTrack();
tpv.getPlayer().getAudioTracks().addEventListener(AudioTrackListEventTypes.ADDTRACK, handleAddTrackEvent);

iOS (/tvOS) SDK

The iOS SDK leverages the MediaTrack API.

func handleAddTrackEvent(addTrackEvent : AddTrackEvent) {
var audioTrack = addTrackEvent .track
self.theoplayer.audioTracks.addEventListener(type: AudioTrackListEventTypes.ADD_TRACK, listener: handleAddTrackEvent)


Related Articles


How to programmatically detect video track qualities

  • Page:

How to programmatically select a video track quality

  • Page:

How to programmatically enable or disable audio tracks