diff --git a/src/main/features/core/player/index.ts b/src/main/features/core/player/index.ts index daba2496..5afcdfe5 100644 --- a/src/main/features/core/player/index.ts +++ b/src/main/features/core/player/index.ts @@ -41,6 +41,12 @@ ipcMain.on('player-seek-to', async (_event, time: number) => { // Sets the queue in position 0 and 1 to the given data. Used when manually starting a song or using the next/prev buttons ipcMain.on('player-set-queue', async (_event, data: PlayerData) => { + if (!data.queue.current && !data.queue.next) { + await mpv.clearPlaylist(); + await mpv.pause(); + return; + } + if (data.queue.current) { await mpv.load(data.queue.current.streamUrl, 'replace'); } @@ -48,6 +54,8 @@ ipcMain.on('player-set-queue', async (_event, data: PlayerData) => { if (data.queue.next) { await mpv.load(data.queue.next.streamUrl, 'append'); } + + await mpv.play(); }); // Replaces the queue in position 1 to the given data diff --git a/src/renderer/features/now-playing/components/play-queue-list-controls.tsx b/src/renderer/features/now-playing/components/play-queue-list-controls.tsx index 870f6459..2f832c58 100644 --- a/src/renderer/features/now-playing/components/play-queue-list-controls.tsx +++ b/src/renderer/features/now-playing/components/play-queue-list-controls.tsx @@ -12,9 +12,10 @@ import { RiEraserLine, } from 'react-icons/ri'; import { Song } from '/@/renderer/api/types'; -import { useQueueControls } from '/@/renderer/store'; +import { usePlayerControls, useQueueControls } from '/@/renderer/store'; import { PlaybackType, TableType } from '/@/renderer/types'; import { usePlayerType } from '/@/renderer/store/settings.store'; +import { useSetCurrentTime } from '../../../store/player.store'; const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null; @@ -27,7 +28,10 @@ export const PlayQueueListControls = ({ type, tableRef }: PlayQueueListOptionsPr const { clearQueue, moveToBottomOfQueue, moveToTopOfQueue, shuffleQueue, removeFromQueue } = useQueueControls(); + const { pause } = usePlayerControls(); + const playerType = usePlayerType(); + const setCurrentTime = useSetCurrentTime(); const handleMoveToBottom = () => { const selectedRows = tableRef?.current?.grid.api.getSelectedRows(); @@ -70,8 +74,11 @@ export const PlayQueueListControls = ({ type, tableRef }: PlayQueueListOptionsPr if (playerType === PlaybackType.LOCAL) { mpvPlayer.setQueue(playerData); - mpvPlayer.stop(); + mpvPlayer.pause(); } + + setCurrentTime(0); + pause(); }; const handleShuffleQueue = () => {