Wait for song to start before setting thumbar

This commit is contained in:
Araxeus
2021-03-22 03:01:46 +02:00
parent 41796aec06
commit df8c77cd3e

View File

@ -8,9 +8,12 @@ module.exports = win => {
// If the page is ready, register the callback // If the page is ready, register the callback
win.on("ready-to-show", () => { win.on("ready-to-show", () => {
// Register the callback
registerCallback((songInfo) => { registerCallback((songInfo) => {
// Song information changed, so lets update the the playPause button //wait for song to start before setting thumbar
if(songInfo.title === '') {
return;
}
// win32 require full rewrite of components
win.setThumbarButtons([ win.setThumbarButtons([
{ {
tooltip: 'Previous', tooltip: 'Previous',
@ -18,6 +21,7 @@ module.exports = win => {
click () { previous(win.webContents) } click () { previous(win.webContents) }
}, { }, {
tooltip: 'Play/Pause', tooltip: 'Play/Pause',
//update icon based on play state
icon: songInfo.isPaused ? get('play.png') : get('pause.png'), icon: songInfo.isPaused ? get('play.png') : get('pause.png'),
click () { playPause(win.webContents) } click () { playPause(win.webContents) }
} , { } , {
@ -30,6 +34,7 @@ module.exports = win => {
}); });
}; };
//util
function get (address) { function get (address) {
return path.join(__dirname,address); return path.join(__dirname,address);
} }