[bugfix]: do not update mpris status unnecessarily
This commit is contained in:
parent
ae167e63fd
commit
65eca32de3
1 changed files with 15 additions and 45 deletions
|
@ -309,12 +309,12 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
const handleRepeatAll = {
|
const handleRepeatAll = {
|
||||||
local: () => {
|
local: () => {
|
||||||
const playerData = next();
|
const playerData = next();
|
||||||
mprisUpdateSong({ song: playerData.current.song, status: PlayerStatus.PLAYING });
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
mpvPlayer!.setQueue(playerData);
|
mpvPlayer!.setQueue(playerData);
|
||||||
},
|
},
|
||||||
web: () => {
|
web: () => {
|
||||||
const playerData = next();
|
const playerData = next();
|
||||||
mprisUpdateSong({ song: playerData.current.song, status: PlayerStatus.PLAYING });
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -327,10 +327,7 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
pause();
|
pause();
|
||||||
} else {
|
} else {
|
||||||
const playerData = next();
|
const playerData = next();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
mpvPlayer!.setQueue(playerData);
|
mpvPlayer!.setQueue(playerData);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -339,16 +336,13 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
const playerData = setCurrentIndex(0);
|
const playerData = setCurrentIndex(0);
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({
|
||||||
song: playerData.current.song,
|
song: playerData.current.song,
|
||||||
status: PlayerStatus.PLAYING,
|
status: PlayerStatus.PAUSED,
|
||||||
});
|
});
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
pause();
|
pause();
|
||||||
} else {
|
} else {
|
||||||
const playerData = next();
|
const playerData = next();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -358,20 +352,14 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
local: () => {
|
local: () => {
|
||||||
if (!isLastTrack) {
|
if (!isLastTrack) {
|
||||||
const playerData = next();
|
const playerData = next();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
mpvPlayer!.setQueue(playerData);
|
mpvPlayer!.setQueue(playerData);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
web: () => {
|
web: () => {
|
||||||
if (!isLastTrack) {
|
if (!isLastTrack) {
|
||||||
const playerData = next();
|
const playerData = next();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -425,34 +413,22 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
local: () => {
|
local: () => {
|
||||||
if (!isFirstTrack) {
|
if (!isFirstTrack) {
|
||||||
const playerData = previous();
|
const playerData = previous();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
mpvPlayer!.setQueue(playerData);
|
mpvPlayer!.setQueue(playerData);
|
||||||
} else {
|
} else {
|
||||||
const playerData = setCurrentIndex(queue.length - 1);
|
const playerData = setCurrentIndex(queue.length - 1);
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
mpvPlayer!.setQueue(playerData);
|
mpvPlayer!.setQueue(playerData);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
web: () => {
|
web: () => {
|
||||||
if (isFirstTrack) {
|
if (isFirstTrack) {
|
||||||
const playerData = setCurrentIndex(queue.length - 1);
|
const playerData = setCurrentIndex(queue.length - 1);
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
} else {
|
} else {
|
||||||
const playerData = previous();
|
const playerData = previous();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -467,7 +443,7 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
pause();
|
pause();
|
||||||
} else {
|
} else {
|
||||||
const playerData = previous();
|
const playerData = previous();
|
||||||
remote?.updateSong({
|
mprisUpdateSong({
|
||||||
currentTime: usePlayerStore.getState().current.time,
|
currentTime: usePlayerStore.getState().current.time,
|
||||||
song: playerData.current.song,
|
song: playerData.current.song,
|
||||||
});
|
});
|
||||||
|
@ -481,10 +457,7 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
pause();
|
pause();
|
||||||
} else {
|
} else {
|
||||||
const playerData = previous();
|
const playerData = previous();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -493,15 +466,12 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
||||||
const handleRepeatOne = {
|
const handleRepeatOne = {
|
||||||
local: () => {
|
local: () => {
|
||||||
const playerData = previous();
|
const playerData = previous();
|
||||||
mprisUpdateSong({
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
song: playerData.current.song,
|
|
||||||
status: PlayerStatus.PLAYING,
|
|
||||||
});
|
|
||||||
mpvPlayer!.setQueue(playerData);
|
mpvPlayer!.setQueue(playerData);
|
||||||
},
|
},
|
||||||
web: () => {
|
web: () => {
|
||||||
const playerData = previous();
|
const playerData = previous();
|
||||||
mprisUpdateSong({ song: playerData.current.song, status: PlayerStatus.PLAYING });
|
mprisUpdateSong({ song: playerData.current.song });
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue