Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f4c2f990a | ||
|
|
027cf93492 | ||
|
|
092a1c74ab | ||
|
|
fb7c86631d |
No files matched your search
Generated
+3
-11
@@ -20,6 +20,7 @@
|
||||
"@tanstack/react-query-devtools": "^4.29.3",
|
||||
"@tauri-apps/api": "^1.2.0",
|
||||
"@videojs/http-streaming": "^3.0.2",
|
||||
"axios": "^1.4.0",
|
||||
"blurhash": "^2.0.5",
|
||||
"events": "^3.3.0",
|
||||
"framer-motion": "^10.12.4",
|
||||
@@ -1892,14 +1893,12 @@
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"peer": true
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
|
||||
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
@@ -2084,7 +2083,6 @@
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
@@ -2164,7 +2162,6 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
@@ -2302,7 +2299,6 @@
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
@@ -2316,7 +2312,6 @@
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
@@ -2682,7 +2677,6 @@
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -2691,7 +2685,6 @@
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
@@ -2948,8 +2941,7 @@
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"peer": true
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "18.2.0",
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"@tanstack/react-query-devtools": "^4.29.3",
|
||||
"@tauri-apps/api": "^1.2.0",
|
||||
"@videojs/http-streaming": "^3.0.2",
|
||||
"axios": "^1.4.0",
|
||||
"blurhash": "^2.0.5",
|
||||
"events": "^3.3.0",
|
||||
"framer-motion": "^10.12.4",
|
||||
|
||||
@@ -17,8 +17,10 @@ tauri-build = { version = "1.2.1", features = [] }
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
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-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]
|
||||
# by default Tauri runs in production mode
|
||||
|
||||
+34
-2
@@ -2,6 +2,8 @@
|
||||
|
||||
use tauri::Manager;
|
||||
|
||||
use tauri::{utils::config::AppUrl, WindowUrl};
|
||||
|
||||
// Create the command:
|
||||
// This command must be async so that it doesn't run on the main thread.
|
||||
#[tauri::command]
|
||||
@@ -14,10 +16,40 @@ async fn close_splashscreen(window: tauri::Window) {
|
||||
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() {
|
||||
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])
|
||||
.plugin(tauri_plugin_store::Builder::default().build())
|
||||
.run(tauri::generate_context!())
|
||||
.run(context)
|
||||
.expect("error while running tauri application");
|
||||
// tauri::Builder::default()
|
||||
// .run(tauri::generate_context!())
|
||||
// .expect("error while running tauri application");
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
"all": false,
|
||||
"process": {
|
||||
"all": false,
|
||||
"exit": true,
|
||||
@@ -24,6 +23,9 @@
|
||||
},
|
||||
"shell": {
|
||||
"all": true
|
||||
},
|
||||
"http": {
|
||||
"all": true
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
|
||||
+27
-31
@@ -7,7 +7,7 @@ import Konami from "react-konami-code";
|
||||
const Kon = Konami.default ? Konami.default : Konami;
|
||||
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import { SnackbarProvider } from "notistack";
|
||||
import { SnackbarProvider, useSnackbar } from "notistack";
|
||||
import {
|
||||
Routes,
|
||||
Route,
|
||||
@@ -59,11 +59,17 @@ import { AppBar } from "./components/appBar/appBar.jsx";
|
||||
import "@fontsource/open-sans";
|
||||
|
||||
// Jellyfin SDK TypeScript
|
||||
import { Jellyfin } from "@jellyfin/sdk";
|
||||
import {
|
||||
Jellyfin,
|
||||
VersionOutdatedIssue,
|
||||
VersionUnsupportedIssue,
|
||||
} from "@jellyfin/sdk";
|
||||
import { version as appVer } from "../package.json";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { delServer, getServer } from "./utils/storage/servers.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({
|
||||
clientInfo: {
|
||||
@@ -123,7 +129,8 @@ function App() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [serverReachable, setServerReachable] = useState(true);
|
||||
const [checkingServer, setChecking] = useState(false);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const createApi = async () => {
|
||||
const server = await getServer();
|
||||
@@ -158,33 +165,24 @@ function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const pingServer = () => {
|
||||
setChecking(true);
|
||||
let data;
|
||||
fetch(`${window.api.basePath}/System/Ping`, {
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.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" },
|
||||
);
|
||||
setServerReachable(false);
|
||||
setChecking(false);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
enqueueSnackbar("Unable to reach server", {
|
||||
variant: "error",
|
||||
});
|
||||
const pingServer = async () => {
|
||||
const server = await getServer();
|
||||
try {
|
||||
const result = await axios.get(
|
||||
new URL(`${server.Ip}/System/Ping`).href,
|
||||
);
|
||||
if (result.data == "Jellyfin Server") {
|
||||
event.emit("create-jellyfin-api", server.Ip);
|
||||
setServerReachable(true);
|
||||
} else {
|
||||
setServerReachable(false);
|
||||
setChecking(false);
|
||||
}
|
||||
} catch (error) {
|
||||
setServerReachable(false);
|
||||
enqueueSnackbar("Unable to verfiy server address.", {
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const userLogin = async () => {
|
||||
@@ -227,7 +225,6 @@ function App() {
|
||||
});
|
||||
} else {
|
||||
navigate("/setup/server");
|
||||
setChecking(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -277,7 +274,7 @@ function App() {
|
||||
return (
|
||||
<SnackbarProvider maxSnack={5}>
|
||||
<ThemeProvider theme={theme}>
|
||||
{checkingServer && (
|
||||
{pingServer.isLoading && (
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
@@ -309,7 +306,6 @@ function App() {
|
||||
<Dialog
|
||||
open={!serverReachable}
|
||||
onClose={handleRelaunch}
|
||||
disableBa
|
||||
aria-labelledby="alert-dialog-text"
|
||||
aria-describedby="alert-dialog-desc"
|
||||
maxWidth="md"
|
||||
|
||||
@@ -10,19 +10,17 @@ import "./avatar.module.scss";
|
||||
export const AvatarImage = ({ userId, userImageTags }) => {
|
||||
return (
|
||||
<Box className="avatar-image-container">
|
||||
{!!userImageTags && (
|
||||
<div
|
||||
className="avatar-image"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url('" +
|
||||
window.api.basePath +
|
||||
"/Users/" +
|
||||
userId +
|
||||
"/Images/Primary')",
|
||||
}}
|
||||
></div>
|
||||
)}
|
||||
<div
|
||||
className="avatar-image"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url('" +
|
||||
window.api.basePath +
|
||||
"/Users/" +
|
||||
userId +
|
||||
"/Images/Primary')",
|
||||
}}
|
||||
></div>
|
||||
|
||||
<div className="avatar-image-icon-container">
|
||||
<MdiAccount className="avatar-image-icon" />
|
||||
|
||||
@@ -48,6 +48,7 @@ export const Card = ({
|
||||
blurhash,
|
||||
currentUser,
|
||||
favourite,
|
||||
disableOverlay,
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const [imgLoading, setImgLoading] = useState(true);
|
||||
@@ -175,6 +176,7 @@ export const Card = ({
|
||||
<div
|
||||
className="card-media-image-container"
|
||||
style={{ opacity: imgLoading ? 0 : 1 }}
|
||||
// style={{ opacity: 1 }}
|
||||
>
|
||||
{imageTags &&
|
||||
(cardType == "thumb" ? (
|
||||
@@ -210,10 +212,17 @@ export const Card = ({
|
||||
<CardMedia
|
||||
component="img"
|
||||
image={
|
||||
window.api.basePath +
|
||||
"/Items/" +
|
||||
itemId +
|
||||
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
|
||||
iconType == "User"
|
||||
? window.api
|
||||
.basePath +
|
||||
"/Users/" +
|
||||
itemId +
|
||||
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
|
||||
: window.api
|
||||
.basePath +
|
||||
"/Items/" +
|
||||
itemId +
|
||||
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
|
||||
}
|
||||
alt={itemName}
|
||||
sx={{
|
||||
@@ -275,56 +284,66 @@ export const Card = ({
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
<Box
|
||||
className="card-media-overlay"
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "flex-end",
|
||||
justifyContent: "flex-end",
|
||||
p: 1,
|
||||
}}
|
||||
>
|
||||
<ButtonGroup>
|
||||
{availableMarkButtonTypes.includes(
|
||||
iconType,
|
||||
) && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleMarkAsPlayOrUnMarkAsPlay();
|
||||
}}
|
||||
onFocus={(e) => e.stopPropagation}
|
||||
>
|
||||
<MdiCheck
|
||||
sx={{
|
||||
color: isWatched
|
||||
? green[400]
|
||||
: "white",
|
||||
{!disableOverlay && (
|
||||
<Box
|
||||
className="card-media-overlay"
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "flex-end",
|
||||
justifyContent: "flex-end",
|
||||
p: 1,
|
||||
}}
|
||||
>
|
||||
<ButtonGroup>
|
||||
{availableMarkButtonTypes.includes(
|
||||
iconType,
|
||||
) && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleMarkAsPlayOrUnMarkAsPlay();
|
||||
}}
|
||||
/>
|
||||
</IconButton>
|
||||
)}
|
||||
{allowedLikeButton.includes(iconType) && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleLiking();
|
||||
}}
|
||||
onFocus={(e) => e.stopPropagation}
|
||||
>
|
||||
{isFavorite ? (
|
||||
<MdiHeart
|
||||
sx={{ color: pink[700] }}
|
||||
onFocus={(e) =>
|
||||
e.stopPropagation
|
||||
}
|
||||
>
|
||||
<MdiCheck
|
||||
sx={{
|
||||
color: isWatched
|
||||
? green[400]
|
||||
: "white",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<MdiHeartOutline />
|
||||
)}
|
||||
</IconButton>
|
||||
)}
|
||||
</ButtonGroup>
|
||||
</Box>
|
||||
</IconButton>
|
||||
)}
|
||||
{allowedLikeButton.includes(
|
||||
iconType,
|
||||
) && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleLiking();
|
||||
}}
|
||||
onFocus={(e) =>
|
||||
e.stopPropagation
|
||||
}
|
||||
>
|
||||
{isFavorite ? (
|
||||
<MdiHeart
|
||||
sx={{
|
||||
color: pink[700],
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<MdiHeartOutline />
|
||||
)}
|
||||
</IconButton>
|
||||
)}
|
||||
</ButtonGroup>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<CardContent
|
||||
|
||||
@@ -23,6 +23,7 @@ import { MdiAccountMusic } from "../icons/mdiAccountMusic";
|
||||
import { MdiDramaMasks } from "../icons/mdiDramaMasks";
|
||||
import { MdiMusic } from "../icons/mdiMusic";
|
||||
import { MdiAccountTie } from "../icons/mdiAccountTie";
|
||||
import { MdiAccount } from "../icons/mdiAccount";
|
||||
|
||||
export const MediaCollectionTypeIconCollection = {
|
||||
universal: <MdiMultimedia />,
|
||||
@@ -97,6 +98,7 @@ export const TypeIconCollectionCard = {
|
||||
Trailer: <MdiYoutube className="card-image-icon" />,
|
||||
TvChannel: <MdiTelevisionClassic className="card-image-icon" />,
|
||||
TvProgram: <MdiTelevisionClassic className="card-image-icon" />,
|
||||
User: <MdiAccount className="card-image-icon" />,
|
||||
UserRootFolder: <MdiFolderOutline className="card-image-icon" />,
|
||||
UserView: <MdiMultimedia className="card-image-icon" />,
|
||||
Video: <MdiFilmstrip className="card-image-icon" />,
|
||||
|
||||
+8
-2
@@ -11,11 +11,17 @@ import App from "./App";
|
||||
|
||||
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(
|
||||
<React.StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<QueryClientProvider client={queryClient} option>
|
||||
<Router>
|
||||
<App />
|
||||
</Router>
|
||||
|
||||
@@ -287,8 +287,8 @@ export const UserLogin = () => {
|
||||
imageTags={
|
||||
!!item.PrimaryImageTag
|
||||
}
|
||||
// cardType="sqaure"
|
||||
iconType="Person"
|
||||
disableOverlay
|
||||
iconType="User"
|
||||
cardOrientation="sqaure"
|
||||
onClickEvent={() =>
|
||||
navigate(
|
||||
|
||||
@@ -7,6 +7,7 @@ import Box from "@mui/material/Box";
|
||||
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 ReactPlayer from "react-player";
|
||||
|
||||
@@ -33,16 +34,22 @@ export const VideoPlayer = () => {
|
||||
const [isMuted, setIsMuted] = 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(() => {
|
||||
if (!isReady) {
|
||||
const timeToStart = ticksToSec(startPosition);
|
||||
playerRef.current.seekTo(timeToStart, "seconds");
|
||||
setDuration(playerRef.current.getDuration());
|
||||
setIsReady(true);
|
||||
}
|
||||
}, [isReady]);
|
||||
|
||||
const startTime = new Date(0);
|
||||
|
||||
const onProgress = async (e) => {
|
||||
console.log(e);
|
||||
await getPlaystateApi(window.api).reportPlaybackProgress({
|
||||
playbackProgressInfo: {
|
||||
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(
|
||||
(state) => [
|
||||
state.url,
|
||||
@@ -109,28 +121,48 @@ export const VideoPlayer = () => {
|
||||
</Typography>
|
||||
</Toolbar>
|
||||
</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 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
|
||||
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>
|
||||
</Stack>
|
||||
<ReactPlayer
|
||||
@@ -139,7 +171,6 @@ export const VideoPlayer = () => {
|
||||
height="100vh"
|
||||
playing={isPlaying}
|
||||
url={url}
|
||||
// controls={true}
|
||||
onProgress={onProgress}
|
||||
onReady={onReady}
|
||||
muted={isMuted}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import axios from "axios";
|
||||
|
||||
import { EventEmitter as event } from "../../../eventEmitter.js";
|
||||
import { setServer } from "../../../utils/storage/servers.js";
|
||||
@@ -20,8 +21,17 @@ import { mdiChevronRight } from "@mdi/js";
|
||||
|
||||
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
|
||||
import "./server.module.scss";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
export const ServerList = () => {
|
||||
const [renderServerList, setRenderServerList] = useState(false);
|
||||
@@ -118,6 +128,17 @@ export const ServerList = () => {
|
||||
};
|
||||
|
||||
export const ServerSetup = (props) => {
|
||||
const sdk = new Jellyfin({
|
||||
clientInfo: {
|
||||
name: "JellyPlayer",
|
||||
version: appVer,
|
||||
},
|
||||
deviceInfo: {
|
||||
name: "JellyPlayer",
|
||||
id: uuidv4(),
|
||||
},
|
||||
});
|
||||
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
const [checkingServer, setServerCheckState] = useState(false);
|
||||
|
||||
@@ -127,15 +148,7 @@ export const ServerSetup = (props) => {
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
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 usersAvailable = async () => {};
|
||||
const addServer = async () => {
|
||||
event.emit("create-jellyfin-api", serverIp);
|
||||
let sysInfo = await getSystemApi(window.api).getPublicSystemInfo();
|
||||
@@ -144,57 +157,75 @@ export const ServerSetup = (props) => {
|
||||
// Set Server Config to Tauri store
|
||||
sysInfo.Ip = serverIp;
|
||||
setServer(sysInfo);
|
||||
|
||||
const usersAvailablity = await usersAvailable();
|
||||
if (usersAvailablity == true) {
|
||||
console.log(usersAvailablity);
|
||||
navigate("/login/users");
|
||||
} else {
|
||||
navigate("/login/manual");
|
||||
};
|
||||
const checkServer = async () => {
|
||||
setServerCheckState(true);
|
||||
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");
|
||||
} else {
|
||||
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 = () => {
|
||||
setLoading(true);
|
||||
let data;
|
||||
fetch(`${serverIp}/System/Ping`, {
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
if (data == "Jellyfin Server") {
|
||||
addServer();
|
||||
setLoading(false);
|
||||
return true;
|
||||
} else {
|
||||
enqueueSnackbar(
|
||||
"The server address does not seem be a jellyfin server",
|
||||
{ variant: "error" },
|
||||
);
|
||||
setLoading(false);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
setLoading(false);
|
||||
enqueueSnackbar(
|
||||
"Unable to verify whether the give address is a valid Jellyfin server",
|
||||
{ variant: "error" },
|
||||
);
|
||||
console.error(error);
|
||||
});
|
||||
// setLoading(true);
|
||||
// let data;
|
||||
// fetch(`${serverIp}/System/Ping`, {
|
||||
// body: JSON.stringify(data),
|
||||
// })
|
||||
// .then((res) => res.json())
|
||||
// .then((data) => {
|
||||
// if (data == "Jellyfin Server") {
|
||||
// addServer();
|
||||
// setLoading(false);
|
||||
// return true;
|
||||
// } else {
|
||||
// enqueueSnackbar(
|
||||
// "The server address does not seem be a jellyfin server",
|
||||
// { variant: "error" },
|
||||
// );
|
||||
// setLoading(false);
|
||||
// return false;
|
||||
// }
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// setLoading(false);
|
||||
// enqueueSnackbar(
|
||||
// "Unable to verify whether the give address is a valid Jellyfin server",
|
||||
// { variant: "error" },
|
||||
// );
|
||||
// console.error(error);
|
||||
// });
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container
|
||||
maxWidth="sm"
|
||||
className={
|
||||
checkingServer
|
||||
? "centered serverContainer loading"
|
||||
: "centered serverContainer"
|
||||
}
|
||||
>
|
||||
<Container maxWidth="sm" className={"centered serverContainer"}>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
@@ -212,22 +243,9 @@ export const ServerSetup = (props) => {
|
||||
variant="outlined"
|
||||
// inputRef={serverIp}
|
||||
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>
|
||||
</Grid>
|
||||
<Grid item xl={5} md={6} sx={{ width: "100%" }}>
|
||||
@@ -235,14 +253,14 @@ export const ServerSetup = (props) => {
|
||||
variant="contained"
|
||||
sx={{ width: "100%" }}
|
||||
size="large"
|
||||
loading={loading}
|
||||
loading={checkingServer}
|
||||
endIcon={
|
||||
<SvgIcon>
|
||||
<path d={mdiChevronRight}></path>
|
||||
</SvgIcon>
|
||||
}
|
||||
loadingPosition="end"
|
||||
onClick={handleAddServer}
|
||||
onClick={() => checkServer()}
|
||||
>
|
||||
Add Server
|
||||
</LoadingButton>
|
||||
|
||||
Reference in new issue
Block a user