feat: shpw upNext card and reset segements while seeking

This commit is contained in:
Prayag Prajapati committed 2025-07-05 15:06:51 +05:30
1 parent f919162dfc
commit 0cf87da218
6 files changed
+187 -3

No files matched your search

-1
View File
@@ -19,7 +19,6 @@ export default function Backdrop() {
return (
<div className="app-backdrop-container">
<BlurhashCanvas
key={backdropHash}
blurhashString={backdropHash}
width={300}
height={150}
@@ -27,7 +27,8 @@ const SkipSegmentButton = () => {
if (
!mediaSegments?.Items?.length ||
currentSegmentIndex < 0 ||
!activeSegmentId
!activeSegmentId ||
mediaSegments?.Items?.[currentSegmentIndex].Type === "Outro"
) {
return null; // No segments to skip
}
@@ -0,0 +1,41 @@
.video-player-up_next_flyout {
position: absolute;
bottom: 2em;
right: 2em;
width: 42em;
height: fit-content;
display: flex;
gap: 10px;
align-items: stretch;
justify-content: center;
background-color: rgba(60, 60, 60,1);
padding: 10px;
border-radius: $border-radius-default + 10px;
z-index: 10;
transition: bottom 0.3s ease-in-out;
&.floating {
bottom: 18vh
}
&-thumbnail {
max-width: 100%;
max-height: 100%;
width: 15em;
object-fit: cover;
border-radius: $border-radius-default;
}
&-details {
display: flex;
flex-direction: column;
gap: 5px;
overflow: hidden;
justify-content: flex-start;
align-items: flex-start;
// height: 100%;
}
&-button{
// justify-self: flex-end;
margin-top: auto;
}
}
@@ -0,0 +1,109 @@
import { Button, Typography } from "@mui/material";
import { motion } from "motion/react";
import React, { useMemo } from "react";
import { useShallow } from "zustand/shallow";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
import { useApiInContext } from "@/utils/store/api";
import { usePlaybackStore } from "@/utils/store/playback";
import useQueue from "@/utils/store/queue";
import "./upNextFlyout.scss";
const UpNextFlyout = () => {
const {
activeSegmentId,
currentSegmemtIndex,
mediaSegments,
skipSegment,
isUserHovering,
isUserSeeking,
isPlayerPlaying,
} = usePlaybackStore(
useShallow((state) => ({
activeSegmentId: state.activeSegmentId,
currentSegmemtIndex: state.nextSegmentIndex - 1,
mediaSegments: state.metadata.mediaSegments,
skipSegment: state.skipSegment,
isUserHovering: state.playerState.isUserHovering,
isUserSeeking: state.playerState.isUserSeeking,
isPlayerPlaying: state.playerState.isPlayerPlaying,
})),
);
const { nextItemIndex, tracks } = useQueue(
useShallow((state) => ({
nextItemIndex: state.currentItemIndex + 1,
tracks: state.tracks,
})),
);
const areControlsVisible = useMemo(() => {
return isUserHovering || isUserSeeking || !isPlayerPlaying;
}, [isUserHovering, isUserSeeking, isPlayerPlaying]);
const api = useApiInContext((s) => s.api);
if (
!api ||
!activeSegmentId ||
mediaSegments?.Items?.[currentSegmemtIndex].Type !== "Outro"
) {
return null;
}
const item = tracks?.[nextItemIndex];
if (!item || !item.Id) {
return null;
}
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%"
sx={{
display: "-webkit-box",
webkitLineClamp: "3",
webkitBoxOrient: "vertical",
overflow: "hidden",
}}
>
{item.Overview}
</Typography>
<Button
onClick={skipSegment}
variant="contained"
color="primary"
className="video-player-up_next_flyout-button"
>
Play
</Button>
</div>
</motion.div>
);
};
export default UpNextFlyout;