feat: implement proper queue functionality and improve upnext flyout and skip segment buttons

This commit is contained in:
--remove-section committed 2025-12-23 21:45:32 +05:30
1 parent e41b5b3085
commit b49f187098
10 files changed
+1019 -597

No files matched your search

@@ -199,7 +199,7 @@ const BubbleSlider = () => {
trickplayResolution.Width / trickplayResolution.Height;
trickplayStyle = {
background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
backgroundImage: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
backgroundPositionX: `${backgroundOffsetX}px`,
backgroundPositionY: `${backgroundOffsetY}px`,
width: `${trickplayResolution.Width}px`,
@@ -1,4 +1,5 @@
import { Button } from "@mui/material";
import { Box, Button } from "@mui/material";
import { AnimatePresence, motion } from "motion/react";
import React from "react";
import { useShallow } from "zustand/shallow";
import { usePlaybackStore } from "@/utils/store/playback";
@@ -24,33 +25,67 @@ const SkipSegmentButton = () => {
})),
);
if (
!mediaSegments?.Items?.length ||
currentSegmentIndex < 0 ||
!activeSegmentId ||
mediaSegments?.Items?.[currentSegmentIndex].Type === "Outro"
) {
return null; // No segments to skip
}
const shouldShow =
mediaSegments?.Items?.length &&
currentSegmentIndex >= 0 &&
activeSegmentId &&
mediaSegments?.Items?.[currentSegmentIndex].Type !== "Outro";
return (
<Button
variant="outlined"
size="large"
//@ts-ignore
color="white"
style={{
position: "absolute",
bottom:
isUserHovering || !isPlayerPlaying || isUserSeeking ? "18vh" : "2em",
right: "2em",
transition: "bottom 0.3s ease-in-out",
zIndex: 10000,
}}
onClick={skipSegment}
>
Skip {mediaSegments?.Items?.[currentSegmentIndex].Type}
</Button>
<AnimatePresence>
{shouldShow && (
<motion.div
initial={{ opacity: 0, x: 20, scale: 0.9 }}
animate={{ opacity: 1, x: 0, scale: 1 }}
exit={{ opacity: 0, x: 20, scale: 0.9 }}
transition={{
type: "spring",
stiffness: 300,
damping: 30,
}}
style={{
position: "absolute",
right: "3em",
zIndex: 10000,
bottom:
isUserHovering || !isPlayerPlaying || isUserSeeking ? "20vh" : "6em",
transition: "bottom 0.3s ease-in-out",
}}
>
<Button
onClick={skipSegment}
variant="contained"
startIcon={
<span className="material-symbols-rounded">skip_next</span>
}
sx={{
bgcolor: "rgba(20, 20, 20, 0.6)",
backdropFilter: "blur(16px) saturate(180%)",
color: "white",
border: "1px solid rgba(255, 255, 255, 0.1)",
borderRadius: "12px",
padding: "12px 24px",
textTransform: "none",
fontSize: "1rem",
fontWeight: 600,
boxShadow: "0 8px 32px 0 rgba(0, 0, 0, 0.2)",
transition: "all 0.2s ease",
"&:hover": {
bgcolor: "rgba(255, 255, 255, 0.1)",
transform: "scale(1.02)",
boxShadow: "0 8px 32px 0 rgba(0, 0, 0, 0.3)",
border: "1px solid rgba(255, 255, 255, 0.2)",
},
"&:active": {
transform: "scale(0.98)",
},
}}
>
Skip {mediaSegments?.Items?.[currentSegmentIndex].Type}
</Button>
</motion.div>
)}
</AnimatePresence>
);
};
@@ -1,6 +1,6 @@
import { Button, Typography } from "@mui/material";
import { motion } from "motion/react";
import React, { useMemo } from "react";
import { Box, Button, IconButton, Typography } from "@mui/material";
import { AnimatePresence, motion } from "motion/react";
import React, { useEffect, useMemo, useState } from "react";
import { useShallow } from "zustand/shallow";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
import { useApiInContext } from "@/utils/store/api";
@@ -36,6 +36,13 @@ const UpNextFlyout = () => {
tracks: state.tracks,
})),
);
const [isHidden, setIsHidden] = useState(false);
useEffect(() => {
setIsHidden(false);
}, [activeSegmentId]);
const areControlsVisible = useMemo(() => {
return isUserHovering || isUserSeeking || !isPlayerPlaying;
}, [isUserHovering, isUserSeeking, isPlayerPlaying]);
@@ -45,7 +52,8 @@ const UpNextFlyout = () => {
if (
!api ||
!activeSegmentId ||
mediaSegments?.Items?.[currentSegmemtIndex].Type !== "Outro"
mediaSegments?.Items?.[currentSegmemtIndex].Type !== "Outro" ||
isHidden
) {
return null;
}
@@ -56,53 +64,154 @@ const UpNextFlyout = () => {
}
return (
<motion.div
className={
areControlsVisible
? "video-player-up_next_flyout floating"
: "video-player-up_next_flyout"
}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<img
className="video-player-up_next_flyout-thumbnail"
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
tag: item.ImageTags?.Primary,
quality: 80,
fillWidth: 300,
})}
alt={"next item thumbnail"}
/>
<div className="video-player-up_next_flyout-details">
<Typography variant="h5">
{`S${item.ParentIndexNumber}:E${item.IndexNumber} `}
{item.Name}
</Typography>
<Typography
variant="subtitle2"
// noWrap
textOverflow="ellipsis"
maxWidth="100%"
<AnimatePresence>
<motion.div
className={
areControlsVisible
? "video-player-up_next_flyout floating"
: "video-player-up_next_flyout"
}
initial={{ opacity: 0, y: 50, scale: 0.95 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 20, scale: 0.95 }}
transition={{ duration: 0.4, ease: [0.4, 0, 0.2, 1] }}
style={{
background: "rgba(20, 20, 20, 0.6)",
backdropFilter: "blur(16px) saturate(180%)",
border: "1px solid rgba(255, 255, 255, 0.1)",
boxShadow: "0 8px 32px 0 rgba(0, 0, 0, 0.3)",
borderRadius: "24px",
padding: "16px",
display: "flex",
gap: "16px",
maxWidth: "500px",
width: "100%",
overflow: "hidden",
}}
>
<Box
sx={{
display: "-webkit-box",
webkitLineClamp: "3",
webkitBoxOrient: "vertical",
position: "relative",
width: "160px",
minWidth: "160px",
borderRadius: "8px",
overflow: "hidden",
aspectRatio: "16/9",
boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
}}
>
{item.Overview}
</Typography>
<Button
onClick={skipSegment}
variant="contained"
color="primary"
className="video-player-up_next_flyout-button"
<img
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
tag: item.ImageTags?.Primary,
quality: 90,
fillWidth: 320,
})}
alt="next item thumbnail"
style={{
width: "100%",
height: "100%",
objectFit: "cover",
}}
/>
<Box
sx={{
position: "absolute",
inset: 0,
background:
"linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%)",
}}
/>
</Box>
<Box
sx={{
display: "flex",
flexDirection: "column",
flex: 1,
minWidth: 0,
justifyContent: "center",
}}
>
Play
</Button>
</div>
</motion.div>
<Typography
variant="overline"
sx={{
color: "primary.main",
fontWeight: 700,
lineHeight: 1,
mb: 0.5,
letterSpacing: 1.2,
}}
>
UP NEXT
</Typography>
<Typography
variant="h6"
sx={{
fontWeight: 600,
lineHeight: 1.2,
mb: 0.5,
fontSize: "1.1rem",
}}
noWrap
>
{item.SeriesName || item.Name}
</Typography>
<Typography
variant="body2"
color="text.secondary"
sx={{
mb: 2,
display: "-webkit-box",
WebkitLineClamp: 1,
WebkitBoxOrient: "vertical",
overflow: "hidden",
opacity: 0.8,
}}
>
{item.SeriesName
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
: item.Overview || ""}
</Typography>
<Box sx={{ display: "flex", gap: 1, mt: "auto" }}>
<Button
onClick={skipSegment}
variant="contained"
color="primary"
startIcon={
<span className="material-symbols-rounded fill">
play_arrow
</span>
}
sx={{
borderRadius: "8px",
textTransform: "none",
fontWeight: 600,
boxShadow:
"0 4px 12px rgba(var(--mui-palette-primary-mainChannel), 0.3)",
flex: 1,
}}
>
Play Now
</Button>
<IconButton
onClick={() => setIsHidden(true)}
sx={{
borderRadius: "8px",
border: "1px solid rgba(255,255,255,0.1)",
color: "text.secondary",
"&:hover": {
bgcolor: "rgba(255,255,255,0.1)",
color: "white",
},
}}
>
<span className="material-symbols-rounded">close</span>
</IconButton>
</Box>
</Box>
</motion.div>
</AnimatePresence>
);
};