Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f4c2f990a | ||
|
|
027cf93492 |
No files matched your search
@@ -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": {
|
||||
|
||||
+18
-54
@@ -130,7 +130,7 @@ function App() {
|
||||
|
||||
const [serverReachable, setServerReachable] = useState(true);
|
||||
|
||||
const enqueueSnackbar = useSnackbar();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const createApi = async () => {
|
||||
const server = await getServer();
|
||||
@@ -165,60 +165,25 @@ function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const pingServer = useQuery({
|
||||
queryKey: ["setup", "server"],
|
||||
queryFn: async () => {
|
||||
let serverUrl = window.api.basePath.replace(/\/$/, "").trim();
|
||||
const candidates =
|
||||
await jellyfin.discovery.getRecommendedServerCandidates(
|
||||
serverUrl,
|
||||
);
|
||||
const best = jellyfin.discovery.findBestServer(candidates);
|
||||
if (best) {
|
||||
const issues = candidates.flatMap((s) => s.issues);
|
||||
if (
|
||||
issues.some(
|
||||
(i) =>
|
||||
i instanceof VersionOutdatedIssue ||
|
||||
i instanceof VersionUnsupportedIssue,
|
||||
)
|
||||
) {
|
||||
setServerReachable(false);
|
||||
enqueueSnackbar(
|
||||
"Please Update your server to latest Jellyfin version to use this client",
|
||||
);
|
||||
}
|
||||
try {
|
||||
const api = sdk.createApi(best.address);
|
||||
const { data } = await getSystemApi(
|
||||
api,
|
||||
).getPublicSystemInfo();
|
||||
delete data.LocalAddress;
|
||||
const serv = {
|
||||
...data,
|
||||
PublicAddress: best.address,
|
||||
isDefault: false,
|
||||
};
|
||||
if (serv.StartupWizardCompleted) {
|
||||
setServerReachable(true);
|
||||
} else {
|
||||
setServerReachable(false);
|
||||
enqueueSnackbar(
|
||||
"Server setup not complete. Please complete your server setup.",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(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);
|
||||
enqueueSnackbar("Server not found.", { variant: "error" });
|
||||
}
|
||||
return "";
|
||||
},
|
||||
// enabled: false,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
} catch (error) {
|
||||
setServerReachable(false);
|
||||
enqueueSnackbar("Unable to verfiy server address.", {
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const userLogin = async () => {
|
||||
const user = await getUser();
|
||||
@@ -234,7 +199,7 @@ function App() {
|
||||
serverAvailable().then(async (server) => {
|
||||
if (server == true) {
|
||||
createApi().then(() => {
|
||||
pingServer.refetch();
|
||||
pingServer();
|
||||
if (serverReachable == true) {
|
||||
userSaved().then((user_available) => {
|
||||
if (user_available == true) {
|
||||
@@ -341,7 +306,6 @@ function App() {
|
||||
<Dialog
|
||||
open={!serverReachable}
|
||||
onClose={handleRelaunch}
|
||||
disableBa
|
||||
aria-labelledby="alert-dialog-text"
|
||||
aria-describedby="alert-dialog-desc"
|
||||
maxWidth="md"
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -158,77 +158,39 @@ export const ServerSetup = (props) => {
|
||||
sysInfo.Ip = serverIp;
|
||||
setServer(sysInfo);
|
||||
};
|
||||
|
||||
const checkServer = useQuery({
|
||||
queryKey: ["setup", "server"],
|
||||
queryFn: async () => {
|
||||
let serverUrl = serverIp.replace(/\/$/, "").trim();
|
||||
const candidates =
|
||||
await sdk.discovery.getRecommendedServerCandidates(
|
||||
serverUrl,
|
||||
);
|
||||
const best = sdk.discovery.findBestServer(candidates);
|
||||
if (best) {
|
||||
const issues = candidates.flatMap((s) => s.issues);
|
||||
if (
|
||||
issues.some(
|
||||
(i) =>
|
||||
i instanceof VersionOutdatedIssue ||
|
||||
i instanceof VersionUnsupportedIssue,
|
||||
)
|
||||
) {
|
||||
enqueueSnackbar(
|
||||
"Please Update your server to latest Jellyfin version to use this client",
|
||||
);
|
||||
}
|
||||
try {
|
||||
const api = sdk.createApi(best.address);
|
||||
const { data } = await getSystemApi(
|
||||
api,
|
||||
).getPublicSystemInfo();
|
||||
delete data.LocalAddress;
|
||||
const serv = {
|
||||
...data,
|
||||
PublicAddress: best.address,
|
||||
isDefault: false,
|
||||
};
|
||||
if (serv.StartupWizardCompleted) {
|
||||
event.emit("create-jellyfin-api", serverIp);
|
||||
data.Ip = serverIp;
|
||||
setServer(data);
|
||||
const users = await getUserApi(
|
||||
window.api,
|
||||
).getPublicUsers();
|
||||
if (users.data.length >= 1) {
|
||||
navigate("/login/users");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
navigate("/login/manual");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
enqueueSnackbar(
|
||||
"Server setup not complete. Please complete your server setup.",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
enqueueSnackbar("Something went wrong", {
|
||||
variant: "error",
|
||||
});
|
||||
console.error(error);
|
||||
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(
|
||||
"Server not found. Please check you entered address",
|
||||
"The provided ip address doesn't seem point to a Jellyfin server.",
|
||||
{ variant: "error" },
|
||||
);
|
||||
}
|
||||
return "";
|
||||
},
|
||||
enabled: false,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
} catch (error) {
|
||||
enqueueSnackbar("Unable to verfiy server address.", {
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
|
||||
setServerCheckState(false);
|
||||
return "";
|
||||
};
|
||||
|
||||
const handleAddServer = () => {
|
||||
// setLoading(true);
|
||||
@@ -291,14 +253,14 @@ export const ServerSetup = (props) => {
|
||||
variant="contained"
|
||||
sx={{ width: "100%" }}
|
||||
size="large"
|
||||
loading={checkServer.isFetching}
|
||||
loading={checkingServer}
|
||||
endIcon={
|
||||
<SvgIcon>
|
||||
<path d={mdiChevronRight}></path>
|
||||
</SvgIcon>
|
||||
}
|
||||
loadingPosition="end"
|
||||
onClick={() => checkServer.refetch()}
|
||||
onClick={() => checkServer()}
|
||||
>
|
||||
Add Server
|
||||
</LoadingButton>
|
||||
|
||||
Reference in new issue
Block a user