Skip to main content
Version: 11.7.0

How to programmatically detect text tracks on Web

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

Listen for the addtrack event on player.textTracks to detect every TextTrack that is added to the player.

function handleAddTrackEvent(addTrackEvent) {
const textTrack = addTrackEvent.track;
}
player.textTracks.addEventListener('addtrack', handleAddTrackEvent);