Skip to content

Commit

Permalink
Fix audio track selection for >= 10 tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 authored and nielsvanvelzen committed May 5, 2023
1 parent 381d9f3 commit 6359d8b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class TrackSelectionHelper(
val player = viewModel.playerOrNull ?: return false
val embeddedStreamIndex = mediaSource.getEmbeddedStreamIndex(audioStream)
val sortedTrackGroups = player.currentTracks.groups.sortedBy { group ->
group.mediaTrackGroup.getFormat(0).id
val formatId = group.mediaTrackGroup.getFormat(0).id

// Sort by format ID, but pad number string with zeroes to ensure proper sorting
formatId?.toIntOrNull()?.let { id -> "%05d".format(id) } ?: formatId
}
val audioGroup = sortedTrackGroups.getOrNull(embeddedStreamIndex) ?: return false

Expand Down

0 comments on commit 6359d8b

Please sign in to comment.