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
  • iOS player
    • Install FastPix iOS player
    • Play uploaded videos
    • Handle playback errors
      • Secure video playback
      • Play DRM-protected content
      • Use a custom domain
      • Switch audio tracks
      • Switch subtitle tracks
      • Add seek preview thumbnails
      • Enable Picture-in-Picture
      • Enable full-screen mode
      • Manage playlists
      • Add skip controls
      • Handle network changes
  • Flutter player
    • Install FastPix Flutter player
    • Play uploaded videos
    • Handle playback errors
LogoLogo
StatusSupportDiscussionsLog inSign Up
On this page
  • Set up the audio track delegate
  • Set a preferred audio track
  • Get available audio tracks
  • Get the current audio track
  • Switch audio tracks
  • Handle audio track events
  • AudioTrack model
iOS playerAdvanced features

Switch audio tracks

Was this page helpful?
Previous

Switch subtitle tracks

Next
Built with

Learn how to detect and switch between multiple audio tracks in the FastPix iOS Player.

The FastPix iOS Player SDK automatically detects all available audio tracks from the stream and lets users switch between them during playback. This is useful for multi-language content.

Set up the audio track delegate

Assign the delegate to receive audio track updates:

1playerViewController.audioTrackDelegate = self

Set a preferred audio track

Set a preferred audio track by language name. The SDK automatically selects it when the video loads. If the preferred track isn’t available, the manifest default is used.

1// Pass the display name of the language (case-insensitive)
2playerViewController.setPreferredAudioTrack("Hindi")

The preferred track is automatically applied on every playlist item change.

Get available audio tracks

1let audioTracks = playerViewController.getAudioTracks()

Get the current audio track

1let currentTrack = playerViewController.getCurrentAudioTrack()

Switch audio tracks

1// Switch by track ID
2playerViewController.setAudioTrack(trackId: track.id)

Handle audio track events

Conform to FastPixAudioTrackDelegate to receive track updates:

1extension VideoPlayerViewController: FastPixAudioTrackDelegate {
2
3 // Called when audio tracks are loaded or updated
4 func onAudioTracksUpdated(tracks: [AudioTrack]) {
5 print("Available audio tracks:", tracks)
6 }
7
8 // Called when the active audio track changes
9 func onAudioTrackChange(selectedTrack: AudioTrack) {
10 print("Audio switched to:", selectedTrack.label)
11 }
12
13 // Called when a track switch fails
14 func onAudioTrackFailed(error: AudioTrackError) {
15 print("Audio switch failed:", error)
16 }
17
18 // Called when a track switch starts or finishes
19 func onAudioTrackSwitching(isSwitching: Bool) {
20 if isSwitching {
21 // Show loading indicator
22 } else {
23 // Hide loading indicator
24 }
25 }
26}

AudioTrack model

PropertyTypeDescription
idStringUnique identifier for the track
languageCodeStringBCP-47 language tag (for example, "hi", "en")
languageNameStringDisplay name of the language (for example, "Hindi")
labelStringHuman-readable label shown in UI
isSelectedBoolWhether this track is currently active
isDefaultBoolWhether this is the default track