diff --git a/src/App.jsx b/src/App.jsx index 6702e34..36b8fd2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -275,20 +275,6 @@ function App() { return ( - {pingServer.isLoading && ( - - - - )} - { + return ( + + + + ); +}; diff --git a/src/components/icons/mdiVolumeHigh.jsx b/src/components/icons/mdiVolumeHigh.jsx new file mode 100644 index 0000000..2a5f507 --- /dev/null +++ b/src/components/icons/mdiVolumeHigh.jsx @@ -0,0 +1,13 @@ +/** @format */ + +import SvgIcon from "@mui/material/SvgIcon"; + +import { mdiVolumeHigh } from "@mdi/js"; + +export const MdiVolumeHigh = (props) => { + return ( + + + + ); +}; diff --git a/src/components/icons/mdiVolumeOff.jsx b/src/components/icons/mdiVolumeOff.jsx new file mode 100644 index 0000000..dc0eb00 --- /dev/null +++ b/src/components/icons/mdiVolumeOff.jsx @@ -0,0 +1,13 @@ +/** @format */ + +import SvgIcon from "@mui/material/SvgIcon"; + +import { mdiVolumeOff } from "@mdi/js"; + +export const MdiVolumeOff = (props) => { + return ( + + + + ); +}; diff --git a/src/routes/player/videoPlayer.jsx b/src/routes/player/videoPlayer.jsx index 0fba0f0..6bb3d1f 100644 --- a/src/routes/player/videoPlayer.jsx +++ b/src/routes/player/videoPlayer.jsx @@ -8,6 +8,8 @@ import Stack from "@mui/material/Stack"; import IconButton from "@mui/material/IconButton"; import Typography from "@mui/material/Typography"; import Slider from "@mui/material/Slider"; +import { theme } from "../../theme"; +import Grow from "@mui/material/Grow"; import ReactPlayer from "react-player"; @@ -27,6 +29,9 @@ import { MdiFastForward } from "../../components/icons/mdiFastForward"; import { MdiRewind } from "../../components/icons/mdiRewind"; import { MdiFullscreen } from "../../components/icons/mdiFullscreen"; import { MdiFullscreenExit } from "../../components/icons/mdiFullscreenExit"; +import { MdiPictureInPictureBottomRight } from "../../components/icons/mdiPictureInPictureBottomRight"; +import { MdiVolumeHigh } from "../../components/icons/mdiVolumeHigh"; +import { MdiVolumeOff } from "../../components/icons/mdiVolumeOff"; export const VideoPlayer = () => { const navigate = useNavigate(); @@ -43,12 +48,14 @@ export const VideoPlayer = () => { const [isPlaying, setIsPlaying] = useState(true); const [isMuted, setIsMuted] = useState(false); const [isReady, setIsReady] = useState(false); + const [isPIP, setIsPIP] = useState(false); + const [volume, setVolume] = useState(0.75); + + const [showVolume, setShowVolume] = useState(false); const [duration, setDuration] = useState(0); const [progress, setProgress] = useState(0); - const [currentTime, setCurrentTime] = useState( - (startPosition / itemDuration) * 100, - ); + const [currentTime, setCurrentTime] = useState(startPosition); const onReady = useCallback(() => { if (!isReady) { @@ -67,6 +74,7 @@ export const VideoPlayer = () => { IsMuted: isMuted, PositionTicks: secToTicks(e.playedSeconds), PlaybackStartTimeTicks: startPosition, + VolumeLevel: volume * 100, }, }); }; @@ -89,8 +97,8 @@ export const VideoPlayer = () => { })}`; }; - const handleDisplayItemDuration = () => { - let time = ticksToSec(itemDuration); + const handleDisplayTime = (ticks) => { + let time = ticksToSec(ticks); let hr = Math.floor(time / 3600); time -= hr * 3600; let min = Math.floor(time / 60); @@ -127,7 +135,7 @@ export const VideoPlayer = () => { document .querySelector(".video") .classList.remove("video-osd-visible"); - }, 2000); + }, 3000); }} > { - + { { playerRef.current.seekTo( - (newVal / 100) * - playerRef.current.getDuration(), + ticksToSec(newVal), ); setCurrentTime(newVal); }} + valueLabelDisplay="auto" + valueLabelFormat={(value) => + handleDisplayTime(value) + } + sx={{ + "& .MuiSlider-valueLabel": { + lineHeight: 1.2, + fontSize: 24, + background: "rgb(0 0 0 / 0.5)", + backdropFilter: "blur(30px)", + padding: 1, + borderRadius: "10px", + transform: + "translatey(-120%) scale(0)", + "&:before": { display: "none" }, + "&.MuiSlider-valueLabelOpen": { + transform: + "translateY(-120%) scale(1)", + }, + "& > *": { + transform: "rotate(0deg)", + }, + }, + }} /> - {handleDisplayItemDuration()} + {handleDisplayTime(itemDuration)} - - - playerRef.current.seekTo( - playerRef.current.getCurrentTime() - - 15, - ) - } + + + + playerRef.current.seekTo( + playerRef.current.getCurrentTime() - + 15, + ) + } + > + + + setIsPlaying(!isPlaying)} + > + {isPlaying ? : } + + + playerRef.current.seekTo( + playerRef.current.getCurrentTime() + + 15, + ) + } + > + + + + - - - setIsPlaying(!isPlaying)} - > - {isPlaying ? : } - - - playerRef.current.seekTo( - playerRef.current.getCurrentTime() + - 15, - ) - } - > - - - { - let fstate = - await appWindow.isFullscreen(); - setAppFullScreen(fstate); - await appWindow.setFullscreen(!fstate); - }} - > - {appFullscreen ? ( - - ) : ( - - )} - + setShowVolume(true)} + onMouseOut={() => setShowVolume(false)} + padding="0.25em 1em" + > + + + setVolume(newVal / 100) + } + valueLabelDisplay="auto" + valueLabelFormat={(value) => + Math.floor(value) + } + sx={{ + "& .MuiSlider-valueLabel": + { + lineHeight: 1.2, + fontSize: 24, + background: + "rgb(0 0 0 / 0.5)", + backdropFilter: + "blur(30px)", + padding: 1, + borderRadius: + "10px", + transform: + "translatey(-120%) scale(0)", + "&:before": { + display: "none", + }, + "&.MuiSlider-valueLabelOpen": + { + transform: + "translateY(-120%) scale(1)", + }, + "& > *": { + transform: + "rotate(0deg)", + }, + }, + }} + /> + + + setIsMuted(!isMuted) + } + > + {isMuted ? ( + + ) : ( + + )} + + + { + setIsPIP(!isPIP); + }} + > + + + { + let fstate = + await appWindow.isFullscreen(); + setAppFullScreen(!fstate); + await appWindow.setFullscreen( + !fstate, + ); + }} + > + {appFullscreen ? ( + + ) : ( + + )} + + @@ -240,6 +377,8 @@ export const VideoPlayer = () => { onProgress={onProgress} onReady={onReady} muted={isMuted} + pip={isPIP} + volume={volume} /> );