Fix the screen saver blocker never getting disabled (#3286)

This commit is contained in:
absidue 2023-03-14 07:17:44 +01:00 committed by GitHub
parent 7f7c016ff6
commit 6c3ff9e999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -519,6 +519,12 @@ export default defineComponent({
if ('mediaSession' in navigator) {
navigator.mediaSession.playbackState = 'none'
}
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
const { ipcRenderer } = require('electron')
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
this.powerSaveBlocker = null
}
})
this.player.on('error', (error, message) => {
@ -527,9 +533,15 @@ export default defineComponent({
if ('mediaSession' in navigator) {
navigator.mediaSession.playbackState = 'none'
}
if (process.env.IS_ELECTRON && this.powerSaveBlocker !== null) {
const { ipcRenderer } = require('electron')
ipcRenderer.send(IpcChannels.STOP_POWER_SAVE_BLOCKER, this.powerSaveBlocker)
this.powerSaveBlocker = null
}
})
this.player.on('play', async function () {
this.player.on('play', async () => {
if ('mediaSession' in navigator) {
navigator.mediaSession.playbackState = 'playing'
}
@ -541,7 +553,7 @@ export default defineComponent({
}
})
this.player.on('pause', function () {
this.player.on('pause', () => {
if ('mediaSession' in navigator) {
navigator.mediaSession.playbackState = 'paused'
}