Skip to content

Commit

Permalink
refactor: Update subtitle streams to use TextTrack indexes (#2529)
Browse files Browse the repository at this point in the history
* refactor: Update subtitle streams to use TextTrack indexes, instead of MediaStream indexes

* Add comment referring to bug in jellyfin server regarding subtitles
  • Loading branch information
EffakT authored Dec 10, 2024
1 parent 88cec72 commit 297b4fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 9 additions & 7 deletions frontend/src/store/playback-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,20 @@ class PlaybackManagerStore extends CommonStore<PlaybackManagerState> {

public get currentItemParsedSubtitleTracks(): PlaybackTrack[] | undefined {
if (!isNil(this._state.currentMediaSource)) {
return this._state.currentMediaSource.MediaStreams?.map(
(stream, index) => ({
srcIndex: index,
...stream
})
)
.filter(
// 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
&& (sub.DeliveryMethod === SubtitleDeliveryMethod.Encode
|| sub.DeliveryMethod === SubtitleDeliveryMethod.External)
)
.map(
(stream, index) => ({
srcIndex: index,
...stream
})
)
.map(sub => ({
label: sub.DisplayTitle ?? 'Undefined',
src:
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/utils/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
)
}

/**
Expand Down

0 comments on commit 297b4fe

Please sign in to comment.