Stop music before close

This commit is contained in:
Core 2022-09-24 23:21:50 +01:00
parent 3f4351d09f
commit b06a9283cc
No known key found for this signature in database
GPG key ID: 2AB8327FBA02D1C0

View file

@ -1445,16 +1445,18 @@ export class BrowserWindow {
}
});
win.on("close", (e: any) => {
win.on("close", async (e: any) => {
if ((process.platform === "darwin" || utils.getStoreValue("general.close_button_hide")) && !isQuitting) {
e.preventDefault();
win.hide();
} else {
win.webContents.executeJavaScript(`
await win.webContents.executeJavaScript(`
window.localStorage.setItem("currentTrack", JSON.stringify(app.mk.nowPlayingItem));
window.localStorage.setItem("currentTime", JSON.stringify(app.mk.currentPlaybackTime));
window.localStorage.setItem("currentQueue", JSON.stringify(app.mk.queue._unplayedQueueItems));
ipcRenderer.send('stopGCast','');`);
ipcRenderer.send('stopGCast','');
MusicKit.getInstance().stop();
`);
}
});