I’m playing an HLS stream on tvOS/iOS using AVPlayer.
The master playlist has two independent AUDIO groups: one for AAC (stereo) and one for AC-3 (5.1). Example:
# AUDIO groups
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-aacl-212",LANGUAGE="dut",NAME="Dutch; Flemish",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-aacl-212",LANGUAGE="gos",NAME="audio_214401_gos",AUTOSELECT=YES,CHANNELS="2",URI="37194-audio_214401_gos=212400.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-ac-3-706",LANGUAGE="dut",NAME="Dutch; Flemish",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6"
# VARIANTS
#EXT-X-STREAM-INF:BANDWIDTH=906000,CODECS="mp4a.40.2,avc1.4D401E",AUDIO="audio-aacl-212",SUBTITLES="textstream"
37194-audio_214400_dut=212400-video=556400.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1481000,CODECS="ac-3,avc1.4D401E",AUDIO="audio-ac-3-706",SUBTITLES="textstream"
37194-audio_708002_dut=706000-video=556400.m3u8
What I observe in AVFoundation:
After
readyToPlay,asset.availableMediaCharacteristicsWithMediaSelectionOptionsshows a single audible group.asset.mediaSelectionGroup(forMediaCharacteristic: .audible)gives me options for languages within the AAC group (e.g.,dut,gos), and I can switch between those withselect(_:in:).However, I don’t see the AC-3 group in that API at all.
Question
With a master like the above (separate AUDIO groups for AAC and AC-3), how can I enable/force the Dolby Digital (AC-3) audio in AVPlayer on tvOS/iOS?
Is there a supported way to switch the active AUDIO group at runtime (from
audio-aacl-212toaudio-ac-3-706) using AVFoundation APIs, ormust playback be started (or restarted) specifically on a variant that references
AUDIO="audio-ac-3-706"in order to get AC-3?
I’m not able to change the HLS manifest on the server. I only need the correct AVFoundation approach to make the AC-3 group active with this kind of master playlist.
Environment
tvOS 26
AVFoundation (AVPlayer / AVPlayerItem)