diff --git a/src/main/base/store.ts b/src/main/base/store.ts index eeac1e9c..6aae5ae9 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -26,6 +26,7 @@ export class Store { }, "audio": { "volume": 1, + "volumeStep": 0.02, "lastVolume": 1, "muted": false, "quality": "HIGH", @@ -34,10 +35,6 @@ export class Store { "ciderPPE": false, "ciderPPE_value": 0.5, "spatial": false, - "maxVolume": 1, - "volumePrecision": 0.1, - "volumeRoundMax": 0.9, - "volumeRoundMin": 0.1, "spatial_properties": { "presets": [], "gain": 0.8, diff --git a/src/main/plugins/menubar.ts b/src/main/plugins/menubar.ts index 5d729a8b..ec484b40 100644 --- a/src/main/plugins/menubar.ts +++ b/src/main/plugins/menubar.ts @@ -95,6 +95,37 @@ export default class Thumbar { } ] }, + { + label: 'Controls', + submenu: [ + { + label: 'Pause / Play', + accelerator: 'Space', + click: () => this._win.webContents.executeJavaScript(`MusicKitInterop.playPause()`) + }, + { + label: 'Next', + accelerator: 'CommandOrControl+Right', + click: () => this._win.webContents.executeJavaScript(`MusicKitInterop.next()`) + }, + { + label: 'Previous', + accelerator: 'CommandOrControl+Left', + click: () => this._win.webContents.executeJavaScript(`MusicKitInterop.previous()`) + }, + { type: 'separator' }, + { + label: 'Volume Up', + accelerator: 'CommandOrControl+Up', + click: () => this._win.webContents.executeJavaScript(`app.volumeUp()`) + }, + { + label: 'Volume Down', + accelerator: 'CommandOrControl+Down', + click: () => this._win.webContents.executeJavaScript(`app.volumeDown()`) + } + ] + }, { label: 'Account', submenu: [ diff --git a/src/renderer/index.js b/src/renderer/index.js index 86dcfa65..e5dba229 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -3307,29 +3307,32 @@ const app = new Vue({ } }) }, + checkScrollDirectionIsUp(event) { + if (event.wheelDelta) { + return event.wheelDelta > 0; + } + return event.deltaY < 0; + }, + volumeUp() { + if ((app.mk.volume + app.cfg.audio.volumeStep) > 1) { + app.mk.volume = 1; + console.log('setting to 1') + } else { + console.log('volume up') + app.mk.volume += app.cfg.audio.volumeStep; + } + }, + volumeDown() { + if ((app.mk.volume - app.cfg.audio.volumeStep) < 0) { + app.mk.volume = 0; + console.log('settings to 0') + } else { + console.log('volume down') + app.mk.volume -= app.cfg.audio.volumeStep; + } + }, volumeWheel(event) { - if (this.cfg.audio.maxVolume < 1.0 && this.cfg.audio.maxVolume > 0.01) { - this.cfg.audio.volumePrecision = 0.01 - this.cfg.audio.volumeRoundMax = this.cfg.audio.maxVolume - 0.01 - this.cfg.audio.volumeRoundMin = 0.01 - } - if (event.deltaY < 0) { - if (this.mk.volume < this.cfg.audio.maxVolume) { - if (this.mk.volume <= this.cfg.audio.volumeRoundMax) { - this.mk.volume += this.cfg.audio.volumePrecision - } else { - this.mk.volume = this.cfg.audio.maxVolume - } - } - } else if (event.deltaY > 0) { - if (this.mk.volume > 0) { - if (this.mk.volume >= this.cfg.audio.volumeRoundMin) { - this.mk.volume -= this.cfg.audio.volumePrecision - } else { - this.mk.volume = 0 - } - } - } + app.checkScrollDirectionIsUp(event) ? app.volumeUp() : app.volumeDown() }, muteButtonPressed() { if (this.cfg.audio.muted) { diff --git a/src/renderer/views/app/chrome-top.ejs b/src/renderer/views/app/chrome-top.ejs index d9d946fd..15fa6f2f 100644 --- a/src/renderer/views/app/chrome-top.ejs +++ b/src/renderer/views/app/chrome-top.ejs @@ -108,7 +108,7 @@
-