Update
This commit is contained in:
5 files changed
+94
-41
No files matched your search
@@ -81,7 +81,8 @@
|
|||||||
"decorations": false,
|
"decorations": false,
|
||||||
"resizable": false,
|
"resizable": false,
|
||||||
"url": "splash.html",
|
"url": "splash.html",
|
||||||
"label": "splashscreen"
|
"label": "splashscreen",
|
||||||
|
"title": "JellyPlayer"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import LinearProgress from "@mui/material/LinearProgress";
|
||||||
import { MdiPlayOutline } from "../icons/mdiPlayOutline";
|
import { MdiPlayOutline } from "../icons/mdiPlayOutline";
|
||||||
import {
|
import {
|
||||||
usePlaybackDataLoadStore,
|
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 { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
import { ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
const PlayButton = ({
|
const PlayButton = ({
|
||||||
itemId,
|
itemId,
|
||||||
|
itemUserData,
|
||||||
userId,
|
userId,
|
||||||
itemType,
|
itemType,
|
||||||
currentAudioTrack,
|
currentAudioTrack,
|
||||||
@@ -23,6 +28,8 @@ const PlayButton = ({
|
|||||||
className,
|
className,
|
||||||
sx,
|
sx,
|
||||||
iconProps,
|
iconProps,
|
||||||
|
buttonProps,
|
||||||
|
iconOnly,
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [
|
const [
|
||||||
@@ -46,6 +53,8 @@ const PlayButton = ({
|
|||||||
(state) => state.setIsLoading,
|
(state) => state.setIsLoading,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const item = useMutation({
|
const item = useMutation({
|
||||||
mutationKey: ["playButton", itemId, userId],
|
mutationKey: ["playButton", itemId, userId],
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
@@ -74,7 +83,6 @@ const PlayButton = ({
|
|||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
onSuccess: (item) => {
|
onSuccess: (item) => {
|
||||||
console.log(item);
|
|
||||||
setUrl(
|
setUrl(
|
||||||
`${window.api.basePath}/Videos/${item.Items[0].Id}/stream.
|
`${window.api.basePath}/Videos/${item.Items[0].Id}/stream.
|
||||||
${item.Items[0].MediaSources[0].Container}
|
${item.Items[0].MediaSources[0].Container}
|
||||||
@@ -95,16 +103,79 @@ const PlayButton = ({
|
|||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
setPlaybackDataLoading(false);
|
setPlaybackDataLoading(false);
|
||||||
},
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
enqueueSnackbar(`${error}`, {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const handleClick = (e) => {
|
const handleClick = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
item.mutate();
|
item.mutate();
|
||||||
};
|
};
|
||||||
return (
|
if (iconOnly) {
|
||||||
<IconButton className={className} onClick={handleClick} sx={sx}>
|
return (
|
||||||
<MdiPlayOutline {...iconProps} />
|
<IconButton
|
||||||
</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;
|
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={{
|
iconProps={{
|
||||||
sx: { fontSize: "1.5em" },
|
sx: { fontSize: "1.5em" },
|
||||||
}}
|
}}
|
||||||
|
iconOnly
|
||||||
/>
|
/>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import LikeButton from "../buttons/likeButton";
|
|||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import { theme } from "../../theme";
|
import { theme } from "../../theme";
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
|
import PlayButton from "../buttons/playButton";
|
||||||
|
|
||||||
const CarouselSlide = ({ item }) => {
|
const CarouselSlide = ({ item }) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -253,40 +254,18 @@ const CarouselSlide = ({ item }) => {
|
|||||||
className="hero-carousel-button-container"
|
className="hero-carousel-button-container"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Stack
|
<PlayButton
|
||||||
direction="row"
|
itemId={item.Id}
|
||||||
gap="1em"
|
userId={user.data.Id}
|
||||||
alignItems="center"
|
itemType={item.Type}
|
||||||
justifyContent="center"
|
currentAudioTrack={0}
|
||||||
>
|
currentSubTrack={0}
|
||||||
<Button
|
currentVideoTrack={0}
|
||||||
variant="contained"
|
buttonProps={{
|
||||||
size="large"
|
size: "large",
|
||||||
disabled
|
}}
|
||||||
startIcon={
|
itemUserData={item.UserData}
|
||||||
<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>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="large"
|
size="large"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const CarouselSkeleton = () => {
|
|||||||
width: "100vw",
|
width: "100vw",
|
||||||
height: "100vh",
|
height: "100vh",
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
|
background: "transparent !important",
|
||||||
}}
|
}}
|
||||||
></Skeleton>
|
></Skeleton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user