Fix external subtitle selection

A recent (?) AndroidX Media3 update caused MergingMediaPeriod to prepend the period ID to the track format's id, breaking the actual track selection. Only matching the substring fixes selecting external subtitles.
This commit is contained in:
Maxr1998 authored and Niels van Velzen committed 2026-06-20 17:01:53 +02:00
1 parent e637337eff
commit 6be3652bdc
1 file changed
+5 -1
@@ -153,7 +153,11 @@ class TrackSelectionHelper(
SubtitleDeliveryMethod.EXTERNAL -> {
// For external subtitles, we can simply match the ID that we set when creating the player media source.
for (group in player.currentTracks.groups) {
if (group.getTrackFormat(0).id == "${ExternalSubtitleStream.ID_PREFIX}${subtitleStream.index}") {
val formatId = group.getTrackFormat(0).id ?: continue
val originalFormatPrefixIndex = formatId.indexOf(ExternalSubtitleStream.ID_PREFIX)
if (originalFormatPrefixIndex < 0) continue
val originalFormatId = formatId.substring(originalFormatPrefixIndex)
if (originalFormatId == "${ExternalSubtitleStream.ID_PREFIX}${subtitleStream.index}") {
return trackSelector.selectTrackByTypeAndGroup(C.TRACK_TYPE_TEXT, group.mediaTrackGroup)
}
}