Prevent display from sleeping when video is playing

This commit is contained in:
Preston 2021-01-11 15:45:46 -05:00
parent ce7e568c7b
commit 6c9e176249
1 changed files with 21 additions and 0 deletions

View File

@ -61,6 +61,7 @@ export default Vue.extend({
data: function () { data: function () {
return { return {
id: '', id: '',
powerSaveBlocker: null,
volume: 1, volume: 1,
player: null, player: null,
useDash: false, useDash: false,
@ -115,6 +116,10 @@ export default Vue.extend({
} }
}, },
computed: { computed: {
usingElectron: function () {
return this.$store.getters.getUsingElectron
},
defaultPlayback: function () { defaultPlayback: function () {
return this.$store.getters.getDefaultPlayback return this.$store.getters.getDefaultPlayback
}, },
@ -235,6 +240,22 @@ export default Vue.extend({
this.player.on('error', function (error, message) { this.player.on('error', function (error, message) {
v.$emit('error', error.target.player.error_) v.$emit('error', error.target.player.error_)
}) })
this.player.on('play', function () {
if (this.usingElectron) {
const { powerSaveBlocker } = require('electron')
this.powerSaveBlocker = powerSaveBlocker.start('prevent-display-sleep')
}
})
this.player.on('pause', function () {
if (this.usingElectron && this.powerSaveBlocker !== null) {
const { powerSaveBlocker } = require('electron')
powerSaveBlocker.stop(this.powerSaveBlocker)
this.powerSaveBlocker = null
}
})
} }
}, },