diff --git a/src/main/base/wsapi.ts b/src/main/base/wsapi.ts index bfd62c9f..95d2b521 100644 --- a/src/main/base/wsapi.ts +++ b/src/main/base/wsapi.ts @@ -61,6 +61,9 @@ export class wsapi { electron.ipcMain.on('wsapi-returnLyrics', (_event: any, arg: any) => { this.returnLyrics(JSON.parse(arg)); }); + electron.ipcMain.on('wsapi-returnvolumeMax', (_event: any, arg: any) => { + this.returnmaxVolume(JSON.parse(arg)); + }); this.wss = new WebSocketServer({ port: this.port, perMessageDeflate: { @@ -162,6 +165,10 @@ export class wsapi { this._win.webContents.executeJavaScript(`MusicKit.getInstance().stop()`); response.message = "Stopped"; break; + case "volumeMax": + this._win.webContents.executeJavaScript(`wsapi.getmaxVolume()`); + response.message = "maxVolume"; + break; case "volume": this._win.webContents.executeJavaScript(`MusicKit.getInstance().volume = ${parseFloat(data.volume)}`); response.message = "Volume"; @@ -295,4 +302,11 @@ export class wsapi { client.send(JSON.stringify(response)); }); } + + returnmaxVolume(vol: any) { + const response: standardResponse = {status: 0, data: vol, message: "OK", type: "maxVolume"}; + this.clients.forEach(function each(client: any) { + client.send(JSON.stringify(response)); + }); + } } \ No newline at end of file diff --git a/src/renderer/js/WSAPI_Interop.js b/src/renderer/js/WSAPI_Interop.js index 525ad47e..422c96b3 100644 --- a/src/renderer/js/WSAPI_Interop.js +++ b/src/renderer/js/WSAPI_Interop.js @@ -107,5 +107,8 @@ const wsapi = { }else{ MusicKit.getInstance().repeatMode = 0 } + }, + getmaxVolume() { + ipcRenderer.send('wsapi-returnvolumeMax',JSON.stringify(app.cfg.audio.maxVolume)); } } \ No newline at end of file diff --git a/src/web-remote/index.js b/src/web-remote/index.js index 44f8d1c0..3a8b522b 100644 --- a/src/web-remote/index.js +++ b/src/web-remote/index.js @@ -13,6 +13,7 @@ var app = new Vue({ player: { currentMediaItem: {}, songActions: false, + maxVolume: 1, lyrics: {}, lyricsMediaItem: {}, lyricsDebug: { @@ -161,6 +162,11 @@ var app = new Vue({ volume: volume })); }, + getVolumeMax() { + socket.send(JSON.stringify({ + action: "volumeMax", + })); + }, getQueue() { socket.send(JSON.stringify({ action: "get-queue" @@ -570,6 +576,9 @@ var app = new Vue({ self.updatePlaybackState(response.data) } break; + case "maxVolume": + this.player.maxVolume = response.data; + break; } // console.log(e.data); } diff --git a/src/web-remote/views/index.ejs b/src/web-remote/views/index.ejs index 46915075..de38dc44 100644 --- a/src/web-remote/views/index.ejs +++ b/src/web-remote/views/index.ejs @@ -172,7 +172,7 @@