Fix video and audio playback to pause on window close

This commit is contained in:
ayumi-signal 2024-02-02 15:39:32 -08:00 committed by GitHub
parent d215e1b9be
commit 96131112da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 98 additions and 1 deletions

View file

@ -832,6 +832,12 @@ async function createWindow() {
// App dock icon bounce
bounce.init(mainWindow);
mainWindow.on('hide', () => {
if (mainWindow && !windowState.shouldQuit()) {
mainWindow.webContents.send('set-media-playback-disabled', true);
}
});
// Emitted when the window is about to be closed.
// Note: We do most of our shutdown logic here because all windows are closed by
// Electron before the app quits.
@ -937,6 +943,12 @@ async function createWindow() {
}
});
mainWindow.on('show', () => {
if (mainWindow) {
mainWindow.webContents.send('set-media-playback-disabled', false);
}
});
mainWindow.once('ready-to-show', async () => {
getLogger().info('main window is ready-to-show');