Compare commits

...
13 changed files with 224 additions and 125 deletions

No files matched your search

+3 -11
View File
@@ -20,6 +20,7 @@
"@tanstack/react-query-devtools": "^4.29.3", "@tanstack/react-query-devtools": "^4.29.3",
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0",
"@videojs/http-streaming": "^3.0.2", "@videojs/http-streaming": "^3.0.2",
"axios": "^1.4.0",
"blurhash": "^2.0.5", "blurhash": "^2.0.5",
"events": "^3.3.0", "events": "^3.3.0",
"framer-motion": "^10.12.4", "framer-motion": "^10.12.4",
@@ -1892,14 +1893,12 @@
"node_modules/asynckit": { "node_modules/asynckit": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
"peer": true
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"peer": true,
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.0", "follow-redirects": "^1.15.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
@@ -2084,7 +2083,6 @@
"version": "1.0.8", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"peer": true,
"dependencies": { "dependencies": {
"delayed-stream": "~1.0.0" "delayed-stream": "~1.0.0"
}, },
@@ -2164,7 +2162,6 @@
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"peer": true,
"engines": { "engines": {
"node": ">=0.4.0" "node": ">=0.4.0"
} }
@@ -2302,7 +2299,6 @@
"url": "https://github.com/sponsors/RubenVerborgh" "url": "https://github.com/sponsors/RubenVerborgh"
} }
], ],
"peer": true,
"engines": { "engines": {
"node": ">=4.0" "node": ">=4.0"
}, },
@@ -2316,7 +2312,6 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"peer": true,
"dependencies": { "dependencies": {
"asynckit": "^0.4.0", "asynckit": "^0.4.0",
"combined-stream": "^1.0.8", "combined-stream": "^1.0.8",
@@ -2682,7 +2677,6 @@
"version": "1.52.0", "version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"peer": true,
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
@@ -2691,7 +2685,6 @@
"version": "2.1.35", "version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"peer": true,
"dependencies": { "dependencies": {
"mime-db": "1.52.0" "mime-db": "1.52.0"
}, },
@@ -2948,8 +2941,7 @@
"node_modules/proxy-from-env": { "node_modules/proxy-from-env": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
"peer": true
}, },
"node_modules/react": { "node_modules/react": {
"version": "18.2.0", "version": "18.2.0",
+1
View File
@@ -21,6 +21,7 @@
"@tanstack/react-query-devtools": "^4.29.3", "@tanstack/react-query-devtools": "^4.29.3",
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0",
"@videojs/http-streaming": "^3.0.2", "@videojs/http-streaming": "^3.0.2",
"axios": "^1.4.0",
"blurhash": "^2.0.5", "blurhash": "^2.0.5",
"events": "^3.3.0", "events": "^3.3.0",
"framer-motion": "^10.12.4", "framer-motion": "^10.12.4",
+3 -1
View File
@@ -17,8 +17,10 @@ tauri-build = { version = "1.2.1", features = [] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2.2", features = ["process-exit", "process-relaunch", "shell-all", "window-set-fullscreen"] } tauri = { version = "1.2.2", features = ["api-all", "devtools"] }
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
portpicker = "0.1" # used in the example to pick a random free port
[features] [features]
# by default Tauri runs in production mode # by default Tauri runs in production mode
+34 -2
View File
@@ -2,6 +2,8 @@
use tauri::Manager; use tauri::Manager;
use tauri::{utils::config::AppUrl, WindowUrl};
// Create the command: // Create the command:
// This command must be async so that it doesn't run on the main thread. // This command must be async so that it doesn't run on the main thread.
#[tauri::command] #[tauri::command]
@@ -14,10 +16,40 @@ async fn close_splashscreen(window: tauri::Window) {
window.get_window("main").unwrap().show().unwrap(); window.get_window("main").unwrap().show().unwrap();
} }
// Tauri by default uses HTTPS, so use the localhost plugin to downgrade back to
// HTTP. However, when running tauri dev, we already have a localhost server
// provided by vite, so don't enable it
#[cfg(debug_assertions)]
const USE_LOCALHOST_SERVER: bool = false;
#[cfg(not(debug_assertions))]
const USE_LOCALHOST_SERVER: bool = true;
fn main() { fn main() {
tauri::Builder::default() let port = portpicker::pick_unused_port().expect("failed to find unused port");
let window_url = if USE_LOCALHOST_SERVER {
WindowUrl::External(format!("http://localhost:{}", port).parse().unwrap())
} else {
WindowUrl::App("index.html".into())
};
let mut context = tauri::generate_context!();
let mut builder = tauri::Builder::default();
if USE_LOCALHOST_SERVER {
// rewrite the config so the IPC is enabled on this URL
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
context.config_mut().build.dev_path = AppUrl::Url(window_url.clone());
builder = builder.plugin(tauri_plugin_localhost::Builder::new(port).build());
}
builder
.invoke_handler(tauri::generate_handler![close_splashscreen]) .invoke_handler(tauri::generate_handler![close_splashscreen])
.plugin(tauri_plugin_store::Builder::default().build()) .plugin(tauri_plugin_store::Builder::default().build())
.run(tauri::generate_context!()) .run(context)
.expect("error while running tauri application"); .expect("error while running tauri application");
// tauri::Builder::default()
// .run(tauri::generate_context!())
// .expect("error while running tauri application");
} }
+3 -1
View File
@@ -12,7 +12,6 @@
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {
"all": false,
"process": { "process": {
"all": false, "all": false,
"exit": true, "exit": true,
@@ -24,6 +23,9 @@
}, },
"shell": { "shell": {
"all": true "all": true
},
"http": {
"all": true
} }
}, },
"bundle": { "bundle": {
+24 -28
View File
@@ -7,7 +7,7 @@ import Konami from "react-konami-code";
const Kon = Konami.default ? Konami.default : Konami; const Kon = Konami.default ? Konami.default : Konami;
import { ThemeProvider } from "@mui/material/styles"; import { ThemeProvider } from "@mui/material/styles";
import { SnackbarProvider } from "notistack"; import { SnackbarProvider, useSnackbar } from "notistack";
import { import {
Routes, Routes,
Route, Route,
@@ -59,11 +59,17 @@ import { AppBar } from "./components/appBar/appBar.jsx";
import "@fontsource/open-sans"; import "@fontsource/open-sans";
// Jellyfin SDK TypeScript // Jellyfin SDK TypeScript
import { Jellyfin } from "@jellyfin/sdk"; import {
Jellyfin,
VersionOutdatedIssue,
VersionUnsupportedIssue,
} from "@jellyfin/sdk";
import { version as appVer } from "../package.json"; import { version as appVer } from "../package.json";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { delServer, getServer } from "./utils/storage/servers.js"; import { delServer, getServer } from "./utils/storage/servers.js";
import { delUser, getUser } from "./utils/storage/user.js"; import { delUser, getUser } from "./utils/storage/user.js";
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api.js";
import { useQuery } from "@tanstack/react-query";
const jellyfin = new Jellyfin({ const jellyfin = new Jellyfin({
clientInfo: { clientInfo: {
@@ -123,7 +129,8 @@ function App() {
const navigate = useNavigate(); const navigate = useNavigate();
const [serverReachable, setServerReachable] = useState(true); const [serverReachable, setServerReachable] = useState(true);
const [checkingServer, setChecking] = useState(false);
const { enqueueSnackbar } = useSnackbar();
const createApi = async () => { const createApi = async () => {
const server = await getServer(); const server = await getServer();
@@ -158,33 +165,24 @@ function App() {
} }
}; };
const pingServer = () => { const pingServer = async () => {
setChecking(true); const server = await getServer();
let data; try {
fetch(`${window.api.basePath}/System/Ping`, { const result = await axios.get(
body: JSON.stringify(data), new URL(`${server.Ip}/System/Ping`).href,
})
.then((res) => res.json())
.then((data) => {
if (data == "Jellyfin Server") {
setServerReachable(true);
setChecking(false);
} else {
enqueueSnackbar(
"The server address does not seem be a jellyfin server",
{ variant: "error" },
); );
if (result.data == "Jellyfin Server") {
event.emit("create-jellyfin-api", server.Ip);
setServerReachable(true);
} else {
setServerReachable(false); setServerReachable(false);
setChecking(false);
} }
}) } catch (error) {
.catch((error) => { setServerReachable(false);
enqueueSnackbar("Unable to reach server", { enqueueSnackbar("Unable to verfiy server address.", {
variant: "error", variant: "error",
}); });
setServerReachable(false); }
setChecking(false);
});
}; };
const userLogin = async () => { const userLogin = async () => {
@@ -227,7 +225,6 @@ function App() {
}); });
} else { } else {
navigate("/setup/server"); navigate("/setup/server");
setChecking(false);
} }
}); });
}; };
@@ -277,7 +274,7 @@ function App() {
return ( return (
<SnackbarProvider maxSnack={5}> <SnackbarProvider maxSnack={5}>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
{checkingServer && ( {pingServer.isLoading && (
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
@@ -309,7 +306,6 @@ function App() {
<Dialog <Dialog
open={!serverReachable} open={!serverReachable}
onClose={handleRelaunch} onClose={handleRelaunch}
disableBa
aria-labelledby="alert-dialog-text" aria-labelledby="alert-dialog-text"
aria-describedby="alert-dialog-desc" aria-describedby="alert-dialog-desc"
maxWidth="md" maxWidth="md"
-2
View File
@@ -10,7 +10,6 @@ import "./avatar.module.scss";
export const AvatarImage = ({ userId, userImageTags }) => { export const AvatarImage = ({ userId, userImageTags }) => {
return ( return (
<Box className="avatar-image-container"> <Box className="avatar-image-container">
{!!userImageTags && (
<div <div
className="avatar-image" className="avatar-image"
style={{ style={{
@@ -22,7 +21,6 @@ export const AvatarImage = ({ userId, userImageTags }) => {
"/Images/Primary')", "/Images/Primary')",
}} }}
></div> ></div>
)}
<div className="avatar-image-icon-container"> <div className="avatar-image-icon-container">
<MdiAccount className="avatar-image-icon" /> <MdiAccount className="avatar-image-icon" />
+24 -5
View File
@@ -48,6 +48,7 @@ export const Card = ({
blurhash, blurhash,
currentUser, currentUser,
favourite, favourite,
disableOverlay,
}) => { }) => {
const navigate = useNavigate(); const navigate = useNavigate();
const [imgLoading, setImgLoading] = useState(true); const [imgLoading, setImgLoading] = useState(true);
@@ -175,6 +176,7 @@ export const Card = ({
<div <div
className="card-media-image-container" className="card-media-image-container"
style={{ opacity: imgLoading ? 0 : 1 }} style={{ opacity: imgLoading ? 0 : 1 }}
// style={{ opacity: 1 }}
> >
{imageTags && {imageTags &&
(cardType == "thumb" ? ( (cardType == "thumb" ? (
@@ -210,7 +212,14 @@ export const Card = ({
<CardMedia <CardMedia
component="img" component="img"
image={ image={
window.api.basePath + iconType == "User"
? window.api
.basePath +
"/Users/" +
itemId +
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
: window.api
.basePath +
"/Items/" + "/Items/" +
itemId + itemId +
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96" "/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
@@ -275,6 +284,7 @@ export const Card = ({
/> />
)} )}
</> </>
{!disableOverlay && (
<Box <Box
className="card-media-overlay" className="card-media-overlay"
sx={{ sx={{
@@ -294,7 +304,9 @@ export const Card = ({
e.stopPropagation(); e.stopPropagation();
handleMarkAsPlayOrUnMarkAsPlay(); handleMarkAsPlayOrUnMarkAsPlay();
}} }}
onFocus={(e) => e.stopPropagation} onFocus={(e) =>
e.stopPropagation
}
> >
<MdiCheck <MdiCheck
sx={{ sx={{
@@ -305,18 +317,24 @@ export const Card = ({
/> />
</IconButton> </IconButton>
)} )}
{allowedLikeButton.includes(iconType) && ( {allowedLikeButton.includes(
iconType,
) && (
<IconButton <IconButton
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
handleLiking(); handleLiking();
}} }}
onFocus={(e) => e.stopPropagation} onFocus={(e) =>
e.stopPropagation
}
> >
{isFavorite ? ( {isFavorite ? (
<MdiHeart <MdiHeart
sx={{ color: pink[700] }} sx={{
color: pink[700],
}}
/> />
) : ( ) : (
<MdiHeartOutline /> <MdiHeartOutline />
@@ -325,6 +343,7 @@ export const Card = ({
)} )}
</ButtonGroup> </ButtonGroup>
</Box> </Box>
)}
</Box> </Box>
<CardContent <CardContent
+2
View File
@@ -23,6 +23,7 @@ import { MdiAccountMusic } from "../icons/mdiAccountMusic";
import { MdiDramaMasks } from "../icons/mdiDramaMasks"; import { MdiDramaMasks } from "../icons/mdiDramaMasks";
import { MdiMusic } from "../icons/mdiMusic"; import { MdiMusic } from "../icons/mdiMusic";
import { MdiAccountTie } from "../icons/mdiAccountTie"; import { MdiAccountTie } from "../icons/mdiAccountTie";
import { MdiAccount } from "../icons/mdiAccount";
export const MediaCollectionTypeIconCollection = { export const MediaCollectionTypeIconCollection = {
universal: <MdiMultimedia />, universal: <MdiMultimedia />,
@@ -97,6 +98,7 @@ export const TypeIconCollectionCard = {
Trailer: <MdiYoutube className="card-image-icon" />, Trailer: <MdiYoutube className="card-image-icon" />,
TvChannel: <MdiTelevisionClassic className="card-image-icon" />, TvChannel: <MdiTelevisionClassic className="card-image-icon" />,
TvProgram: <MdiTelevisionClassic className="card-image-icon" />, TvProgram: <MdiTelevisionClassic className="card-image-icon" />,
User: <MdiAccount className="card-image-icon" />,
UserRootFolder: <MdiFolderOutline className="card-image-icon" />, UserRootFolder: <MdiFolderOutline className="card-image-icon" />,
UserView: <MdiMultimedia className="card-image-icon" />, UserView: <MdiMultimedia className="card-image-icon" />,
Video: <MdiFilmstrip className="card-image-icon" />, Video: <MdiFilmstrip className="card-image-icon" />,
+8 -2
View File
@@ -11,11 +11,17 @@ import App from "./App";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
const queryClient = new QueryClient(); const queryClient = new QueryClient({
defaultOptions: {
queries: {
networkMode: "always",
},
},
});
ReactDOM.createRoot(document.getElementById("root")).render( ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode> <React.StrictMode>
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient} option>
<Router> <Router>
<App /> <App />
</Router> </Router>
+2 -2
View File
@@ -287,8 +287,8 @@ export const UserLogin = () => {
imageTags={ imageTags={
!!item.PrimaryImageTag !!item.PrimaryImageTag
} }
// cardType="sqaure" disableOverlay
iconType="Person" iconType="User"
cardOrientation="sqaure" cardOrientation="sqaure"
onClickEvent={() => onClickEvent={() =>
navigate( navigate(
+37 -6
View File
@@ -7,6 +7,7 @@ import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack"; 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 ReactPlayer from "react-player"; import ReactPlayer from "react-player";
@@ -33,16 +34,22 @@ export const VideoPlayer = () => {
const [isMuted, setIsMuted] = useState(false); const [isMuted, setIsMuted] = useState(false);
const [isReady, setIsReady] = useState(false); const [isReady, setIsReady] = useState(false);
const [duration, setDuration] = useState(0);
const [progress, setProgress] = useState(0);
const [currentTime, setCurrentTime] = useState(0);
const onReady = useCallback(() => { const onReady = useCallback(() => {
if (!isReady) { if (!isReady) {
const timeToStart = ticksToSec(startPosition); const timeToStart = ticksToSec(startPosition);
playerRef.current.seekTo(timeToStart, "seconds"); playerRef.current.seekTo(timeToStart, "seconds");
setDuration(playerRef.current.getDuration());
setIsReady(true); setIsReady(true);
} }
}, [isReady]); }, [isReady]);
const startTime = new Date(0);
const onProgress = async (e) => { const onProgress = async (e) => {
console.log(e);
await getPlaystateApi(window.api).reportPlaybackProgress({ await getPlaystateApi(window.api).reportPlaybackProgress({
playbackProgressInfo: { playbackProgressInfo: {
ItemId: itemId, ItemId: itemId,
@@ -53,6 +60,11 @@ export const VideoPlayer = () => {
}); });
}; };
const handleSeeking = useCallback((time, offset) => {
playerRef.current.seekTo(time / 100);
setCurrentTime(time / 100);
}, []);
const [url, startPosition, itemId, itemName] = usePlaybackStore( const [url, startPosition, itemId, itemName] = usePlaybackStore(
(state) => [ (state) => [
state.url, state.url,
@@ -109,23 +121,42 @@ export const VideoPlayer = () => {
</Typography> </Typography>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
<Stack padding={2} direction="row"> <Stack direction="column" padding={2} width="100%">
<Stack width="100%">
<Slider
value={currentTime}
step={0.01}
max={100}
onChange={(e, newVal) => {
playerRef.current.seekTo(
(newVal / 100) *
playerRef.current.getDuration(),
);
setCurrentTime(newVal);
}}
/>
</Stack>
<Stack direction="row">
<IconButton <IconButton
onClick={() => onClick={() =>
playerRef.current.seekTo( playerRef.current.seekTo(
playerRef.current.getCurrentTime() - 15, playerRef.current.getCurrentTime() -
15,
) )
} }
> >
<MdiRewind /> <MdiRewind />
</IconButton> </IconButton>
<IconButton onClick={() => setIsPlaying(!isPlaying)}> <IconButton
onClick={() => setIsPlaying(!isPlaying)}
>
{isPlaying ? <MdiPause /> : <MdiPlay />} {isPlaying ? <MdiPause /> : <MdiPlay />}
</IconButton> </IconButton>
<IconButton <IconButton
onClick={() => onClick={() =>
playerRef.current.seekTo( playerRef.current.seekTo(
playerRef.current.getCurrentTime() + 15, playerRef.current.getCurrentTime() +
15,
) )
} }
> >
@@ -133,13 +164,13 @@ export const VideoPlayer = () => {
</IconButton> </IconButton>
</Stack> </Stack>
</Stack> </Stack>
</Stack>
<ReactPlayer <ReactPlayer
ref={playerRef} ref={playerRef}
width="100vw" width="100vw"
height="100vh" height="100vh"
playing={isPlaying} playing={isPlaying}
url={url} url={url}
// controls={true}
onProgress={onProgress} onProgress={onProgress}
onReady={onReady} onReady={onReady}
muted={isMuted} muted={isMuted}
+83 -65
View File
@@ -2,6 +2,7 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import axios from "axios";
import { EventEmitter as event } from "../../../eventEmitter.js"; import { EventEmitter as event } from "../../../eventEmitter.js";
import { setServer } from "../../../utils/storage/servers.js"; import { setServer } from "../../../utils/storage/servers.js";
@@ -20,8 +21,17 @@ import { mdiChevronRight } from "@mdi/js";
import { useSnackbar } from "notistack"; import { useSnackbar } from "notistack";
import {
Jellyfin,
VersionOutdatedIssue,
VersionUnsupportedIssue,
} from "@jellyfin/sdk";
import { version as appVer } from "../../../../package.json";
import { v4 as uuidv4 } from "uuid";
// SCSS // SCSS
import "./server.module.scss"; import "./server.module.scss";
import { useQuery } from "@tanstack/react-query";
export const ServerList = () => { export const ServerList = () => {
const [renderServerList, setRenderServerList] = useState(false); const [renderServerList, setRenderServerList] = useState(false);
@@ -118,6 +128,17 @@ export const ServerList = () => {
}; };
export const ServerSetup = (props) => { export const ServerSetup = (props) => {
const sdk = new Jellyfin({
clientInfo: {
name: "JellyPlayer",
version: appVer,
},
deviceInfo: {
name: "JellyPlayer",
id: uuidv4(),
},
});
const [serverIp, setServerIp] = useState(""); const [serverIp, setServerIp] = useState("");
const [checkingServer, setServerCheckState] = useState(false); const [checkingServer, setServerCheckState] = useState(false);
@@ -127,15 +148,7 @@ export const ServerSetup = (props) => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const usersAvailable = async () => { const usersAvailable = async () => {};
const users = await getUserApi(window.api).getPublicUsers();
if (users.data.length >= 1) {
console.log("Users => ", users.data);
return true;
} else {
return false;
}
};
const addServer = async () => { const addServer = async () => {
event.emit("create-jellyfin-api", serverIp); event.emit("create-jellyfin-api", serverIp);
let sysInfo = await getSystemApi(window.api).getPublicSystemInfo(); let sysInfo = await getSystemApi(window.api).getPublicSystemInfo();
@@ -144,57 +157,75 @@ export const ServerSetup = (props) => {
// Set Server Config to Tauri store // Set Server Config to Tauri store
sysInfo.Ip = serverIp; sysInfo.Ip = serverIp;
setServer(sysInfo); setServer(sysInfo);
};
const usersAvailablity = await usersAvailable(); const checkServer = async () => {
if (usersAvailablity == true) { setServerCheckState(true);
console.log(usersAvailablity); try {
const result = await axios.get(`${serverIp}/System/Ping`);
if (result.data == "Jellyfin Server") {
event.emit("create-jellyfin-api", serverIp);
let sysInfo = await getSystemApi(
window.api,
).getPublicSystemInfo();
sysInfo = sysInfo.data;
sysInfo.Ip = serverIp;
setServer(sysInfo);
const users = await getUserApi(window.api).getPublicUsers();
if (users.data.length >= 1) {
navigate("/login/users"); navigate("/login/users");
} else { } else {
navigate("/login/manual"); navigate("/login/manual");
} }
} else {
enqueueSnackbar(
"The provided ip address doesn't seem point to a Jellyfin server.",
{ variant: "error" },
);
}
} catch (error) {
enqueueSnackbar("Unable to verfiy server address.", {
variant: "error",
});
}
setServerCheckState(false);
return "";
}; };
const handleAddServer = () => { const handleAddServer = () => {
setLoading(true); // setLoading(true);
let data; // let data;
fetch(`${serverIp}/System/Ping`, { // fetch(`${serverIp}/System/Ping`, {
body: JSON.stringify(data), // body: JSON.stringify(data),
}) // })
.then((res) => res.json()) // .then((res) => res.json())
.then((data) => { // .then((data) => {
if (data == "Jellyfin Server") { // if (data == "Jellyfin Server") {
addServer(); // addServer();
setLoading(false); // setLoading(false);
return true; // return true;
} else { // } else {
enqueueSnackbar( // enqueueSnackbar(
"The server address does not seem be a jellyfin server", // "The server address does not seem be a jellyfin server",
{ variant: "error" }, // { variant: "error" },
); // );
setLoading(false); // setLoading(false);
return false; // return false;
} // }
}) // })
.catch((error) => { // .catch((error) => {
setLoading(false); // setLoading(false);
enqueueSnackbar( // enqueueSnackbar(
"Unable to verify whether the give address is a valid Jellyfin server", // "Unable to verify whether the give address is a valid Jellyfin server",
{ variant: "error" }, // { variant: "error" },
); // );
console.error(error); // console.error(error);
}); // });
}; };
return ( return (
<> <>
<Container <Container maxWidth="sm" className={"centered serverContainer"}>
maxWidth="sm"
className={
checkingServer
? "centered serverContainer loading"
: "centered serverContainer"
}
>
<Grid <Grid
container container
spacing={2} spacing={2}
@@ -212,22 +243,9 @@ export const ServerSetup = (props) => {
variant="outlined" variant="outlined"
// inputRef={serverIp} // inputRef={serverIp}
onChange={(event) => { onChange={(event) => {
if (
event.target.value.charAt(
event.target.value.length - 1,
) == "/"
) {
setServerIp(
event.target.value.slice(
0,
-1,
),
);
} else {
setServerIp(event.target.value); setServerIp(event.target.value);
}
}} }}
helperText="Add your server adddress with https:// or http://" helperText="Add your server adddress with https:// or http://. Eg: https://demo.jellyfin.org"
></TextField> ></TextField>
</Grid> </Grid>
<Grid item xl={5} md={6} sx={{ width: "100%" }}> <Grid item xl={5} md={6} sx={{ width: "100%" }}>
@@ -235,14 +253,14 @@ export const ServerSetup = (props) => {
variant="contained" variant="contained"
sx={{ width: "100%" }} sx={{ width: "100%" }}
size="large" size="large"
loading={loading} loading={checkingServer}
endIcon={ endIcon={
<SvgIcon> <SvgIcon>
<path d={mdiChevronRight}></path> <path d={mdiChevronRight}></path>
</SvgIcon> </SvgIcon>
} }
loadingPosition="end" loadingPosition="end"
onClick={handleAddServer} onClick={() => checkServer()}
> >
Add Server Add Server
</LoadingButton> </LoadingButton>