mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-27 01:06:42 +01:00
Sync subtitle and audio indexes between server and offline
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useCallback } from "react";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { getDownloadedItemById } from "@/providers/Downloads/database";
|
||||
import { usePlaySettings } from "@/providers/PlaySettingsProvider";
|
||||
import { writeToLog } from "@/utils/log";
|
||||
|
||||
@@ -15,9 +16,14 @@ export const useDownloadedFileOpener = () => {
|
||||
console.error("Attempted to open a file without an ID.");
|
||||
return;
|
||||
}
|
||||
const downloadedItem = getDownloadedItemById(item.Id);
|
||||
const queryParams = new URLSearchParams({
|
||||
itemId: item.Id,
|
||||
offline: "true",
|
||||
audioIndex:
|
||||
downloadedItem?.userData?.audioStreamIndex?.toString() ?? "",
|
||||
subtitleIndex:
|
||||
downloadedItem?.userData?.subtitleStreamIndex?.toString() ?? "-1",
|
||||
playbackPosition:
|
||||
item.UserData?.PlaybackPositionTicks?.toString() ?? "0",
|
||||
});
|
||||
|
||||
@@ -186,6 +186,20 @@ export const usePlaybackManager = ({
|
||||
: playedPercentage,
|
||||
},
|
||||
},
|
||||
// Sync selected audio/subtitle tracks so next playback resumes with
|
||||
// the same tracks the user had active — but only for non-transcoded
|
||||
// downloads where the user can freely switch tracks.
|
||||
userData: localItem.userData.isTranscoded
|
||||
? localItem.userData
|
||||
: {
|
||||
...localItem.userData,
|
||||
...(playbackProgressInfo.AudioStreamIndex != null && {
|
||||
audioStreamIndex: playbackProgressInfo.AudioStreamIndex,
|
||||
}),
|
||||
...(playbackProgressInfo.SubtitleStreamIndex != null && {
|
||||
subtitleStreamIndex: playbackProgressInfo.SubtitleStreamIndex,
|
||||
}),
|
||||
},
|
||||
});
|
||||
// Force invalidate queries so they refetch from updated local database
|
||||
queryClient.invalidateQueries({ queryKey: ["item", itemId] });
|
||||
|
||||
Reference in New Issue
Block a user