Fallback to web player if mpv fails to run

This commit is contained in:
jeffvli 2024-02-13 02:05:59 -08:00
parent fb08502e51
commit 9b0c9ba3ac
14 changed files with 115 additions and 70 deletions

View file

@ -3,7 +3,7 @@ import {
useCurrentStatus,
useCurrentTime,
useLyricsSettings,
usePlayerType,
usePlaybackType,
useSeeked,
} from '/@/renderer/store';
import { PlaybackType, PlayerStatus } from '/@/renderer/types';
@ -59,7 +59,7 @@ export const SynchronizedLyrics = ({
}: SynchronizedLyricsProps) => {
const playersRef = PlayersRef;
const status = useCurrentStatus();
const playerType = usePlayerType();
const playbackType = usePlaybackType();
const now = useCurrentTime();
const settings = useLyricsSettings();
@ -96,7 +96,7 @@ export const SynchronizedLyrics = ({
};
const getCurrentTime = useCallback(async () => {
if (isElectron() && playerType !== PlaybackType.WEB) {
if (isElectron() && playbackType !== PlaybackType.WEB) {
if (mpvPlayer) {
return mpvPlayer.getCurrentTime();
}
@ -116,7 +116,7 @@ export const SynchronizedLyrics = ({
if (!player) return 0;
return player.currentTime;
}, [playerType, playersRef]);
}, [playbackType, playersRef]);
const setCurrentLyric = useCallback(
(timeInMs: number, epoch?: number, targetIndex?: number) => {
@ -222,7 +222,7 @@ export const SynchronizedLyrics = ({
}
return () => {};
}, [getCurrentTime, lyrics, playerType, setCurrentLyric, status]);
}, [getCurrentTime, lyrics, playbackType, setCurrentLyric, status]);
useEffect(() => {
// This handler is used to deal with changes to the current delay. If the offset