Fix mpv stopping after first playback

- On startup, the first time a song is played, mpv will stop after playback
- This adds a loop to the queue handler to automatically retry when failing to add to the queue
This commit is contained in:
jeffvli 2023-03-09 12:45:13 -08:00
parent 7f9de4b180
commit 275d68ec5b
2 changed files with 44 additions and 22 deletions

View file

@ -168,6 +168,20 @@ export const useHandlePlayQueueAdd = () => {
if (!songs) return toast.warn({ message: 'No songs found' });
const playerData = usePlayerStore.getState().actions.addToQueue(songs, options.play);
if (playerType === PlaybackType.LOCAL) {
if (options.play === Play.NEXT || options.play === Play.LAST) {
mpvPlayer.setQueueNext(playerData);
}
if (options.play === Play.NOW) {
mpvPlayer.setQueue(playerData);
mpvPlayer.play();
}
}
play();
mpris?.updateSong({
currentTime: usePlayerStore.getState().current.time,
repeat: usePlayerStore.getState().repeat,
@ -176,21 +190,6 @@ export const useHandlePlayQueueAdd = () => {
status: 'Playing',
});
if (options.play === Play.NEXT || options.play === Play.LAST) {
if (playerType === PlaybackType.LOCAL) {
mpvPlayer.setQueueNext(playerData);
}
}
if (options.play === Play.NOW) {
if (playerType === PlaybackType.LOCAL) {
mpvPlayer.setQueue(playerData);
mpvPlayer.play();
}
play();
}
// if (fetchId) {
// toast.update({
// autoClose: 1000,