Skip to main content
Version: 11.7.0

How to programmatically enable or disable text tracks on Android

This article describes how you can use the TextTrack API to enable or disable subtitles, closed captions or metadata. Implementing this functionality is a common use-case for developers who want to build their own UI to toggle subtitles.

It is advised to disable the text tracks which you do not want to display, in order to avoid issues with overlapping text.

Usage

Set the mode of a TextTrack.

// disable all text tracks
for (textTrack in player.textTracks) {
textTrack.mode = TextTrackMode.DISABLED
}
// enable a specific text track
player.textTracks.getItem(indexOfRequestedTextTrack).mode = TextTrackMode.SHOWING