feat: add skip recap button

This commit is contained in:
Prayag Prajapati committed 2024-12-10 11:49:02 +05:30
1 parent bc6d39b004
commit 0847c2b2ef
3 files changed
+182 -62

No files matched your search

+39
View File
@@ -175,6 +175,10 @@ function VideoPlayer() {
(segment) => segment.Type === "Outro",
);
const recapInfo = mediaSegments?.Items?.find(
(segment) => segment.Type === "Recap",
);
const [currentQueueItemIndex, queue] = useQueue((s) => [
s.currentItemIndex,
s.tracks,
@@ -438,6 +442,17 @@ function VideoPlayer() {
return false;
}, [progress, item?.Id]);
const showSkipRecap = useMemo(() => {
if (
recapInfo &&
progress >= (recapInfo?.StartTicks ?? 0) &&
progress < (recapInfo?.EndTicks ?? 0)
) {
return true;
}
return false;
}, [progress, item?.Id]);
const handleSkipIntro = useCallback(() => {
player.current?.seekTo(
ticksToSec(Number(introInfo?.EndTicks)) ??
@@ -445,6 +460,13 @@ function VideoPlayer() {
);
}, [item?.Id]);
const handleSkipRecap = useCallback(() => {
player.current?.seekTo(
ticksToSec(Number(recapInfo?.EndTicks)) ??
player.current?.getCurrentTime(),
);
}, [item?.Id]);
const [forceShowCredits, setForceShowCredits] = useState(false);
const handleShowCredits = useCallback(() => {
setForceShowCredits(true);
@@ -725,6 +747,23 @@ function VideoPlayer() {
Skip Intro
</Button>
)}
{showSkipRecap && (
<Button
variant="outlined"
size="large"
//@ts-ignore
color="white"
style={{
position: "absolute",
bottom: "18vh",
right: "2em",
zIndex: 10000,
}}
onClick={handleSkipRecap}
>
Skip Recap
</Button>
)}
{!forceShowCredits && showUpNextCard && (
<OutroCard handleShowCredits={handleShowCredits} />
)}