fix(mpv): apply carried audio/subtitle track after file load

Setting sid/aid before loadfile does not stick for embedded tracks, so a
carried-over subtitle was silently dropped on a freshly loaded episode.
Apply the initial audio/subtitle selection in the MPV_EVENT_FILE_LOADED
handler (after tracks are enumerated) for embedded and external alike, on
both iOS and Android.
This commit is contained in:
Fredrik Burmester
2026-05-30 20:15:37 +02:00
parent 6876ce046f
commit d2e73021b1
2 changed files with 27 additions and 12 deletions

View File

@@ -684,11 +684,19 @@ class MPVLayerRenderer(private val context: Context) : MPVLib.EventObserver {
MPVLib.command(arrayOf("sub-add", subUrl, "auto"))
}
pendingExternalSubtitles = emptyList()
// Set subtitle after external subs are added
initialSubtitleId?.let { setSubtitleTrack(it) } ?: disableSubtitles()
}
// Apply the initial audio/subtitle selection now that the file's
// tracks are enumerated. Setting sid/aid before `loadfile` does not
// reliably stick for embedded tracks (the selection is silently
// dropped), so we (re)apply here for embedded and external alike.
// This is what makes a carried-over subtitle show up on the next
// episode without a manual re-selection.
if (initialAudioId != null && initialAudioId > 0) {
setAudioTrack(initialAudioId)
}
initialSubtitleId?.let { setSubtitleTrack(it) } ?: disableSubtitles()
if (!isReadyToSeek) {
isReadyToSeek = true
mainHandler.post { delegate?.onReadyToSeek() }