Added thumbar buttons

win32 taskbar controls and svg icons to png
This commit is contained in:
Onur Gümüş 2022-01-16 11:53:22 +03:00
parent e2738a7ffa
commit 4291396ce1
6 changed files with 39 additions and 0 deletions

View file

@ -1,3 +1,6 @@
const { nativeImage } = require("electron");
const path = require('path')
let mediaPlayer = null;
module.exports = {
@ -102,6 +105,39 @@ module.exports = {
}
},
SetButtons: (win, attributes) => {
if (process.platform === 'win32') { // Set the Windows Thumbnail Toolbar Buttons
win.setThumbarButtons([
{
tooltip: 'Previous',
icon: nativeImage.createFromPath(path.join(__dirname, 'thumbaricons/backwardPng.png')),
click() {
console.log("Clicked the bc taskbar button!")
win.webContents.executeJavaScript('MusicKitInterop.previousTrack()').catch(err => console.error(err))
}
},
{
tooltip: attributes.status ? 'Pause' : 'Play',
//tooltip: 'Play',
icon: attributes.status ? nativeImage.createFromPath(path.join(__dirname, 'thumbaricons/pausePng.png')) : nativeImage.createFromPath(path.join(__dirname, 'thumbaricons/playPng.png')),
click() {
console.log("Clicked the pl taskbar button!")
win.webContents.executeJavaScript('MusicKitInterop.pausePlay()').catch(err => console.error(err))
}
},
{
tooltip: 'Next',
icon: nativeImage.createFromPath(path.join(__dirname, 'thumbaricons/forwardPng.png')),
click() {
console.log("Clicked the fw taskbar button!")
win.webContents.executeJavaScript('MusicKitInterop.nextTrack()').catch(err => console.error(err))
}
}
]);
}
},
/**
* Closes the MPRIS interface.
*/