From ed1b27ede02696ab8c7a1f00c9d97be6e81ff49e Mon Sep 17 00:00:00 2001 From: Rolando Guedes Date: Thu, 12 May 2016 15:09:01 +0100 Subject: [PATCH 1/6] Increase/Decrease Sound with mouse wheel on video --- renderer/views/player.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/renderer/views/player.js b/renderer/views/player.js index 8f30dd53..18ce3932 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -10,14 +10,21 @@ var Bitfield = require('bitfield') var TorrentSummary = require('../lib/torrent-summary') var {dispatch, dispatcher} = require('../lib/dispatcher') +// Handles volume change by wheel +var handleVolumeWheel = function (e) { + dispatch('changeVolume', (-e.deltaY | e.deltaX) / 500) +}; + // Shows a streaming video player. Standard features + Chromecast + Airplay function Player (state) { // Show the video as large as will fit in the window, play immediately // If the video is on Chromecast or Airplay, show a title screen instead - var showVideo = state.playing.location === 'local' + var showVideo = state.playing.location === 'local'; + return hx`
${showVideo ? renderMedia(state) : renderCastScreen(state)} ${renderPlayerControls(state)} @@ -125,7 +132,7 @@ function renderMedia (state) { function onCanPlay (e) { var video = e.target if (video.webkitVideoDecodedByteCount > 0 && - video.webkitAudioDecodedByteCount === 0) { + video.webkitAudioDecodedByteCount === 0) { dispatch('mediaError', 'Audio codec unsupported') } else { video.play() @@ -195,7 +202,7 @@ function renderAudioMetadata (state) { function renderLoadingSpinner (state) { if (state.playing.isPaused) return var isProbablyStalled = state.playing.isStalled || - (new Date().getTime() - state.playing.lastTimeUpdate > 2000) + (new Date().getTime() - state.playing.lastTimeUpdate > 2000) if (!isProbablyStalled) return var prog = getPlayingTorrentSummary(state).progress || {} @@ -290,8 +297,8 @@ function renderPlayerControls (state) { var positionPercent = 100 * state.playing.currentTime / state.playing.duration var playbackCursorStyle = { left: 'calc(' + positionPercent + '% - 8px)' } var captionsClass = state.playing.subtitles.tracks.length === 0 - ? 'disabled' - : state.playing.subtitles.enabled + ? 'disabled' + : state.playing.subtitles.enabled ? 'active' : '' @@ -403,8 +410,8 @@ function renderPlayerControls (state) { var volume = state.playing.volume var volumeIcon = 'volume_' + (volume === 0 ? 'off' : volume < 0.3 ? 'mute' : volume < 0.6 ? 'down' : 'up') var volumeStyle = { background: '-webkit-gradient(linear, left top, right top, ' + - 'color-stop(' + (volume * 100) + '%, #eee), ' + - 'color-stop(' + (volume * 100) + '%, #727272))' + 'color-stop(' + (volume * 100) + '%, #eee), ' + + 'color-stop(' + (volume * 100) + '%, #727272))' } elements.push(hx` @@ -447,11 +454,6 @@ function renderPlayerControls (state) { dispatch('playbackJump', position) } - // Handles volume change by wheel - function handleVolumeWheel (e) { - dispatch('changeVolume', (-e.deltaY | e.deltaX) / 500) - } - // Handles volume muting and Unmuting function handleVolumeMute (e) { if (state.playing.volume === 0.0) { @@ -520,13 +522,13 @@ function renderLoadingBar (state) { return hx`
${parts.map(function (part) { - var style = { - left: (100 * part.start / fileProg.numPieces) + '%', - width: (100 * part.count / fileProg.numPieces) + '%' - } + var style = { + left: (100 * part.start / fileProg.numPieces) + '%', + width: (100 * part.count / fileProg.numPieces) + '%' + } - return hx`
` - })} + return hx`
` + })}
` } @@ -541,7 +543,7 @@ function cssBackgroundImagePoster (state) { function cssBackgroundImageDarkGradient () { return 'radial-gradient(circle at center, ' + - 'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' + 'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' } function getPlayingTorrentSummary (state) { From 4faf30e0a1fe026aeacb41479dc0d6d5c789dde7 Mon Sep 17 00:00:00 2001 From: Rolando Guedes Date: Thu, 12 May 2016 15:31:28 +0100 Subject: [PATCH 2/6] Fix Cli Test fails: JavaScript Standard Style --- renderer/views/player.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/renderer/views/player.js b/renderer/views/player.js index 18ce3932..04f1b98b 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -13,14 +13,13 @@ var {dispatch, dispatcher} = require('../lib/dispatcher') // Handles volume change by wheel var handleVolumeWheel = function (e) { dispatch('changeVolume', (-e.deltaY | e.deltaX) / 500) -}; +} // Shows a streaming video player. Standard features + Chromecast + Airplay function Player (state) { // Show the video as large as will fit in the window, play immediately // If the video is on Chromecast or Airplay, show a title screen instead - var showVideo = state.playing.location === 'local'; - + var showVideo = state.playing.location === 'local' return hx`
${parts.map(function (part) { var style = { - left: (100 * part.start / fileProg.numPieces) + '%', - width: (100 * part.count / fileProg.numPieces) + '%' + left: (100 * part.start / fileProg.numPieces) + '%', + width: (100 * part.count / fileProg.numPieces) + '%' } return hx`
` })} -
+
` } From 8d93641ebe014e68a0a8ed03ed38ed8ad470341e Mon Sep 17 00:00:00 2001 From: Rolando Guedes Date: Thu, 12 May 2016 15:47:48 +0100 Subject: [PATCH 3/6] Fix Cli Test fails: JavaScript Standard Style --- renderer/views/player.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/renderer/views/player.js b/renderer/views/player.js index 04f1b98b..778732ef 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -522,13 +522,13 @@ function renderLoadingBar (state) {
${parts.map(function (part) { var style = { - left: (100 * part.start / fileProg.numPieces) + '%', - width: (100 * part.count / fileProg.numPieces) + '%' + left: (100 * part.start / fileProg.numPieces) + '%', + width: (100 * part.count / fileProg.numPieces) + '%' } return hx`
` })} -
+ ` } From cb8f7f53c2c2a50408711388df3b67ba0b745c5a Mon Sep 17 00:00:00 2001 From: Rolando Guedes Date: Thu, 12 May 2016 15:56:29 +0100 Subject: [PATCH 4/6] Fix Cli Test fails: JavaScript Standard Style --- renderer/views/player.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/renderer/views/player.js b/renderer/views/player.js index 778732ef..ccc8fce9 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -521,13 +521,13 @@ function renderLoadingBar (state) { return hx`
${parts.map(function (part) { - var style = { - left: (100 * part.start / fileProg.numPieces) + '%', - width: (100 * part.count / fileProg.numPieces) + '%' - } + var style = { + left: (100 * part.start / fileProg.numPieces) + '%', + width: (100 * part.count / fileProg.numPieces) + '%' + } - return hx`
` - })} + return hx`
` + })}
` } From c343c008ed2aafd368d893b9ba605aea7061874a Mon Sep 17 00:00:00 2001 From: Rolando Guedes Date: Fri, 13 May 2016 21:02:35 +0100 Subject: [PATCH 5/6] Undo spaces changes --- renderer/views/player.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/renderer/views/player.js b/renderer/views/player.js index ccc8fce9..f2c58838 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -11,7 +11,7 @@ var TorrentSummary = require('../lib/torrent-summary') var {dispatch, dispatcher} = require('../lib/dispatcher') // Handles volume change by wheel -var handleVolumeWheel = function (e) { +function handleVolumeWheel(e) { dispatch('changeVolume', (-e.deltaY | e.deltaX) / 500) } @@ -131,7 +131,7 @@ function renderMedia (state) { function onCanPlay (e) { var video = e.target if (video.webkitVideoDecodedByteCount > 0 && - video.webkitAudioDecodedByteCount === 0) { + video.webkitAudioDecodedByteCount === 0) { dispatch('mediaError', 'Audio codec unsupported') } else { video.play() @@ -201,7 +201,7 @@ function renderAudioMetadata (state) { function renderLoadingSpinner (state) { if (state.playing.isPaused) return var isProbablyStalled = state.playing.isStalled || - (new Date().getTime() - state.playing.lastTimeUpdate > 2000) + (new Date().getTime() - state.playing.lastTimeUpdate > 2000) if (!isProbablyStalled) return var prog = getPlayingTorrentSummary(state).progress || {} @@ -296,8 +296,8 @@ function renderPlayerControls (state) { var positionPercent = 100 * state.playing.currentTime / state.playing.duration var playbackCursorStyle = { left: 'calc(' + positionPercent + '% - 8px)' } var captionsClass = state.playing.subtitles.tracks.length === 0 - ? 'disabled' - : state.playing.subtitles.enabled + ? 'disabled' + : state.playing.subtitles.enabled ? 'active' : '' @@ -409,8 +409,8 @@ function renderPlayerControls (state) { var volume = state.playing.volume var volumeIcon = 'volume_' + (volume === 0 ? 'off' : volume < 0.3 ? 'mute' : volume < 0.6 ? 'down' : 'up') var volumeStyle = { background: '-webkit-gradient(linear, left top, right top, ' + - 'color-stop(' + (volume * 100) + '%, #eee), ' + - 'color-stop(' + (volume * 100) + '%, #727272))' + 'color-stop(' + (volume * 100) + '%, #eee), ' + + 'color-stop(' + (volume * 100) + '%, #727272))' } elements.push(hx` @@ -542,7 +542,7 @@ function cssBackgroundImagePoster (state) { function cssBackgroundImageDarkGradient () { return 'radial-gradient(circle at center, ' + - 'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' + 'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' } function getPlayingTorrentSummary (state) { From 9e33be0ab16d82a83ce762a802e7cbafd48cf438 Mon Sep 17 00:00:00 2001 From: Rolando Guedes Date: Fri, 13 May 2016 21:05:26 +0100 Subject: [PATCH 6/6] Undo spaces changes --- renderer/views/player.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/renderer/views/player.js b/renderer/views/player.js index f2c58838..2f88c383 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -11,7 +11,7 @@ var TorrentSummary = require('../lib/torrent-summary') var {dispatch, dispatcher} = require('../lib/dispatcher') // Handles volume change by wheel -function handleVolumeWheel(e) { +function handleVolumeWheel (e) { dispatch('changeVolume', (-e.deltaY | e.deltaX) / 500) } @@ -409,8 +409,8 @@ function renderPlayerControls (state) { var volume = state.playing.volume var volumeIcon = 'volume_' + (volume === 0 ? 'off' : volume < 0.3 ? 'mute' : volume < 0.6 ? 'down' : 'up') var volumeStyle = { background: '-webkit-gradient(linear, left top, right top, ' + - 'color-stop(' + (volume * 100) + '%, #eee), ' + - 'color-stop(' + (volume * 100) + '%, #727272))' + 'color-stop(' + (volume * 100) + '%, #eee), ' + + 'color-stop(' + (volume * 100) + '%, #727272))' } elements.push(hx`