mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-07 13:02:52 +01:00
fix(subtitles): teardown mpv before re-navigation and record the real local-sub index
Destroy the mpv instance before the track-change router.replace in replaceWithTrackSelection and goToPreviousItem, matching goToNextItem — two overlapping decoders/surfaces during the transition OOM low-RAM devices (CodeRabbit). addSubtitleFile now sets the live index to the downloaded local sub's real index (LOCAL_SUBTITLE_INDEX_START - position) instead of a blanket -100, which collided with the first local sub and mis-recorded the selection (Copilot); it still resolves to notFound on the onTracksReady re-apply so it doesn't clobber the freshly selected track.
This commit is contained in:
@@ -33,7 +33,6 @@ import {
|
||||
type SubtitleSearchResult,
|
||||
useRemoteSubtitles,
|
||||
} from "@/hooks/useRemoteSubtitles";
|
||||
import { compareTracksForMenu } from "@/utils/jellyfin/subtitleUtils";
|
||||
import { COMMON_SUBTITLE_LANGUAGES } from "@/utils/opensubtitles/api";
|
||||
|
||||
interface TVSubtitleSheetProps {
|
||||
@@ -97,19 +96,13 @@ export const TVSubtitleSheet: React.FC<TVSubtitleSheetProps> = ({
|
||||
const overlayOpacity = useRef(new Animated.Value(0)).current;
|
||||
const sheetTranslateY = useRef(new Animated.Value(300)).current;
|
||||
|
||||
// Order like jellyfin-web (embedded first, externals last, forced/default up).
|
||||
const sortedTracks = useMemo(
|
||||
() => [...subtitleTracks].sort(compareTracksForMenu),
|
||||
[subtitleTracks],
|
||||
);
|
||||
|
||||
const initialSelectedTrackIndex = useMemo(() => {
|
||||
if (currentSubtitleIndex === -1) return 0;
|
||||
const trackIdx = sortedTracks.findIndex(
|
||||
const trackIdx = subtitleTracks.findIndex(
|
||||
(t) => t.Index === currentSubtitleIndex,
|
||||
);
|
||||
return trackIdx >= 0 ? trackIdx + 1 : 0;
|
||||
}, [sortedTracks, currentSubtitleIndex]);
|
||||
}, [subtitleTracks, currentSubtitleIndex]);
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
@@ -222,7 +215,7 @@ export const TVSubtitleSheet: React.FC<TVSubtitleSheetProps> = ({
|
||||
value: -1,
|
||||
selected: currentSubtitleIndex === -1,
|
||||
};
|
||||
const options = sortedTracks.map((track) => ({
|
||||
const options = subtitleTracks.map((track) => ({
|
||||
label:
|
||||
track.DisplayTitle || `${track.Language || "Unknown"} (${track.Codec})`,
|
||||
sublabel: track.Codec?.toUpperCase(),
|
||||
@@ -230,7 +223,7 @@ export const TVSubtitleSheet: React.FC<TVSubtitleSheetProps> = ({
|
||||
selected: track.Index === currentSubtitleIndex,
|
||||
}));
|
||||
return [noneOption, ...options];
|
||||
}, [sortedTracks, currentSubtitleIndex, t]);
|
||||
}, [subtitleTracks, currentSubtitleIndex, t]);
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user