Switch audio tracks
Learn how to discover and switch between audio tracks in the FastPix Android Player.
FastPixPlayer can discover and switch audio tracks, commonly available on HLS streams with multiple audio renditions.
AudioTrack properties
Each AudioTrack includes the following properties (useful for building a UI):
id: pass this tosetAudioTrack(id)to switch tracks.languageCode/languageName/label: display in your language menu.isSelected,isPlayable,isDefault: for UI state.- Optional diagnostics:
role,channels,codec,bitrate,groupId.
Listen for audio track updates
Switch audio track by ID
Note: If a seek is in progress, the SDK defers switching until the seek completes.
Set a default audio language
Set a preferred audio language that applies automatically when tracks become available. This never overrides a manual selection:
Use BCP-47 / ISO language names like "English", "Hindi", "French". If the preferred language doesn’t exist in the stream, the player keeps its normal selection.
Build a language menu
Remove the audio track listener
Keep a reference to your AudioTrackListener and remove it when it is no longer needed:
Frequently asked questions
How do I change the audio language on the FastPix Android player?
Call player.setAudioTrack(id) with an id from getAudioTracks() to switch immediately, or call player.setDefaultAudioTrack(languageName = "Hindi") so a preferred language is applied automatically when tracks load. Switching does not restart playback: position and state are preserved.
How do I switch the audio track in an HLS stream?
Audio track switching works on media that provides multiple audio renditions, which HLS streams commonly do. Read the tracks with player.getAudioTracks(), then call player.setAudioTrack(track.id). If a seek is in progress, the SDK defers the switch until the seek completes.
How do I set a default audio language?
Call player.setDefaultAudioTrack(languageName = "English") with a BCP-47 / ISO language name. The preference is applied automatically when tracks become available, such as after loading new media, and it never overrides a manual selection. If the language is not in the stream, the player keeps its normal selection.
What information does the AudioTrack model provide?
Each AudioTrack exposes id (pass it to setAudioTrack), plus languageCode, languageName, and label for your menu, and isSelected, isPlayable, and isDefault for UI state. Optional diagnostics include role, channels, codec, bitrate, and groupId.
What’s next
- Switch subtitle tracks to let viewers turn captions on, off, or into another language.
- Switch video quality so users can lock a fixed resolution or return to adaptive auto mode.
- Listen to playback events to keep your track menus and player UI in sync.