14
main/ipc.js
14
main/ipc.js
@@ -9,6 +9,10 @@ var windows = require('./windows')
|
||||
|
||||
var app = electron.app
|
||||
var ipcMain = electron.ipcMain
|
||||
var powerSaveBlocker = electron.powerSaveBlocker
|
||||
|
||||
// has to be a number, not a boolean, and undefined throws an error
|
||||
var powerSaveBlocked = 0
|
||||
|
||||
function init () {
|
||||
ipcMain.on('showOpenTorrentFile', function (e) {
|
||||
@@ -42,6 +46,16 @@ function init () {
|
||||
ipcMain.on('log', function (e, message) {
|
||||
console.log(message)
|
||||
})
|
||||
|
||||
ipcMain.on('playing-video', function (e) {
|
||||
powerSaveBlocked = powerSaveBlocker.start('prevent-display-sleep')
|
||||
})
|
||||
|
||||
ipcMain.on('paused-video', function (e) {
|
||||
if (powerSaveBlocker.isStarted(powerSaveBlocked)) {
|
||||
powerSaveBlocker.stop(powerSaveBlocked)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function setBounds (bounds) {
|
||||
|
||||
@@ -206,6 +206,9 @@ function dispatch (action, ...args) {
|
||||
state.video.isPaused = true
|
||||
update()
|
||||
}
|
||||
if (action === 'videoPlaying') {
|
||||
ipcRenderer.send('playing-video')
|
||||
}
|
||||
if (action === 'videoPaused') {
|
||||
ipcRenderer.send('paused-video')
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ function Player (state, dispatch) {
|
||||
ondblclick=${() => dispatch('toggleFullScreen')}
|
||||
onloadedmetadata=${onLoadedMetadata}
|
||||
onended=${onEnded}
|
||||
onplay=${() => dispatch('videoPlaying')}
|
||||
onpause=${() => dispatch('videoPaused')}
|
||||
autoplay>
|
||||
</video>
|
||||
|
||||
Reference in New Issue
Block a user