mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Fallback to web player if mpv fails to run
This commit is contained in:
parent
fb08502e51
commit
9b0c9ba3ac
14 changed files with 115 additions and 70 deletions
|
|
@ -2,14 +2,16 @@ import { useMemo, useEffect } from 'react';
|
|||
import isElectron from 'is-electron';
|
||||
import { Navigate, Outlet } from 'react-router-dom';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { useCurrentServer, useSetPlayerFallback } from '/@/renderer/store';
|
||||
import { toast } from '/@/renderer/components';
|
||||
|
||||
const ipc = isElectron() ? window.electron.ipc : null;
|
||||
const utils = isElectron() ? window.electron.utils : null;
|
||||
const mpvPlayerListener = isElectron() ? window.electron.mpvPlayerListener : null;
|
||||
|
||||
export const AppOutlet = () => {
|
||||
const currentServer = useCurrentServer();
|
||||
const setFallback = useSetPlayerFallback();
|
||||
|
||||
const isActionsRequired = useMemo(() => {
|
||||
const isServerRequired = !currentServer;
|
||||
|
|
@ -25,10 +27,15 @@ export const AppOutlet = () => {
|
|||
toast.show(data);
|
||||
});
|
||||
|
||||
mpvPlayerListener?.rendererPlayerFallback((_event, data) => {
|
||||
setFallback(data);
|
||||
});
|
||||
|
||||
return () => {
|
||||
ipc?.removeAllListeners('toast-from-main');
|
||||
ipc?.removeAllListeners('renderer-player-fallback');
|
||||
};
|
||||
}, []);
|
||||
}, [setFallback]);
|
||||
|
||||
if (isActionsRequired) {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue