Skip to main content

Subtitles

Text tracks embedded in a stream are automatically accessible through the Player.getTrackManager method. The TrackManager provides utilities to manage subtitle tracks, such as selecting or disabling tracks.

Showing Subtitles

To display subtitles, select a specific text track using the TrackManager.setTextTrack method. For example:

const selectedTextTrack = player
.getTrackManager()
.getTextTracks()
.find(t => t.language === 'en');

if (selectedTextTrack) {
trackManager.setTextTrack(selectedTextTrack);
}

Hiding Subtitles

To hide the subtitles overlay, use the TrackManager.setTextTrack method with null as the argument. For example:

player.getTrackManager().setTextTrack(null);

Adding Side-Loaded Subtitles

If a stream lacks embedded subtitles or additional subtitles need to be added, side-loaded subtitles can be defined through the PlayerConfiguration.remoteTextTracks configuration. This allows specifying subtitles that are loaded from external URLs.

const playerConfiguration = {
source: { /* ... */ },
remoteTextTracks: [
{
language: 'en',
label: 'English',
url: 'https://example.com/en.vtt',
mimeType: 'text/vtt',
},
]
};

Supported Formats

For a full list of supported subtitle formats, refer to the Features page.