Start implementing player Ui #10

This commit is contained in:
prayag17 committed 2023-05-10 18:06:49 +05:30
1 parent 989542107f
commit 7137cbc13e
5 files changed
+111 -4

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
/** @format */
import SvgIcon from "@mui/material/SvgIcon";
import { mdiFastForward } from "@mdi/js";
export const MdiFastForward = (props) => {
return (
<SvgIcon {...props}>
<path d={mdiFastForward}></path>
</SvgIcon>
);
};
+12
View File
@@ -0,0 +1,12 @@
/** @format */
import SvgIcon from "@mui/material/SvgIcon";
import { mdiPause } from "@mdi/js";
export const MdiPause = (props) => {
return (
<SvgIcon {...props}>
<path d={mdiPause}></path>
</SvgIcon>
);
};
+12
View File
@@ -0,0 +1,12 @@
/** @format */
import SvgIcon from "@mui/material/SvgIcon";
import { mdiRewind } from "@mdi/js";
export const MdiRewind = (props) => {
return (
<SvgIcon {...props}>
<path d={mdiRewind}></path>
</SvgIcon>
);
};
+64 -4
View File
@@ -4,6 +4,7 @@ import { appWindow } from "@tauri-apps/api/window";
import AppBar from "@mui/material/AppBar"; import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar"; import Toolbar from "@mui/material/Toolbar";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
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";
@@ -11,6 +12,7 @@ import ReactPlayer from "react-player";
import { usePlaybackStore } from "../../utils/store/playback"; import { usePlaybackStore } from "../../utils/store/playback";
import { MdiArrowLeft } from "../../components/icons/mdiArrowLeft"; import { MdiArrowLeft } from "../../components/icons/mdiArrowLeft";
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 } from "react";
@@ -18,6 +20,11 @@ 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";
import "./videoPlayer.module.scss";
import { MdiPause } from "../../components/icons/mdiPause";
import { MdiFastForward } from "../../components/icons/mdiFastForward";
import { MdiRewind } from "../../components/icons/mdiRewind";
export const VideoPlayer = () => { export const VideoPlayer = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -54,10 +61,39 @@ export const VideoPlayer = () => {
state.itemName, state.itemName,
], ],
); );
let timer;
return ( return (
<Box sx={{ background: "black" }}> <Box
className="video"
sx={{ background: "black" }}
onMouseMove={(e) => {
let a = "he";
clearTimeout(timer);
e.currentTarget.classList.add("video-osd-visible");
timer = setTimeout(() => {
document
.querySelector(".video")
.classList.remove("video-osd-visible");
}, 2000);
}}
>
<Stack
className="video-osd"
sx={{
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
alignItems="center"
justifyContent="space-between"
direction="column"
zIndex="10000000"
>
<AppBar <AppBar
position="fixed" position="static"
elevation={0} elevation={0}
sx={{ sx={{
background: background:
@@ -73,13 +109,37 @@ export const VideoPlayer = () => {
</Typography> </Typography>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
<Stack padding={2} direction="row">
<IconButton
onClick={() =>
playerRef.current.seekTo(
playerRef.current.getCurrentTime() - 15,
)
}
>
<MdiRewind />
</IconButton>
<IconButton onClick={() => setIsPlaying(!isPlaying)}>
{isPlaying ? <MdiPause /> : <MdiPlay />}
</IconButton>
<IconButton
onClick={() =>
playerRef.current.seekTo(
playerRef.current.getCurrentTime() + 15,
)
}
>
<MdiFastForward />
</IconButton>
</Stack>
</Stack>
<ReactPlayer <ReactPlayer
ref={playerRef} ref={playerRef}
width="100vw" width="100vw"
height="100vh" height="100vh"
playing={true} playing={isPlaying}
url={url} url={url}
controls={true} // controls={true}
onProgress={onProgress} onProgress={onProgress}
onReady={onReady} onReady={onReady}
muted={isMuted} muted={isMuted}
+11
View File
@@ -0,0 +1,11 @@
/** @format */
.video {
&-osd {
opacity: 0;
transition: opacity 0.1s linear;
}
&-osd-visible &-osd {
opacity: 1;
}
}