Start working PlayButton and add few missing displays to card #153
This commit is contained in:
6 files changed
+201
-126
No files matched your search
@@ -2,15 +2,63 @@
|
||||
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import { MdiPlayOutline } from "../icons/mdiPlayOutline";
|
||||
import { usePlaybackStore } from "../../utils/store/playback";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
const PlayButton = ({ className, sx, iconProps }) => {
|
||||
const PlayButton = ({
|
||||
itemId,
|
||||
mediaSources,
|
||||
currentAudioTrack,
|
||||
currentSubTrack,
|
||||
currentVideoTrack,
|
||||
itemName,
|
||||
seriesName,
|
||||
itemIndex,
|
||||
itemParentIndex,
|
||||
itemRuntimeTicks,
|
||||
itemPlaybackPositionTicks,
|
||||
itemType,
|
||||
className,
|
||||
sx,
|
||||
iconProps,
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const [
|
||||
setUrl,
|
||||
setPosition,
|
||||
setDuration,
|
||||
setItemId,
|
||||
setItemName,
|
||||
setSubtitleTracksStore,
|
||||
setSelectedSubtitleTrack,
|
||||
] = usePlaybackStore((state) => [
|
||||
state.setUrl,
|
||||
state.setPosition,
|
||||
state.setDuration,
|
||||
state.setItemId,
|
||||
state.setItemName,
|
||||
state.setSubtitleTracks,
|
||||
state.setSelectedSubtitleTrack,
|
||||
]);
|
||||
const handleClick = (e) => {
|
||||
e.stopPropagation();
|
||||
setUrl(
|
||||
`${window.api.basePath}/Videos/${itemId}/stream.${mediaSources[0].Container}?Static=true&mediaSourceId=${itemId}&deviceId=${window.api.deviceInfo.id}&api_key=${window.api.accessToken}&Tag=${mediaSources[0].ETag}&videoStreamIndex=${currentVideoTrack}&audioStreamIndex=${currentAudioTrack}`,
|
||||
);
|
||||
setPosition(itemPlaybackPositionTicks);
|
||||
setItemName(
|
||||
itemType == "Episode"
|
||||
? `${seriesName} S${itemParentIndex}:E${itemIndex} ${itemName}`
|
||||
: itemName,
|
||||
);
|
||||
setItemId(itemId);
|
||||
setDuration(itemRuntimeTicks);
|
||||
// setSubtitleTracksStore(subtitleTracks);
|
||||
setSelectedSubtitleTrack(currentSubTrack);
|
||||
navigate(`/player`);
|
||||
};
|
||||
return (
|
||||
<IconButton
|
||||
className={className}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
sx={sx}
|
||||
disabled
|
||||
>
|
||||
<IconButton className={className} onClick={handleClick} sx={sx}>
|
||||
<MdiPlayOutline {...iconProps} />
|
||||
</IconButton>
|
||||
);
|
||||
|
||||
+101
-40
@@ -43,19 +43,15 @@ const cardImageAspectRatios = {
|
||||
};
|
||||
|
||||
export const Card = ({
|
||||
itemId,
|
||||
itemType,
|
||||
itemName,
|
||||
isFavorite,
|
||||
isPlayed,
|
||||
item,
|
||||
cardTitle,
|
||||
cardCaption,
|
||||
imageType = "Primary",
|
||||
imageBlurhash,
|
||||
cardType,
|
||||
secondaryText,
|
||||
queryKey,
|
||||
userId,
|
||||
availableImagesTypes,
|
||||
playedProgress = 0,
|
||||
seriesId,
|
||||
|
||||
onClick,
|
||||
@@ -64,7 +60,7 @@ export const Card = ({
|
||||
const ref = useRef();
|
||||
const isVisible = useIntersecting(ref);
|
||||
const navigate = useNavigate();
|
||||
const defaultOnClick = () => navigate(`/item/${itemId}`);
|
||||
const defaultOnClick = () => navigate(`/item/${item.Id}`);
|
||||
return (
|
||||
<CardActionArea
|
||||
sx={{ padding: 1, borderRadius: "10px" }}
|
||||
@@ -103,26 +99,69 @@ export const Card = ({
|
||||
zIndex: 0,
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "0.4em",
|
||||
right: "0.4em",
|
||||
zIndex: 2,
|
||||
background: "rgb(20 20 20 / 0.5)",
|
||||
padding: "0.2em 0.75em",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
borderRadius: "100px",
|
||||
backdropFilter: "blur(5px)",
|
||||
transition: "opacity 250ms",
|
||||
opacity: isPlayed ? 1 : 0,
|
||||
boxShadow: "0 0 5px rgb(0 0 0 / 0.2)",
|
||||
}}
|
||||
>
|
||||
<MdiCheck />
|
||||
</Box>
|
||||
{!!item.UserData && (
|
||||
<>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "0.4em",
|
||||
right: "0.4em",
|
||||
zIndex: 2,
|
||||
background:
|
||||
"rgb(20 20 20 / 0.5)",
|
||||
padding: "0.2em 0.75em",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
borderRadius: "100px",
|
||||
backdropFilter: "blur(5px)",
|
||||
transition: "opacity 250ms",
|
||||
opacity: item.UserData
|
||||
?.IsPlayed
|
||||
? 1
|
||||
: 0,
|
||||
boxShadow:
|
||||
"0 0 5px rgb(0 0 0 / 0.2)",
|
||||
}}
|
||||
>
|
||||
<MdiCheck />
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "0.4em",
|
||||
right: "0.4em",
|
||||
zIndex: 2,
|
||||
background:
|
||||
"rgb(20 20 20 / 0.5)",
|
||||
padding: "0.2em 0.75em",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
borderRadius: "100px",
|
||||
backdropFilter: "blur(5px)",
|
||||
transition: "opacity 250ms",
|
||||
opacity: item.UserData
|
||||
?.UnplayedItemCount
|
||||
? 1
|
||||
: 0,
|
||||
boxShadow:
|
||||
"0 0 5px rgb(0 0 0 / 0.2)",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
padding="0.1em 0.4em"
|
||||
fontWeight={400}
|
||||
>
|
||||
{
|
||||
item.UserData
|
||||
?.UnplayedItemCount
|
||||
}
|
||||
</Typography>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
{!!imageBlurhash && (
|
||||
<Blurhash
|
||||
hash={imageBlurhash}
|
||||
@@ -134,11 +173,11 @@ export const Card = ({
|
||||
/>
|
||||
)}
|
||||
<Box className="card-image-icon-container">
|
||||
{TypeIconCollectionCard[itemType]}
|
||||
{TypeIconCollectionCard[item.Type]}
|
||||
</Box>
|
||||
<img
|
||||
src={window.api.getItemImageUrl(
|
||||
!!seriesId ? seriesId : itemId,
|
||||
!!seriesId ? item.SeriesId : item.Id,
|
||||
imageType,
|
||||
{
|
||||
quality: 90,
|
||||
@@ -158,31 +197,53 @@ export const Card = ({
|
||||
{!disableOverlay && (
|
||||
<Box className="card-overlay">
|
||||
<PlayButton
|
||||
itemId={item.Id}
|
||||
mediaSources={item.MediaSources}
|
||||
currentAudioTrack={0}
|
||||
currentSubTrack={0}
|
||||
currentVideoTrack={0}
|
||||
itemName={item.Name}
|
||||
seriesName={item.SeriesName}
|
||||
itemIndex={item.IndexNumber}
|
||||
itemParentIndex={
|
||||
item.ParentIndexNumber
|
||||
}
|
||||
itemRuntimeTicks={
|
||||
!!item.MediaSources &&
|
||||
item.MediaSources[0]
|
||||
.RunTimeTicks
|
||||
}
|
||||
itemPlaybackPositionTicks={
|
||||
item.UserData
|
||||
?.PlaybackPositionTicks
|
||||
}
|
||||
className="card-play-button"
|
||||
iconProps={{
|
||||
sx: { fontSize: "1.5em" },
|
||||
}}
|
||||
/>
|
||||
<LikeButton
|
||||
itemId={itemId}
|
||||
itemName={itemName}
|
||||
isFavorite={isFavorite}
|
||||
itemId={item.Id}
|
||||
itemName={item.Name}
|
||||
isFavorite={
|
||||
item.UserData?.IsFavorite
|
||||
}
|
||||
queryKey={queryKey}
|
||||
userId={userId}
|
||||
/>
|
||||
<MarkPlayedButton
|
||||
itemId={itemId}
|
||||
itemName={itemName}
|
||||
isPlayed={isPlayed}
|
||||
itemId={item.Id}
|
||||
itemName={item.Name}
|
||||
isPlayed={item.UserData.IsPlayed}
|
||||
queryKey={queryKey}
|
||||
userId={userId}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
{playedProgress != 0 && (
|
||||
{Boolean(item.UserData?.PlayedPercentage) && (
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={playedProgress}
|
||||
value={item.UserData.PlayedPercentage}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
left: 0,
|
||||
@@ -206,7 +267,7 @@ export const Card = ({
|
||||
textAlign="center"
|
||||
sx={{ opacity: 0.9 }}
|
||||
>
|
||||
{itemName}
|
||||
{cardTitle}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
@@ -215,7 +276,7 @@ export const Card = ({
|
||||
sx={{ opacity: 0.6 }}
|
||||
lineHeight="auto"
|
||||
>
|
||||
{secondaryText}
|
||||
{cardCaption}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
@@ -45,23 +45,16 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
{data.data.map((item, index) => {
|
||||
return (
|
||||
<Card
|
||||
key={index}
|
||||
itemName={
|
||||
key={item.Id}
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type == BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
itemId={item.Id}
|
||||
seriesId={item.SeriesId}
|
||||
itemType={item.Type}
|
||||
imageType="Primary"
|
||||
cardType={
|
||||
item.Type == BaseItemKind.MusicAlbum ||
|
||||
item.Type == BaseItemKind.Audio
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
secondaryText={
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type == BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type == BaseItemKind.Series
|
||||
@@ -79,12 +72,16 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
isFavorite={item.UserData.IsFavorite}
|
||||
cardType={
|
||||
item.Type == BaseItemKind.MusicAlbum ||
|
||||
item.Type == BaseItemKind.Audio
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[
|
||||
"homeSection, latestMedia",
|
||||
latestMediaLib,
|
||||
]}
|
||||
isPlayed={item.UserData.Played}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
item.ImageBlurHashes?.Primary[
|
||||
@@ -93,9 +90,6 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
playedProgress={
|
||||
item.UserData.PlayedPercentage
|
||||
}
|
||||
></Card>
|
||||
);
|
||||
})}
|
||||
|
||||
+25
-60
@@ -103,6 +103,8 @@ const Home = () => {
|
||||
"ParentIndexNumber",
|
||||
ItemFields.SeasonUserData,
|
||||
ItemFields.IsHd,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.MediaSources,
|
||||
],
|
||||
enableUserData: true,
|
||||
enableImages: true,
|
||||
@@ -123,6 +125,10 @@ const Home = () => {
|
||||
limit: 10,
|
||||
mediaTypes: ["Video"],
|
||||
enableUserData: true,
|
||||
fields: [
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.MediaSources,
|
||||
],
|
||||
},
|
||||
);
|
||||
return resumeItems.data;
|
||||
@@ -140,6 +146,10 @@ const Home = () => {
|
||||
limit: 10,
|
||||
mediaTypes: ["Audio"],
|
||||
enableUserData: true,
|
||||
fields: [
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.MediaSources,
|
||||
],
|
||||
},
|
||||
);
|
||||
return resumeItems.data;
|
||||
@@ -155,6 +165,8 @@ const Home = () => {
|
||||
userId: user.data.Id,
|
||||
fields: [
|
||||
ItemFields.PrimaryImageAspectRatio,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.ParentId,
|
||||
],
|
||||
limit: 10,
|
||||
@@ -252,9 +264,10 @@ const Home = () => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
itemName={item.Name}
|
||||
itemId={item.Id}
|
||||
itemType="Library"
|
||||
item={item}
|
||||
cardTitle={
|
||||
item.Name
|
||||
}
|
||||
imageType="Primary"
|
||||
cardType="thumb"
|
||||
disableOverlay
|
||||
@@ -292,14 +305,13 @@ const Home = () => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
itemName={
|
||||
item={item}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
itemId={item.Id}
|
||||
itemType={item.Type}
|
||||
imageType={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
@@ -312,7 +324,7 @@ const Home = () => {
|
||||
? "Thumb"
|
||||
: "Backdrop"
|
||||
}
|
||||
secondaryText={
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
@@ -335,17 +347,10 @@ const Home = () => {
|
||||
: item.ProductionYear
|
||||
}
|
||||
cardType="thumb"
|
||||
isFavorite={
|
||||
item.UserData
|
||||
.IsFavorite
|
||||
}
|
||||
queryKey={[
|
||||
"home",
|
||||
"upNext",
|
||||
]}
|
||||
isPlayed={
|
||||
item.UserData.Played
|
||||
}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
item.ImageBlurHashes
|
||||
@@ -357,16 +362,6 @@ const Home = () => {
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
availableImagesTypes={
|
||||
!!item.ImageTags &&
|
||||
Object.keys(
|
||||
item.ImageTags,
|
||||
)
|
||||
}
|
||||
playedProgress={
|
||||
item.UserData
|
||||
.PlayedPercentage
|
||||
}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
@@ -387,14 +382,13 @@ const Home = () => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
itemName={
|
||||
item={item}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
itemId={item.Id}
|
||||
itemType={item.Type}
|
||||
imageType={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
@@ -407,7 +401,7 @@ const Home = () => {
|
||||
? "Thumb"
|
||||
: "Backdrop"
|
||||
}
|
||||
secondaryText={
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
@@ -430,18 +424,11 @@ const Home = () => {
|
||||
: item.ProductionYear
|
||||
}
|
||||
cardType="thumb"
|
||||
isFavorite={
|
||||
item.UserData
|
||||
.IsFavorite
|
||||
}
|
||||
queryKey={[
|
||||
"home",
|
||||
"resume",
|
||||
"video",
|
||||
]}
|
||||
isPlayed={
|
||||
item.UserData.Played
|
||||
}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
item.ImageBlurHashes
|
||||
@@ -453,16 +440,6 @@ const Home = () => {
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
availableImagesTypes={
|
||||
!!item.ImageTags &&
|
||||
Object.keys(
|
||||
item.ImageTags,
|
||||
)
|
||||
}
|
||||
playedProgress={
|
||||
item.UserData
|
||||
.PlayedPercentage
|
||||
}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
@@ -483,9 +460,8 @@ const Home = () => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
itemName={item.Name}
|
||||
itemId={item.Id}
|
||||
itemType={item.Type}
|
||||
item={item}
|
||||
cardTitle={item.Name}
|
||||
imageType={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
@@ -498,22 +474,15 @@ const Home = () => {
|
||||
? "Thumb"
|
||||
: "Backdrop"
|
||||
}
|
||||
secondaryText={
|
||||
cardCaption={
|
||||
item.ProductionYear
|
||||
}
|
||||
cardType="thumb"
|
||||
isFavorite={
|
||||
item.UserData
|
||||
.IsFavorite
|
||||
}
|
||||
queryKey={[
|
||||
"home",
|
||||
"resume",
|
||||
"audio",
|
||||
]}
|
||||
isPlayed={
|
||||
item.UserData.Played
|
||||
}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
item.ImageBlurHashes
|
||||
@@ -525,10 +494,6 @@ const Home = () => {
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
playedProgress={
|
||||
item.UserData
|
||||
.PlayedPercentage
|
||||
}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -210,7 +210,7 @@ export const VideoPlayer = () => {
|
||||
|
||||
return (
|
||||
<Box
|
||||
className="video"
|
||||
className="video-player-container"
|
||||
sx={{ background: "black" }}
|
||||
onMouseMove={() => {
|
||||
setShowControls(true);
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
&-osd-visible &-osd {
|
||||
opacity: 1;
|
||||
}
|
||||
&-player-container {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
video {
|
||||
|
||||
Reference in new issue
Block a user