Update
This commit is contained in:
5 files changed
+94
-41
No files matched your search
@@ -1,6 +1,9 @@
|
||||
/** @format */
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Button from "@mui/material/Button";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import { MdiPlayOutline } from "../icons/mdiPlayOutline";
|
||||
import {
|
||||
usePlaybackDataLoadStore,
|
||||
@@ -12,9 +15,11 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
const PlayButton = ({
|
||||
itemId,
|
||||
itemUserData,
|
||||
userId,
|
||||
itemType,
|
||||
currentAudioTrack,
|
||||
@@ -23,6 +28,8 @@ const PlayButton = ({
|
||||
className,
|
||||
sx,
|
||||
iconProps,
|
||||
buttonProps,
|
||||
iconOnly,
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const [
|
||||
@@ -46,6 +53,8 @@ const PlayButton = ({
|
||||
(state) => state.setIsLoading,
|
||||
);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const item = useMutation({
|
||||
mutationKey: ["playButton", itemId, userId],
|
||||
mutationFn: async () => {
|
||||
@@ -74,7 +83,6 @@ const PlayButton = ({
|
||||
return result.data;
|
||||
},
|
||||
onSuccess: (item) => {
|
||||
console.log(item);
|
||||
setUrl(
|
||||
`${window.api.basePath}/Videos/${item.Items[0].Id}/stream.
|
||||
${item.Items[0].MediaSources[0].Container}
|
||||
@@ -95,16 +103,79 @@ const PlayButton = ({
|
||||
onSettled: () => {
|
||||
setPlaybackDataLoading(false);
|
||||
},
|
||||
onError: (error) => {
|
||||
enqueueSnackbar(`${error}`, {
|
||||
variant: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
const handleClick = (e) => {
|
||||
e.stopPropagation();
|
||||
item.mutate();
|
||||
};
|
||||
return (
|
||||
<IconButton className={className} onClick={handleClick} sx={sx}>
|
||||
<MdiPlayOutline {...iconProps} />
|
||||
</IconButton>
|
||||
);
|
||||
if (iconOnly) {
|
||||
return (
|
||||
<IconButton
|
||||
className={className}
|
||||
onClick={handleClick}
|
||||
sx={sx}
|
||||
{...buttonProps}
|
||||
>
|
||||
<MdiPlayOutline {...iconProps} />
|
||||
</IconButton>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Button
|
||||
className={className}
|
||||
variant="contained"
|
||||
onClick={handleClick}
|
||||
startIcon={<MdiPlayOutline />}
|
||||
{...buttonProps}
|
||||
sx={{
|
||||
position: "relative",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={
|
||||
!!itemUserData.PlayedPercentage
|
||||
? itemUserData.PlayedPercentage
|
||||
: 0
|
||||
}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
height: "100%",
|
||||
background: "transparent",
|
||||
opacity: 0.2,
|
||||
zIndex: 0,
|
||||
}}
|
||||
color="white"
|
||||
/>
|
||||
{itemUserData.PlayedPercentage > 0 ? "Resume" : "Play"}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default PlayButton;
|
||||
|
||||
PlayButton.propTypes = {
|
||||
itemId: PropTypes.string.isRequired,
|
||||
itemUserData: PropTypes.object,
|
||||
userId: PropTypes.string.isRequired,
|
||||
itemType: PropTypes.string.isRequired,
|
||||
currentAudioTrack: PropTypes.number.isRequired,
|
||||
currentSubTrack: PropTypes.number.isRequired,
|
||||
currentVideoTrack: PropTypes.number.isRequired,
|
||||
className: PropTypes.string,
|
||||
sx: PropTypes.any,
|
||||
iconProps: PropTypes.any,
|
||||
buttonProps: PropTypes.any,
|
||||
iconOnly: PropTypes.bool,
|
||||
};
|
||||
@@ -207,6 +207,7 @@ export const Card = ({
|
||||
iconProps={{
|
||||
sx: { fontSize: "1.5em" },
|
||||
}}
|
||||
iconOnly
|
||||
/>
|
||||
<LikeButton
|
||||
itemId={item.Id}
|
||||
|
||||
@@ -33,6 +33,7 @@ import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
import { theme } from "../../theme";
|
||||
import { useCarouselStore } from "../../utils/store/carousel";
|
||||
import PlayButton from "../buttons/playButton";
|
||||
|
||||
const CarouselSlide = ({ item }) => {
|
||||
const navigate = useNavigate();
|
||||
@@ -253,40 +254,18 @@ const CarouselSlide = ({ item }) => {
|
||||
className="hero-carousel-button-container"
|
||||
alignItems="center"
|
||||
>
|
||||
<Stack
|
||||
direction="row"
|
||||
gap="1em"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
size="large"
|
||||
disabled
|
||||
startIcon={
|
||||
<MdiPlayOutline
|
||||
sx={{ fontSize: "1.4em" }}
|
||||
/>
|
||||
}
|
||||
sx={{
|
||||
textTransform: "none !important",
|
||||
}}
|
||||
>
|
||||
{item.UserData.PlaybackPositionTicks >
|
||||
0 ? (
|
||||
<Stack
|
||||
direction="column"
|
||||
gap="0.2em"
|
||||
alignItems="flex-start"
|
||||
justifyContent="center"
|
||||
>
|
||||
Resume
|
||||
</Stack>
|
||||
) : (
|
||||
"Play"
|
||||
)}
|
||||
</Button>
|
||||
</Stack>
|
||||
<PlayButton
|
||||
itemId={item.Id}
|
||||
userId={user.data.Id}
|
||||
itemType={item.Type}
|
||||
currentAudioTrack={0}
|
||||
currentSubTrack={0}
|
||||
currentVideoTrack={0}
|
||||
buttonProps={{
|
||||
size: "large",
|
||||
}}
|
||||
itemUserData={item.UserData}
|
||||
/>
|
||||
|
||||
<Button
|
||||
size="large"
|
||||
|
||||
@@ -25,6 +25,7 @@ export const CarouselSkeleton = () => {
|
||||
width: "100vw",
|
||||
height: "100vh",
|
||||
position: "absolute",
|
||||
background: "transparent !important",
|
||||
}}
|
||||
></Skeleton>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user