Attempt to fix player unresponsive on first start

This commit is contained in:
jeffvli 2024-02-16 22:12:28 -08:00
parent 2f105956b9
commit 9a43ea0e4a
3 changed files with 9 additions and 8 deletions

View file

@ -323,13 +323,16 @@ ipcMain.on('player-set-queue', async (_event, data: PlayerData, pause?: boolean)
await getMpvInstance()?.load(data.queue.next.streamUrl, 'append'); await getMpvInstance()?.load(data.queue.next.streamUrl, 'append');
} }
} }
if (pause) {
await getMpvInstance()?.pause();
} else if (pause === false) {
// Only force play if pause is explicitly false
await getMpvInstance()?.play();
}
} catch (err: NodeMpvError | any) { } catch (err: NodeMpvError | any) {
mpvLog({ action: `Failed to set play queue` }, err); mpvLog({ action: `Failed to set play queue` }, err);
} }
if (pause) {
getMpvInstance()?.pause();
}
}); });
// Replaces the queue in position 1 to the given data // Replaces the queue in position 1 to the given data

View file

@ -89,8 +89,7 @@ export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
if (playbackType === PlaybackType.LOCAL) { if (playbackType === PlaybackType.LOCAL) {
mpvPlayer!.volume(volume); mpvPlayer!.volume(volume);
mpvPlayer!.setQueue(playerData); mpvPlayer!.setQueue(playerData, false);
mpvPlayer!.play();
} }
play(); play();

View file

@ -175,8 +175,7 @@ export const useHandlePlayQueueAdd = () => {
if (playType === Play.NOW || !hadSong) { if (playType === Play.NOW || !hadSong) {
mpvPlayer!.pause(); mpvPlayer!.pause();
mpvPlayer!.setQueue(playerData); mpvPlayer!.setQueue(playerData, false);
mpvPlayer!.play();
} else { } else {
mpvPlayer!.setQueueNext(playerData); mpvPlayer!.setQueueNext(playerData);
} }