# 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.

```brightscript
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
```

## Related articles

* [How to programmatically enable or disable audio tracks](https://docs-preview.optiview.dolby.com/pr-861/theoplayer/how-to-guides/roku/media-tracks/enable-disable-audio-tracks.md)
