Skip to content

Commit

Permalink
[bugfix]: MPV do not next/prev on queue set
Browse files Browse the repository at this point in the history
When calling setQueue, do not successively call next()/prev().
Somehow, prev() works, but for next() there is a race condition where after the first skip
you will skip two tracks.
  • Loading branch information
kgarner7 committed Oct 7, 2023
1 parent cca6fa2 commit c97b894
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/renderer/features/player/hooks/use-center-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ export const useCenterControls = (args: { playersRef: any }) => {
const playerData = next();
mprisUpdateSong({ song: playerData.current.song, status: PlayerStatus.PLAYING });
mpvPlayer!.setQueue(playerData);
mpvPlayer!.next();
},
web: () => {
const playerData = next();
Expand All @@ -331,7 +330,6 @@ export const useCenterControls = (args: { playersRef: any }) => {
status: PlayerStatus.PLAYING,
});
mpvPlayer!.setQueue(playerData);
mpvPlayer!.next();
}
},
web: () => {
Expand Down Expand Up @@ -359,7 +357,6 @@ export const useCenterControls = (args: { playersRef: any }) => {
const playerData = next();
mprisUpdateSong({ song: playerData.current.song, status: PlayerStatus.PLAYING });
mpvPlayer!.setQueue(playerData);
mpvPlayer!.next();
},
web: () => {
if (!isLastTrack) {
Expand Down Expand Up @@ -426,15 +423,13 @@ export const useCenterControls = (args: { playersRef: any }) => {
status: PlayerStatus.PLAYING,
});
mpvPlayer!.setQueue(playerData);
mpvPlayer!.previous();
} else {
const playerData = setCurrentIndex(queue.length - 1);
mprisUpdateSong({
song: playerData.current.song,
status: PlayerStatus.PLAYING,
});
mpvPlayer!.setQueue(playerData);
mpvPlayer!.previous();
}
},
web: () => {
Expand Down Expand Up @@ -464,7 +459,6 @@ export const useCenterControls = (args: { playersRef: any }) => {
song: playerData.current.song,
});
mpvPlayer!.setQueue(playerData);
mpvPlayer!.previous();
},
web: () => {
if (isFirstTrack) {
Expand All @@ -491,7 +485,6 @@ export const useCenterControls = (args: { playersRef: any }) => {
status: PlayerStatus.PLAYING,
});
mpvPlayer!.setQueue(playerData);
mpvPlayer!.previous();
} else {
mpvPlayer!.stop();
}
Expand Down

0 comments on commit c97b894

Please sign in to comment.