mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-26 08:46:45 +01:00
fix(segments): backport segment-skip fixes from chromecast refactor
Reconcile segment-skip with the diverged-but-ahead version on the chromecast refactor branch: - useSegmentSkipper: track auto-skip by segment identity instead of a bool, so it no longer re-triggers on pause/unpause; guard skipMode "none"; use a finite totalDuration check for Outro. - Controls: playingRef avoids a stale-closure resume after a seek; only resume playback if it was actually playing; skipCredit noop fallback. - segments: drop the dead try/catch around Promise.allSettled. - Remove the obsolete useIntroSkipper / useCreditSkipper hooks (177 dead lines, superseded by useSegmentSkipper).
This commit is contained in:
@@ -124,6 +124,12 @@ export const Controls: FC<Props> = ({
|
||||
// Ref to track pending play timeout for cleanup and cancellation
|
||||
const playTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
// Mutable ref tracking isPlaying to avoid stale closures in seekMs timeout
|
||||
const playingRef = useRef(isPlaying);
|
||||
useEffect(() => {
|
||||
playingRef.current = isPlaying;
|
||||
}, [isPlaying]);
|
||||
|
||||
// Clean up timeout on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
@@ -346,8 +352,11 @@ export const Controls: FC<Props> = ({
|
||||
seek(timeInSeconds * 1000);
|
||||
// Brief delay ensures the seek operation completes before resuming playback
|
||||
// Without this, playback may resume from the old position
|
||||
// Read latest isPlaying from ref to avoid stale closure
|
||||
playTimeoutRef.current = setTimeout(() => {
|
||||
play();
|
||||
if (playingRef.current) {
|
||||
play();
|
||||
}
|
||||
playTimeoutRef.current = null;
|
||||
}, 200);
|
||||
},
|
||||
@@ -427,7 +436,7 @@ export const Controls: FC<Props> = ({
|
||||
);
|
||||
const skipIntro = activeSegment?.skipSegment || noop;
|
||||
const showSkipCreditButton = activeSegment?.type === "Outro";
|
||||
const skipCredit = outroSkipper.skipSegment;
|
||||
const skipCredit = outroSkipper.skipSegment || noop;
|
||||
const hasContentAfterCredits =
|
||||
outroSkipper.currentSegment && maxSeconds
|
||||
? outroSkipper.currentSegment.endTime < maxSeconds
|
||||
|
||||
Reference in New Issue
Block a user