mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
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:
parent
9f3691fd1b
commit
efde6deb58
1 changed files with 16 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue