Allow changing volume #10
This commit is contained in:
5 files changed
+193
-30
No files matched your search
-14
@@ -275,20 +275,6 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<SnackbarProvider maxSnack={5}>
|
<SnackbarProvider maxSnack={5}>
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
{pingServer.isLoading && (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
width: "100%",
|
|
||||||
height: "100vh",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CircularProgress />
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Kon resetDelay={1000} action={sixtyNine}></Kon>
|
<Kon resetDelay={1000} action={sixtyNine}></Kon>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={easterEgg}
|
open={easterEgg}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/** @format */
|
||||||
|
import SvgIcon from "@mui/material/SvgIcon";
|
||||||
|
|
||||||
|
import { mdiPictureInPictureBottomRight } from "@mdi/js";
|
||||||
|
|
||||||
|
export const MdiPictureInPictureBottomRight = (props) => {
|
||||||
|
return (
|
||||||
|
<SvgIcon {...props}>
|
||||||
|
<path d={mdiPictureInPictureBottomRight}></path>
|
||||||
|
</SvgIcon>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
import SvgIcon from "@mui/material/SvgIcon";
|
||||||
|
|
||||||
|
import { mdiVolumeHigh } from "@mdi/js";
|
||||||
|
|
||||||
|
export const MdiVolumeHigh = (props) => {
|
||||||
|
return (
|
||||||
|
<SvgIcon {...props}>
|
||||||
|
<path d={mdiVolumeHigh}></path>
|
||||||
|
</SvgIcon>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
import SvgIcon from "@mui/material/SvgIcon";
|
||||||
|
|
||||||
|
import { mdiVolumeOff } from "@mdi/js";
|
||||||
|
|
||||||
|
export const MdiVolumeOff = (props) => {
|
||||||
|
return (
|
||||||
|
<SvgIcon {...props}>
|
||||||
|
<path d={mdiVolumeOff}></path>
|
||||||
|
</SvgIcon>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -8,6 +8,8 @@ import Stack from "@mui/material/Stack";
|
|||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Slider from "@mui/material/Slider";
|
import Slider from "@mui/material/Slider";
|
||||||
|
import { theme } from "../../theme";
|
||||||
|
import Grow from "@mui/material/Grow";
|
||||||
|
|
||||||
import ReactPlayer from "react-player";
|
import ReactPlayer from "react-player";
|
||||||
|
|
||||||
@@ -27,6 +29,9 @@ import { MdiFastForward } from "../../components/icons/mdiFastForward";
|
|||||||
import { MdiRewind } from "../../components/icons/mdiRewind";
|
import { MdiRewind } from "../../components/icons/mdiRewind";
|
||||||
import { MdiFullscreen } from "../../components/icons/mdiFullscreen";
|
import { MdiFullscreen } from "../../components/icons/mdiFullscreen";
|
||||||
import { MdiFullscreenExit } from "../../components/icons/mdiFullscreenExit";
|
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 = () => {
|
export const VideoPlayer = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -43,12 +48,14 @@ export const VideoPlayer = () => {
|
|||||||
const [isPlaying, setIsPlaying] = useState(true);
|
const [isPlaying, setIsPlaying] = useState(true);
|
||||||
const [isMuted, setIsMuted] = useState(false);
|
const [isMuted, setIsMuted] = useState(false);
|
||||||
const [isReady, setIsReady] = 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 [duration, setDuration] = useState(0);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [currentTime, setCurrentTime] = useState(
|
const [currentTime, setCurrentTime] = useState(startPosition);
|
||||||
(startPosition / itemDuration) * 100,
|
|
||||||
);
|
|
||||||
|
|
||||||
const onReady = useCallback(() => {
|
const onReady = useCallback(() => {
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
@@ -67,6 +74,7 @@ export const VideoPlayer = () => {
|
|||||||
IsMuted: isMuted,
|
IsMuted: isMuted,
|
||||||
PositionTicks: secToTicks(e.playedSeconds),
|
PositionTicks: secToTicks(e.playedSeconds),
|
||||||
PlaybackStartTimeTicks: startPosition,
|
PlaybackStartTimeTicks: startPosition,
|
||||||
|
VolumeLevel: volume * 100,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -89,8 +97,8 @@ export const VideoPlayer = () => {
|
|||||||
})}`;
|
})}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDisplayItemDuration = () => {
|
const handleDisplayTime = (ticks) => {
|
||||||
let time = ticksToSec(itemDuration);
|
let time = ticksToSec(ticks);
|
||||||
let hr = Math.floor(time / 3600);
|
let hr = Math.floor(time / 3600);
|
||||||
time -= hr * 3600;
|
time -= hr * 3600;
|
||||||
let min = Math.floor(time / 60);
|
let min = Math.floor(time / 60);
|
||||||
@@ -127,7 +135,7 @@ export const VideoPlayer = () => {
|
|||||||
document
|
document
|
||||||
.querySelector(".video")
|
.querySelector(".video")
|
||||||
.classList.remove("video-osd-visible");
|
.classList.remove("video-osd-visible");
|
||||||
}, 2000);
|
}, 3000);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -161,7 +169,15 @@ export const VideoPlayer = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<Stack direction="column" padding={2} width="100%">
|
<Stack
|
||||||
|
direction="column"
|
||||||
|
padding={2}
|
||||||
|
width="100%"
|
||||||
|
sx={{
|
||||||
|
background:
|
||||||
|
"linear-gradient(to top, rgb(0 0 0 / 0.75), transparent)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Stack
|
<Stack
|
||||||
width="100%"
|
width="100%"
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -175,20 +191,48 @@ export const VideoPlayer = () => {
|
|||||||
<Slider
|
<Slider
|
||||||
value={currentTime}
|
value={currentTime}
|
||||||
step={0.01}
|
step={0.01}
|
||||||
max={100}
|
max={itemDuration}
|
||||||
onChange={(e, newVal) => {
|
onChange={(e, newVal) => {
|
||||||
playerRef.current.seekTo(
|
playerRef.current.seekTo(
|
||||||
(newVal / 100) *
|
ticksToSec(newVal),
|
||||||
playerRef.current.getDuration(),
|
|
||||||
);
|
);
|
||||||
setCurrentTime(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)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Typography variant="h6">
|
<Typography variant="h6">
|
||||||
{handleDisplayItemDuration()}
|
{handleDisplayTime(itemDuration)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Stack direction="row" gap={1}>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
playerRef.current.seekTo(
|
playerRef.current.seekTo(
|
||||||
@@ -214,23 +258,116 @@ export const VideoPlayer = () => {
|
|||||||
>
|
>
|
||||||
<MdiFastForward />
|
<MdiFastForward />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={1}
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
width="15em"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
gap={1}
|
||||||
|
sx={{
|
||||||
|
transition: "250ms background",
|
||||||
|
borderRadius: 20,
|
||||||
|
"&:hover": {
|
||||||
|
background:
|
||||||
|
theme.palette.background
|
||||||
|
.paper,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
onMouseOver={() => setShowVolume(true)}
|
||||||
|
onMouseOut={() => setShowVolume(false)}
|
||||||
|
padding="0.25em 1em"
|
||||||
|
>
|
||||||
|
<Grow in={showVolume}>
|
||||||
|
<Slider
|
||||||
|
value={volume * 100}
|
||||||
|
step={1}
|
||||||
|
max={100}
|
||||||
|
onChange={(e, newVal) =>
|
||||||
|
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)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Grow>
|
||||||
|
<IconButton
|
||||||
|
sx={{
|
||||||
|
ml: 0.1,
|
||||||
|
}}
|
||||||
|
onClick={() =>
|
||||||
|
setIsMuted(!isMuted)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{isMuted ? (
|
||||||
|
<MdiVolumeOff />
|
||||||
|
) : (
|
||||||
|
<MdiVolumeHigh />
|
||||||
|
)}
|
||||||
|
</IconButton>
|
||||||
|
</Stack>
|
||||||
|
<IconButton
|
||||||
|
onClick={() => {
|
||||||
|
setIsPIP(!isPIP);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MdiPictureInPictureBottomRight />
|
||||||
|
</IconButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
let fstate =
|
let fstate =
|
||||||
await appWindow.isFullscreen();
|
await appWindow.isFullscreen();
|
||||||
setAppFullScreen(fstate);
|
setAppFullScreen(!fstate);
|
||||||
await appWindow.setFullscreen(!fstate);
|
await appWindow.setFullscreen(
|
||||||
|
!fstate,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{appFullscreen ? (
|
{appFullscreen ? (
|
||||||
<MdiFullscreen />
|
|
||||||
) : (
|
|
||||||
<MdiFullscreenExit />
|
<MdiFullscreenExit />
|
||||||
|
) : (
|
||||||
|
<MdiFullscreen />
|
||||||
)}
|
)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
</Stack>
|
||||||
<ReactPlayer
|
<ReactPlayer
|
||||||
ref={playerRef}
|
ref={playerRef}
|
||||||
width="100vw"
|
width="100vw"
|
||||||
@@ -240,6 +377,8 @@ export const VideoPlayer = () => {
|
|||||||
onProgress={onProgress}
|
onProgress={onProgress}
|
||||||
onReady={onReady}
|
onReady={onReady}
|
||||||
muted={isMuted}
|
muted={isMuted}
|
||||||
|
pip={isPIP}
|
||||||
|
volume={volume}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user