Adjust audio index when downloading subtitles (#129)

If the user has picked a specific audio track, then downloads a new
external subtitle, the audio track index must be adjusted (add 1) to
account for the shift in track indices.

This is because external subtitles are always indexed first.
This commit is contained in:
damontecres 2025-10-31 22:20:00 -04:00 committed by GitHub
parent 9f3691fd1b
commit efde6deb58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -494,6 +494,7 @@ class PlaybackViewModel
.build()
}
}
Timber.v("externalSubtitleCount=$externalSubtitleCount, externalSubtitle=$externalSubtitle")
val mediaItem =
MediaItem
@ -964,7 +965,21 @@ class PlaybackViewModel
removeAll(currentSubtitleStreams)
}.firstOrNull { it.external }
if (newStream != null) {
changeSubtitleStream(newStream.index).join()
var audioIndex = currentItemPlayback.value?.audioIndex
if (audioIndex != null && audioIndex != TrackIndex.UNSPECIFIED) {
// User has picked a specific audio track
// Since, now adding a new external subtitle track, need to adjust the audio index as well
Timber.v("New external subtitle, audioIndex=$audioIndex, adding 1")
audioIndex += 1
}
changeStreams(
dto,
currentItemPlayback.value!!,
audioIndex,
newStream.index,
onMain { player.currentPosition },
true,
)
}
}
subtitleSearch.setValueOnMain(null)