mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +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> => {
|
ipcMain.handle('player-get-time', async (): Promise<number | undefined> => {
|
||||||
try {
|
try {
|
||||||
return getMpvInstance()?.getTimePosition();
|
const mpv = getMpvInstance();
|
||||||
|
if (!mpv) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return await mpv.getTimePosition();
|
||||||
} catch (err: any | NodeMpvError) {
|
} 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);
|
mpvLog({ action: `Failed to get current time` }, err);
|
||||||
return 0;
|
return undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,10 @@ export const MpvPlayerEngine = (props: MpvPlayerEngineProps) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playerStatus !== PlayerStatus.PLAYING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const updateProgress = async () => {
|
const updateProgress = async () => {
|
||||||
if (!mpvPlayer || !isMountedRef.current) {
|
if (!mpvPlayer || !isMountedRef.current) {
|
||||||
return;
|
return;
|
||||||
@@ -245,7 +249,7 @@ export const MpvPlayerEngine = (props: MpvPlayerEngineProps) => {
|
|||||||
progressIntervalRef.current = null;
|
progressIntervalRef.current = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [hasCurrentSong, isTransitioning, onProgress]);
|
}, [hasCurrentSong, isTransitioning, onProgress, playerStatus]);
|
||||||
|
|
||||||
const { mediaAutoNext } = usePlayerActions();
|
const { mediaAutoNext } = usePlayerActions();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user