Show endsAt and fix mouseOver in player #10
This commit is contained in:
2 files changed
+43
-33
No files matched your search
@@ -5,6 +5,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<script src="http://localhost:8097"></script>
|
||||||
<title>Jellyplayer</title>
|
<title>Jellyplayer</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import Slider from "@mui/material/Slider";
|
import Slider from "@mui/material/Slider";
|
||||||
import { theme } from "../../theme";
|
import { theme } from "../../theme";
|
||||||
import Grow from "@mui/material/Grow";
|
import Grow from "@mui/material/Grow";
|
||||||
|
import Backdrop from "@mui/material/Backdrop";
|
||||||
|
|
||||||
import ReactPlayer from "react-player";
|
import ReactPlayer from "react-player";
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ import { MdiArrowLeft } from "../../components/icons/mdiArrowLeft";
|
|||||||
import { MdiPlay } from "../../components/icons/mdiPlay";
|
import { MdiPlay } from "../../components/icons/mdiPlay";
|
||||||
|
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useRef, useState, useCallback } from "react";
|
import { useRef, useState, useCallback, useEffect } from "react";
|
||||||
import { secToTicks, ticksToSec } from "../../utils/date/time";
|
import { secToTicks, ticksToSec } from "../../utils/date/time";
|
||||||
|
|
||||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||||
@@ -33,6 +34,8 @@ import { MdiPictureInPictureBottomRight } from "../../components/icons/mdiPictur
|
|||||||
import { MdiVolumeHigh } from "../../components/icons/mdiVolumeHigh";
|
import { MdiVolumeHigh } from "../../components/icons/mdiVolumeHigh";
|
||||||
import { MdiVolumeOff } from "../../components/icons/mdiVolumeOff";
|
import { MdiVolumeOff } from "../../components/icons/mdiVolumeOff";
|
||||||
|
|
||||||
|
import { endsAt } from "../../utils/date/time";
|
||||||
|
|
||||||
export const VideoPlayer = () => {
|
export const VideoPlayer = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [url, startPosition, itemDuration, itemId, itemName] =
|
const [url, startPosition, itemDuration, itemId, itemName] =
|
||||||
@@ -44,6 +47,8 @@ export const VideoPlayer = () => {
|
|||||||
state.itemName,
|
state.itemName,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const [showControls, setShowControls] = useState(false);
|
||||||
|
|
||||||
const playerRef = useRef();
|
const playerRef = useRef();
|
||||||
const [isPlaying, setIsPlaying] = useState(true);
|
const [isPlaying, setIsPlaying] = useState(true);
|
||||||
const [isMuted, setIsMuted] = useState(false);
|
const [isMuted, setIsMuted] = useState(false);
|
||||||
@@ -115,42 +120,36 @@ export const VideoPlayer = () => {
|
|||||||
})}`;
|
})}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSeeking = useCallback((time, offset) => {
|
|
||||||
playerRef.current.seekTo(time / 100);
|
|
||||||
setCurrentTime(time / 100);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const [appFullscreen, setAppFullScreen] = useState(false);
|
const [appFullscreen, setAppFullScreen] = useState(false);
|
||||||
|
|
||||||
let timer;
|
useEffect(() => {
|
||||||
|
let timeout = null;
|
||||||
|
if (showControls) {
|
||||||
|
window.clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
setShowControls(false);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
}, [showControls]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className="video"
|
className="video"
|
||||||
sx={{ background: "black" }}
|
sx={{ background: "black" }}
|
||||||
onMouseMove={(e) => {
|
onMouseMove={() => {
|
||||||
let a = "he";
|
setShowControls(true);
|
||||||
clearTimeout(timer);
|
|
||||||
e.currentTarget.classList.add("video-osd-visible");
|
|
||||||
timer = setTimeout(() => {
|
|
||||||
document
|
|
||||||
.querySelector(".video")
|
|
||||||
.classList.remove("video-osd-visible");
|
|
||||||
}, 3000);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack
|
<Backdrop
|
||||||
className="video-osd"
|
className="video-osd"
|
||||||
sx={{
|
sx={{
|
||||||
position: "fixed",
|
display: "flex",
|
||||||
top: 0,
|
flexDirection: "column",
|
||||||
left: 0,
|
zIndex: 100000,
|
||||||
right: 0,
|
justifyContent: "space-between",
|
||||||
bottom: 0,
|
background: "transparent",
|
||||||
}}
|
}}
|
||||||
alignItems="center"
|
open={showControls}
|
||||||
justifyContent="space-between"
|
|
||||||
direction="column"
|
|
||||||
zIndex="10000000"
|
|
||||||
>
|
>
|
||||||
<AppBar
|
<AppBar
|
||||||
position="static"
|
position="static"
|
||||||
@@ -193,6 +192,9 @@ export const VideoPlayer = () => {
|
|||||||
step={0.01}
|
step={0.01}
|
||||||
max={itemDuration}
|
max={itemDuration}
|
||||||
onChange={(e, newVal) => {
|
onChange={(e, newVal) => {
|
||||||
|
setCurrentTime(newVal);
|
||||||
|
}}
|
||||||
|
onChangeCommitted={(e, newVal) => {
|
||||||
playerRef.current.seekTo(
|
playerRef.current.seekTo(
|
||||||
ticksToSec(newVal),
|
ticksToSec(newVal),
|
||||||
);
|
);
|
||||||
@@ -207,7 +209,7 @@ export const VideoPlayer = () => {
|
|||||||
lineHeight: 1.2,
|
lineHeight: 1.2,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
background: "rgb(0 0 0 / 0.5)",
|
background: "rgb(0 0 0 / 0.5)",
|
||||||
backdropFilter: "blur(30px)",
|
backdropFilter: "blur(5px)",
|
||||||
padding: 1,
|
padding: 1,
|
||||||
borderRadius: "10px",
|
borderRadius: "10px",
|
||||||
transform:
|
transform:
|
||||||
@@ -232,7 +234,12 @@ export const VideoPlayer = () => {
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Stack direction="row" gap={1}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={1}
|
||||||
|
justifyContent="center"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
playerRef.current.seekTo(
|
playerRef.current.seekTo(
|
||||||
@@ -258,6 +265,9 @@ export const VideoPlayer = () => {
|
|||||||
>
|
>
|
||||||
<MdiFastForward />
|
<MdiFastForward />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
<Typography variant="subtitle1">
|
||||||
|
{endsAt(itemDuration - currentTime)}
|
||||||
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -275,9 +285,8 @@ export const VideoPlayer = () => {
|
|||||||
transition: "250ms background",
|
transition: "250ms background",
|
||||||
borderRadius: 20,
|
borderRadius: 20,
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
background:
|
background: "rgb(0 0 0/0.5)",
|
||||||
theme.palette.background
|
backdropFilter: "blur(5px)",
|
||||||
.paper,
|
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onMouseOver={() => setShowVolume(true)}
|
onMouseOver={() => setShowVolume(true)}
|
||||||
@@ -304,7 +313,7 @@ export const VideoPlayer = () => {
|
|||||||
background:
|
background:
|
||||||
"rgb(0 0 0 / 0.5)",
|
"rgb(0 0 0 / 0.5)",
|
||||||
backdropFilter:
|
backdropFilter:
|
||||||
"blur(30px)",
|
"blur(5px)",
|
||||||
padding: 1,
|
padding: 1,
|
||||||
borderRadius:
|
borderRadius:
|
||||||
"10px",
|
"10px",
|
||||||
@@ -367,7 +376,7 @@ export const VideoPlayer = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Backdrop>
|
||||||
<ReactPlayer
|
<ReactPlayer
|
||||||
ref={playerRef}
|
ref={playerRef}
|
||||||
width="100vw"
|
width="100vw"
|
||||||
|
|||||||
Reference in new issue
Block a user