# How to programmatically detect text tracks on Roku

This article describes how you can use the TextTrack API to detect text tracks, which can be subtitles, closed captions or metadata. Implementing this functionality is a common use-case for developers who want to build their own UI to visualize the available subtitle languages.

## Usage

You can use the `addedtexttrack` event to programmatically detect all text tracks which are loaded with the stream.

```brightscript
sub Init()
  ...
  m.THEOplayer.callFunc("addEventListener", "addedtexttrack", m.top, "onEventTextTracksChanged")
  ...
end sub

sub onEventTextTracksChanged()
  textTracks = m.player.textTracks
  print "Text tracks changed. "; textTracks
end sub
```

## Related articles

* [How to programmatically enable or disable text tracks](https://docs-preview.optiview.dolby.com/pr-861/theoplayer/how-to-guides/roku/text-tracks/enable-disable-text-tracks.md)
* [How to dynamically change the visible captions](https://docs-preview.optiview.dolby.com/pr-861/theoplayer/how-to-guides/roku/text-tracks/change-visible-captions.md)
