mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
prevent change of media state with empty queue
This commit is contained in:
parent
ba531505af
commit
0d03b66fe5
5 changed files with 26 additions and 11 deletions
|
|
@ -306,7 +306,7 @@ 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, pause?: boolean) => {
|
||||
if (!data.queue.current && !data.queue.next) {
|
||||
if (!data.queue.current?.id && !data.queue.next?.id) {
|
||||
try {
|
||||
await getMpvInstance()?.clearPlaylist();
|
||||
await getMpvInstance()?.pause();
|
||||
|
|
@ -317,14 +317,14 @@ ipcMain.on('player-set-queue', async (_event, data: PlayerData, pause?: boolean)
|
|||
}
|
||||
|
||||
try {
|
||||
if (data.queue.current) {
|
||||
if (data.queue.current?.streamUrl) {
|
||||
await getMpvInstance()
|
||||
?.load(data.queue.current.streamUrl, 'replace')
|
||||
.catch(() => {
|
||||
getMpvInstance()?.play();
|
||||
});
|
||||
|
||||
if (data.queue.next) {
|
||||
if (data.queue.next?.streamUrl) {
|
||||
await getMpvInstance()?.load(data.queue.next.streamUrl, 'append');
|
||||
}
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ ipcMain.on('player-set-queue-next', async (_event, data: PlayerData) => {
|
|||
await getMpvInstance()?.playlistRemove(1);
|
||||
}
|
||||
|
||||
if (data.queue.next) {
|
||||
if (data.queue.next?.streamUrl) {
|
||||
await getMpvInstance()?.load(data.queue.next.streamUrl, 'append');
|
||||
}
|
||||
} catch (err: NodeMpvError | any) {
|
||||
|
|
@ -373,7 +373,7 @@ ipcMain.on('player-auto-next', async (_event, data: PlayerData) => {
|
|||
getMpvInstance()?.pause();
|
||||
});
|
||||
|
||||
if (data.queue.next) {
|
||||
if (data.queue.next?.streamUrl) {
|
||||
await getMpvInstance()?.load(data.queue.next.streamUrl, 'append');
|
||||
}
|
||||
} catch (err: NodeMpvError | any) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue