Switch subtitle tracks
Learn how to discover, switch, and disable subtitle tracks in the FastPix Android Player.
SubtitleTrack properties
Each SubtitleTrack includes:
id: pass tosetSubtitleTrack(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
Switch subtitle track by ID
Disable subtitles
Set a default subtitle language
Set a preferred subtitle language that applies automatically when tracks become available. This never overrides a manual selection:
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.
Remove the subtitle track listener
Keep a reference to your SubtitleTrackListener and remove it when it is no longer needed:
Frequently asked questions
How do I turn on subtitles in the FastPix Android player?
Read the available tracks with player.getSubtitleTracks(), then enable one by id with player.setSubtitleTrack(track.id). Playback position and state are preserved when you switch, so the video does not restart.
How do I disable captions?
Call player.disableSubtitles() to turn subtitles off. Playback position and state are preserved, though forced subtitles may still render depending on the stream. In onSubtitleChange, a null track means subtitles are disabled.
How do I set a default subtitle language?
Call player.setDefaultSubtitleTrack(languageName = "Spanish") with a BCP-47 / ISO language name. It applies automatically when tracks become available and never overrides a manual selection or a “subtitles disabled” state. If the language is not present, the player keeps its normal selection.
How do I render custom subtitle cues?
Implement onSubtitleCueChange(info: SubtitleRenderInfo) in a SubtitleTrackListener. Each SubtitleCueInfo in info.cues has text, startTimeMs, and endTimeMs, which you can use to drive a custom overlay such as a TextView.
What’s next
- Switch audio tracks to let viewers choose an alternate audio language.
- Switch video quality so users can lock a fixed resolution or return to adaptive auto mode.
- Listen to playback events to keep your caption menus and player UI in sync.