fix: name the tracks the audio and subtitle menus offer - #142
Merged
Conversation
The menus were built only from AVFoundation's media selection groups, which left them saying two wrong things. A file whose tracks sit in no alternate group gets no media selection group at all, so both menus read "None" even though the file plainly has tracks - which is what Front Row > Play Spatial Audio Sample did, and what the Inspector's Tracks tab contradicted. Where no group exists, the menus now fall back to the asset's own tracks and switch between them by enabling the matching player item track. Media selection is still preferred wherever it exists, since it is what HTTP Live Streaming and well-tagged files describe themselves with. An untagged track was named "Unknown language", which is the `und` marker rendered as text rather than anything about the track. One rule now names every entry in both menus: the track's own title qualified by its language, else the language, else its number. An HLS rendition's NAME arrives as a title and a caption option carries no tag at all, so both keep the names they had.
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two complaints, one cause — the menus repeated whatever media selection handed back.
Why "None". AVFoundation only synthesises a media selection group for a file-based asset when the container's tracks carry a non-zero
alternate_group. The Dolby sample's are all0:01300Not a streaming problem — a local copy of the sample behaves identically, and
AVPlayerItem.tracksplainly carries its 6-channel E-AC-3 track. Any MP4 in group 0 hits this, which is why the Inspector's Tracks tab listed tracks for files whose menus said "None".Why "Unknown language".
Locale.current.localizedString(forIdentifier: "und")is"Unknown language". AVFoundation was rendering the marker a container writes for a track nobody tagged, not describing the track.Change
AVPlayerItemTrack. Media selection stays preferred wherever it exists.Track N.undcounts as untagged.Checked against measured behaviour so well-described options survive — probing a hand-built HLS stream, a rendition's
NAMEarrives as common metadata and aCCoption carries a nil tag rather thanund, so "Commentary", "CC" and "English Forced" are all kept.Verification
analyzeandswift-format lintclean.New source strings
%@ (%@)andTrack %lldare added untranslated for Crowdin.