Skip to main content
Version: 11.8.0

How to programmatically detect audio tracks on Roku

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

The snippet below allows you to detect added audio tracks. In this example, we have used the addedaudiotrack event to propagate information about audio tracks. Basically, all you have to do is add an event listener.

sub Init()
...
m.THEOplayer.callFunc("addEventListener", "addedaudiotrack", m.top, "onAudioTracksChanged")
...
end sub

sub onAudioTracksChanged()
audioTracks = m.player.audioTracks
print "Audio tracks changed. "; audioTracks
end sub