Clean up thumbar (thumbnail) code (#670)

* Cleanup thumbnail bar code

- rename thumbnail method names for succinctness
- Get rid of 'updateThumbnailBar' event -- use existing events
- Get rid of 'blockPowerSave' and 'unblockPowerSave' events -- use a
new combined 'onPlayerPlay' and 'onPlayerPause' events which apply to
power save and updating the thumbbar

* Consistent naming for enable/disable methods
This commit is contained in:
Feross Aboukhadijeh
2016-06-28 06:32:28 -07:00
committed by DC
parent c44943cef7
commit 349c5ee22e
7 changed files with 81 additions and 68 deletions

View File

@@ -15,7 +15,7 @@ var shell = require('./shell')
var shortcuts = require('./shortcuts')
var vlc = require('./vlc')
var windows = require('./windows')
var thumbnail = require('./thumbnail')
var thumbar = require('./thumbar')
// Messages from the main process, to be sent once the WebTorrent process starts
var messageQueueMainToWebTorrent = []
@@ -61,24 +61,27 @@ function init () {
ipc.on('onPlayerOpen', function () {
menu.onPlayerOpen()
shortcuts.onPlayerOpen()
powerSaveBlocker.enable()
shortcuts.enable()
thumbar.enable()
})
ipc.on('onPlayerClose', function () {
menu.onPlayerClose()
shortcuts.onPlayerOpen()
powerSaveBlocker.disable()
shortcuts.disable()
thumbar.disable()
})
ipc.on('updateThumbnailBar', function (e, isPaused) {
thumbnail.updateThumbarButtons(isPaused)
ipc.on('onPlayerPlay', function () {
powerSaveBlocker.enable()
thumbar.onPlayerPlay()
})
/**
* Power Save Blocker
*/
ipc.on('blockPowerSave', () => powerSaveBlocker.start())
ipc.on('unblockPowerSave', () => powerSaveBlocker.stop())
ipc.on('onPlayerPause', function () {
powerSaveBlocker.disable()
thumbar.onPlayerPause()
})
/**
* Shell