From fc425e422154f3f79876e44f6c128b8a086d3c0f Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 22 Mar 2016 02:07:57 -0700 Subject: [PATCH] WebTorrent can now play audio --- renderer/index.css | 5 +- renderer/index.js | 56 ++++++++++++-------- renderer/lib/cast.js | 14 ++--- renderer/lib/torrent-player.js | 17 +++++-- renderer/state.js | 15 +++--- renderer/views/app.js | 6 +-- renderer/views/player.js | 93 +++++++++++++++++++++------------- renderer/views/torrent-list.js | 13 +++-- 8 files changed, 134 insertions(+), 85 deletions(-) diff --git a/renderer/index.css b/renderer/index.css index 05f82e9f..b6528428 100644 --- a/renderer/index.css +++ b/renderer/index.css @@ -181,7 +181,6 @@ i:not(.disabled):hover { left: 0; top: 0; right: 0; - z-index: 1000; transition: opacity 0.15s ease-out; font-size: 14px; line-height: 1.5em; @@ -456,8 +455,7 @@ input { background-color: #F44336; } -.torrent.timeout .play, -.torrent.unplayable .play { +.torrent.timeout .play { padding-top: 8px; } @@ -738,7 +736,6 @@ body.drag .torrent-placeholder span { .error-popover { position: fixed; - z-index: 1001; top: 36px; margin: 0; width: 100%; diff --git a/renderer/index.js b/renderer/index.js index b8412149..9d532192 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -163,7 +163,7 @@ function updateElectron () { // Events from the UI never modify state directly. Instead they call dispatch() function dispatch (action, ...args) { - if (['videoMouseMoved', 'playbackJump'].indexOf(action) === -1) { + if (['mediaMouseMoved', 'playbackJump'].indexOf(action) === -1) { console.log('dispatch: %s %o', action, args) /* log user interactions, but don't spam */ } if (action === 'onOpen') { @@ -235,20 +235,20 @@ function dispatch (action, ...args) { if (action === 'playbackJump') { jumpToTime(args[0] /* seconds */) } - if (action === 'videoPlaying') { - state.video.isPaused = false + if (action === 'mediaPlaying') { + state.playing.isPaused = false ipcRenderer.send('blockPowerSave') } - if (action === 'videoPaused') { - state.video.isPaused = true + if (action === 'mediaPaused') { + state.playing.isPaused = true ipcRenderer.send('unblockPowerSave') } if (action === 'toggleFullScreen') { ipcRenderer.send('toggleFullScreen', args[0]) update() } - if (action === 'videoMouseMoved') { - state.video.mouseStationarySince = new Date().getTime() + if (action === 'mediaMouseMoved') { + state.playing.mouseStationarySince = new Date().getTime() update() } if (action === 'exitModal') { @@ -259,14 +259,14 @@ function dispatch (action, ...args) { // Plays or pauses the video. If isPaused is undefined, acts as a toggle function playPause (isPaused) { - if (isPaused === state.video.isPaused) { + if (isPaused === state.playing.isPaused) { return // Nothing to do } // Either isPaused is undefined, or it's the opposite of the current state. Toggle. if (Cast.isCasting()) { Cast.playPause() } - state.video.isPaused = !state.video.isPaused + state.playing.isPaused = !state.playing.isPaused update() } @@ -274,7 +274,7 @@ function jumpToTime (time) { if (Cast.isCasting()) { Cast.seek(time) } else { - state.video.jumpToTime = time + state.playing.jumpToTime = time update() } } @@ -601,20 +601,14 @@ function startServer (torrentSummary, index, cb) { function startServerFromReadyTorrent (torrent, index, cb) { // automatically choose which file in the torrent to play, if necessary - if (!index) { - // filter out file formats that the