14
main/ipc.js
14
main/ipc.js
@@ -9,6 +9,10 @@ var windows = require('./windows')
|
|||||||
|
|
||||||
var app = electron.app
|
var app = electron.app
|
||||||
var ipcMain = electron.ipcMain
|
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 () {
|
function init () {
|
||||||
ipcMain.on('showOpenTorrentFile', function (e) {
|
ipcMain.on('showOpenTorrentFile', function (e) {
|
||||||
@@ -42,6 +46,16 @@ function init () {
|
|||||||
ipcMain.on('log', function (e, message) {
|
ipcMain.on('log', function (e, message) {
|
||||||
console.log(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) {
|
function setBounds (bounds) {
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ function dispatch (action, ...args) {
|
|||||||
state.video.isPaused = true
|
state.video.isPaused = true
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
if (action === 'videoPlaying') {
|
||||||
|
ipcRenderer.send('playing-video')
|
||||||
|
}
|
||||||
if (action === 'videoPaused') {
|
if (action === 'videoPaused') {
|
||||||
ipcRenderer.send('paused-video')
|
ipcRenderer.send('paused-video')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ function Player (state, dispatch) {
|
|||||||
ondblclick=${() => dispatch('toggleFullScreen')}
|
ondblclick=${() => dispatch('toggleFullScreen')}
|
||||||
onloadedmetadata=${onLoadedMetadata}
|
onloadedmetadata=${onLoadedMetadata}
|
||||||
onended=${onEnded}
|
onended=${onEnded}
|
||||||
|
onplay=${() => dispatch('videoPlaying')}
|
||||||
onpause=${() => dispatch('videoPaused')}
|
onpause=${() => dispatch('videoPaused')}
|
||||||
autoplay>
|
autoplay>
|
||||||
</video>
|
</video>
|
||||||
|
|||||||
Reference in New Issue
Block a user