Skip to content

Commit 2f6b288

Browse files
committed
fix(MediaStream.swift): adjust external subtitle indexes to correct ordering in VLC player
ref: jellyfin#1311 Signed-off-by: ddrccw <[email protected]>
1 parent db7723f commit 2f6b288

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

Shared/Extensions/JellyfinAPI/MediaStream.swift

+30-3
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,41 @@ extension [MediaStream] {
220220
func adjustExternalSubtitleIndexes(audioStreamCount: Int) -> [MediaStream] {
221221
guard allSatisfy({ $0.type == .subtitle }) else { return self }
222222
let embeddedSubtitleCount = filter { !($0.isExternal ?? false) }.count
223+
let externalSubtitleCount = filter { $0.isExternal ?? false }.count
223224

224225
var mediaStreams = self
225226

227+
// TODO: how to fix when transcoding
228+
// case:鱿鱼游戏第二季,第五集
229+
// display order
230+
// - external, ch
231+
// - korean
232+
// - ...
233+
// - viet
234+
235+
// vlc player subtitle track order
236+
// - 2 ==> viet
237+
// - 3 ==> korean
238+
// - 37 ==> same as displayed subtitle
239+
// - 38 ==> external, ch while displaying viet
240+
241+
// display order
242+
// - extern subtitles
243+
// - embeded subtitles
244+
245+
// ??? weird order
246+
// vlc player subtitle track order
247+
// - embeded subtitles n
248+
// - embeded subtitles (1, n-1)
249+
// - extern subtitles
250+
226251
for (i, mediaStream) in mediaStreams.enumerated() {
227-
guard mediaStream.isExternal ?? false else { continue }
228252
var copy = mediaStream
229-
copy.index = (copy.index ?? 0) + 1 + embeddedSubtitleCount + audioStreamCount
230-
253+
if copy.isExternal ?? false {
254+
copy.index = (copy.index ?? 0) + 1 + embeddedSubtitleCount + audioStreamCount
255+
} else {
256+
copy.index = (copy.index ?? 0) - externalSubtitleCount
257+
}
231258
mediaStreams[i] = copy
232259
}
233260

0 commit comments

Comments
 (0)