Skip to main content
Version: 11.7.0

How to insert subtitles on Android

This article describes how you can side-load subtitles or closed captions, i.e. how you can add text tracks which are not part of your HLS or MPEG-DASH manifest.

Every source description has a text tracks property, which accepts an array of side-loaded text tracks. All valid tracks are available for playback as long as the player's source is not set again.

Text track descriptions can also be used for other purposes, e.g. for including preview thumbnails and chapters.

Usage

Each text track is described by a TextTrackDescription.

val sourceWithSubs = SourceDescription.Builder("//path/to/your-manifest.m3u8")
.textTracks(
TextTrackDescription.Builder("path/to/your-subs-track1.vtt")
.isDefault(true)
.kind(TextTrackKind.SUBTITLES)
.srclang("en")
.label("English subs")
.build()
)
.build()