mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 21:10:12 +02:00
fix mpv progress interval still running after queue ends
This commit is contained in:
@@ -437,10 +437,18 @@ ipcMain.on('player-mute', async (_event, mute: boolean) => {
|
||||
|
||||
ipcMain.handle('player-get-time', async (): Promise<number | undefined> => {
|
||||
try {
|
||||
return getMpvInstance()?.getTimePosition();
|
||||
const mpv = getMpvInstance();
|
||||
if (!mpv) {
|
||||
return undefined;
|
||||
}
|
||||
return await mpv.getTimePosition();
|
||||
} catch (err: any | NodeMpvError) {
|
||||
// Err 3: IPC command invalid — e.g. time-pos unavailable when idle / between tracks
|
||||
if (err?.errcode === 3) {
|
||||
return undefined;
|
||||
}
|
||||
mpvLog({ action: `Failed to get current time` }, err);
|
||||
return 0;
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -216,6 +216,10 @@ export const MpvPlayerEngine = (props: MpvPlayerEngineProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerStatus !== PlayerStatus.PLAYING) {
|
||||
return;
|
||||
}
|
||||
|
||||
const updateProgress = async () => {
|
||||
if (!mpvPlayer || !isMountedRef.current) {
|
||||
return;
|
||||
@@ -245,7 +249,7 @@ export const MpvPlayerEngine = (props: MpvPlayerEngineProps) => {
|
||||
progressIntervalRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [hasCurrentSong, isTransitioning, onProgress]);
|
||||
}, [hasCurrentSong, isTransitioning, onProgress, playerStatus]);
|
||||
|
||||
const { mediaAutoNext } = usePlayerActions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user