From 432d7d4a56a4de9eef62904477e6f7620a6f1eee Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 14 Apr 2016 16:16:54 -0700 Subject: [PATCH] Simplify play/pause handling (#410) I found it awkward to listen to the video tags 'playing' and 'paused' events, when we're controlling the state that defines what state it's in in the first place. This commit removes those listeners, in favor of just setting things to the right state immediately when play(), pause(), or playPause() is called. Added play(), pause() methods for clarity. --- renderer/index.js | 46 ++++++++++++++++++------------------ renderer/lib/cast.js | 50 ++++++++++++++++++++++++++++------------ renderer/views/player.js | 2 -- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index 511f6de7..843d3e6c 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -254,10 +254,7 @@ function dispatch (action, ...args) { }, onbeforeunload: closePlayer }) - playPause(false) - } - if (action === 'pause') { - playPause(true) + play() } if (action === 'playbackJump') { jumpToTime(args[0] /* seconds */) @@ -271,17 +268,6 @@ function dispatch (action, ...args) { if (action === 'openSubtitles') { openSubtitles() } - if (action === 'mediaPlaying') { - state.playing.isPaused = false - ipcRenderer.send('blockPowerSave') - } - if (action === 'mediaPaused') { - // When removing the