For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
StatusSupportDiscussionsLog inSign Up
Docs HomeAPI ReferenceVideo on DemandAI FeaturesLive StreamingVideo PlayerVideo DataCloud PlayoutRecipes
Docs HomeAPI ReferenceVideo on DemandAI FeaturesLive StreamingVideo PlayerVideo DataCloud PlayoutRecipes
  • Player SDKs
    • Introduction
  • Web player
    • Install the FastPix web player
    • Play uploaded videos
    • Handle playback errors
  • Android player
    • Install FastPix Android player
    • Set up the player
    • Play uploaded videos
    • Handle playback errors
      • Enable secure video playback
      • Use custom domain
      • Switch audio tracks
      • Switch subtitle tracks
      • Add seek preview thumbnails
      • Enable fullscreen mode
      • Monitor video data
  • iOS player
    • Install FastPix iOS player
    • Play uploaded videos
    • Handle playback errors
  • Flutter player
    • Install FastPix Flutter player
    • Play uploaded videos
    • Handle playback errors
LogoLogo
StatusSupportDiscussionsLog inSign Up
On this page
  • SubtitleTrack properties
  • Listen for subtitle track updates
  • Switch subtitle track by ID
  • Disable subtitles
  • Set a default subtitle language
Android playerAdvanced features

Switch subtitle tracks

Was this page helpful?
Previous

Add seek preview thumbnails

Next
Built with

Learn how to discover, switch, and disable subtitle tracks in the FastPix Android Player.

SubtitleTrack properties

Each SubtitleTrack includes:

  • id — pass to setSubtitleTrack(id) to switch tracks.
  • languageCode / languageName / label — display in your subtitle menu.
  • isSelected, isPlayable, isDefault, isForced — for UI state.
  • Optional: role, codec, groupId.

Listen for subtitle track updates

1import io.fastpix.media3.tracks.SubtitleTrackListener
2
3player.addSubtitleTrackListener(object : SubtitleTrackListener {
4 override fun onSubtitlesLoaded(tracks: List<SubtitleTrack>) {
5 // Populate subtitle selection UI
6 }
7 override fun onSubtitleChange(track: SubtitleTrack?) {
8 // track == null means subtitles are disabled
9 }
10 override fun onSubtitlesLoadedFailed(error: SubtitleTrackError) {
11 // Track not found, not playable, player not ready, etc.
12 }
13 override fun onSubtitleCueChange(info: SubtitleRenderInfo) {
14 // Optional: observe cues (text + timing) if building a custom subtitle renderer
15 }
16})

Switch subtitle track by ID

1val subs = player.getSubtitleTracks()
2val target = subs.firstOrNull()
3if (target != null) {
4 player.setSubtitleTrack(target.id)
5}

Disable subtitles

1player.disableSubtitles()

Set a default subtitle language

Set a preferred subtitle language that applies automatically when tracks become available. This never overrides a manual selection:

1player.setDefaultSubtitleTrack(languageName = "Spanish")

Use BCP-47 / ISO language names like "English", "Spanish", "Hindi". If the preferred language doesn’t exist in the stream, the player keeps its normal selection.