mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-16 05:51:57 +01:00
wip
This commit is contained in:
@@ -21,7 +21,8 @@ interface CreditTimestamps {
|
||||
export const useCreditSkipper = (
|
||||
itemId: string | undefined,
|
||||
currentTime: number,
|
||||
videoRef: React.RefObject<any>
|
||||
seek: (time: number) => void,
|
||||
play: () => void
|
||||
) => {
|
||||
const [api] = useAtom(apiAtom);
|
||||
const [showSkipCreditButton, setShowSkipCreditButton] = useState(false);
|
||||
@@ -60,16 +61,16 @@ export const useCreditSkipper = (
|
||||
}, [creditTimestamps, currentTime]);
|
||||
|
||||
const skipCredit = useCallback(() => {
|
||||
if (!creditTimestamps || !videoRef.current) return;
|
||||
if (!creditTimestamps) return;
|
||||
try {
|
||||
videoRef.current.seek(creditTimestamps.Credits.End);
|
||||
seek(creditTimestamps.Credits.End);
|
||||
setTimeout(() => {
|
||||
videoRef.current?.resume();
|
||||
play();
|
||||
}, 200);
|
||||
} catch (error) {
|
||||
writeToLog("ERROR", "Error skipping intro", error);
|
||||
}
|
||||
}, [creditTimestamps, videoRef]);
|
||||
}, [creditTimestamps]);
|
||||
|
||||
return { showSkipCreditButton, skipCredit };
|
||||
};
|
||||
|
||||
@@ -17,7 +17,8 @@ interface IntroTimestamps {
|
||||
export const useIntroSkipper = (
|
||||
itemId: string | undefined,
|
||||
currentTime: number,
|
||||
videoRef: React.RefObject<any>
|
||||
seek: (ticks: number) => void,
|
||||
play: () => void
|
||||
) => {
|
||||
const [api] = useAtom(apiAtom);
|
||||
const [showSkipButton, setShowSkipButton] = useState(false);
|
||||
@@ -57,16 +58,16 @@ export const useIntroSkipper = (
|
||||
|
||||
const skipIntro = useCallback(() => {
|
||||
console.log("skipIntro");
|
||||
if (!introTimestamps || !videoRef.current) return;
|
||||
if (!introTimestamps) return;
|
||||
try {
|
||||
videoRef.current.seek(introTimestamps.IntroEnd);
|
||||
seek(introTimestamps.IntroEnd);
|
||||
setTimeout(() => {
|
||||
videoRef.current?.resume();
|
||||
play();
|
||||
}, 200);
|
||||
} catch (error) {
|
||||
writeToLog("ERROR", "Error skipping intro", error);
|
||||
}
|
||||
}, [introTimestamps, videoRef]);
|
||||
}, [introTimestamps]);
|
||||
|
||||
return { showSkipButton, skipIntro };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user