From e0ac424d2dc32552962bc68f1958675d9fe6ed24 Mon Sep 17 00:00:00 2001 From: EffakT Date: Thu, 5 Dec 2024 09:15:53 +1300 Subject: [PATCH 1/2] refactor: Update subtitle streams to use TextTrack indexes, instead of MediaStream indexes --- frontend/src/store/playback-manager.ts | 14 +++++++------- frontend/src/utils/items.ts | 8 +++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/src/store/playback-manager.ts b/frontend/src/store/playback-manager.ts index db4605f1d47..ecb36fa9f76 100644 --- a/frontend/src/store/playback-manager.ts +++ b/frontend/src/store/playback-manager.ts @@ -270,18 +270,18 @@ class PlaybackManagerStore extends CommonStore { public get currentItemParsedSubtitleTracks(): PlaybackTrack[] | undefined { if (!isNil(this._state.currentMediaSource)) { - return this._state.currentMediaSource.MediaStreams?.map( - (stream, index) => ({ - srcIndex: index, - ...stream - }) - ) - .filter( + return this._state.currentMediaSource.MediaStreams?.filter( sub => sub.Type === MediaStreamType.Subtitle && (sub.DeliveryMethod === SubtitleDeliveryMethod.Encode || sub.DeliveryMethod === SubtitleDeliveryMethod.External) ) + .map( + (stream, index) => ({ + srcIndex: index, + ...stream + }) + ) .map(sub => ({ label: sub.DisplayTitle ?? 'Undefined', src: diff --git a/frontend/src/utils/items.ts b/frontend/src/utils/items.ts index d2cf4557697..e02b5c3e8e0 100644 --- a/frontend/src/utils/items.ts +++ b/frontend/src/utils/items.ts @@ -450,7 +450,13 @@ export function getMediaStreams( mediaStreams: MediaStream[], streamType: string ): MediaStream[] { - return mediaStreams.filter(mediaStream => mediaStream.Type === streamType); + return mediaStreams.filter(mediaStream => mediaStream.Type === streamType) + .map( + (stream, index) => ({ + ...stream, + Index: index + }) + ) } /** From c9060b35c14f2d9381c6e3e6d0b1fd98c158213e Mon Sep 17 00:00:00 2001 From: EffakT Date: Tue, 10 Dec 2024 09:55:55 +1300 Subject: [PATCH 2/2] Add comment referring to bug in jellyfin server regarding subtitles --- frontend/src/store/playback-manager.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/store/playback-manager.ts b/frontend/src/store/playback-manager.ts index ecb36fa9f76..b5203599201 100644 --- a/frontend/src/store/playback-manager.ts +++ b/frontend/src/store/playback-manager.ts @@ -270,6 +270,8 @@ class PlaybackManagerStore extends CommonStore { public get currentItemParsedSubtitleTracks(): PlaybackTrack[] | undefined { if (!isNil(this._state.currentMediaSource)) { + // TODO: There is currently a bug in Jellyfin server when adding external subtitles may play the incorrect subtitle + // https://github.com/jellyfin/jellyfin/issues/13198 return this._state.currentMediaSource.MediaStreams?.filter( sub => sub.Type === MediaStreamType.Subtitle