diff --git a/renderer/index.css b/renderer/index.css index 1bf15e8d..e9d7e185 100644 --- a/renderer/index.css +++ b/renderer/index.css @@ -317,30 +317,6 @@ input { box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.1); } -/* - * PLAYER - */ - -.player { - position: absolute; - width: 100%; - height: 100%; - background-color: #000; -} - -.player .letterbox { - width: 100%; - height: 100%; - display: flex; - background-size: cover; - background-position: center center; -} - -.player video { - display: block; - width: 100%; -} - /* * TORRENT LIST */ @@ -562,6 +538,28 @@ body.drag .torrent-placeholder span { text-align: right; } +/* + * PLAYER + */ + +.player { + position: absolute; + width: 100%; + height: 100%; + background-color: #000; +} + +.player .letterbox { + width: 100%; + height: 100%; + display: flex; +} + +.player video { + display: block; + width: 100%; +} + /* * PLAYER CONTROLS */ @@ -712,6 +710,17 @@ body.drag .torrent-placeholder span { * MEDIA OVERLAY / AUDIO DETAILS */ +.media-overlay-background { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + background-size: cover; + background-position: center center; +} + .media-overlay { max-width: calc(100% - 80px); white-space: nowrap; diff --git a/renderer/index.js b/renderer/index.js index 69fd9298..9b56ebde 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -258,6 +258,7 @@ function dispatch (action, ...args) { playPause() } if (action === 'play') { + if (state.location.pending()) return state.location.go({ url: 'player', onbeforeload: function (cb) { diff --git a/renderer/lib/location-history.js b/renderer/lib/location-history.js index 09122948..91f555f7 100644 --- a/renderer/lib/location-history.js +++ b/renderer/lib/location-history.js @@ -4,6 +4,7 @@ function LocationHistory () { if (!new.target) return new LocationHistory() this._history = [] this._forward = [] + this._pending = null } LocationHistory.prototype.go = function (page) { @@ -13,9 +14,12 @@ LocationHistory.prototype.go = function (page) { } LocationHistory.prototype._go = function (page) { + if (this._pending) return if (page.onbeforeload) { + this._pending = page page.onbeforeload((err) => { if (err) return + this._pending = null this._history.push(page) }) } else { @@ -59,3 +63,7 @@ LocationHistory.prototype.hasBack = function () { LocationHistory.prototype.hasForward = function () { return this._forward.length > 0 } + +LocationHistory.prototype.pending = function () { + return this._pending +} diff --git a/renderer/views/player.js b/renderer/views/player.js index 3aee668e..ab156412 100644 --- a/renderer/views/player.js +++ b/renderer/views/player.js @@ -70,16 +70,9 @@ function renderMedia (state) { mediaTag.tagName = mediaType // Show the media. - // Video fills the window, centered with black bars if necessary - // Audio gets a static poster image and a summary of the file metadata. - var isAudio = mediaType === 'audio' - var style = { - backgroundImage: isAudio ? cssBackgroundImagePoster(state) : '' - } return hx`
${mediaTag} ${renderOverlay(state)} @@ -104,15 +97,28 @@ function renderMedia (state) { } function renderOverlay (state) { + var elems = [] var audioMetadataElem = renderAudioMetadata(state) var spinnerElem = renderLoadingSpinner(state) - - var elems = [] if (audioMetadataElem) elems.push(audioMetadataElem) if (spinnerElem) elems.push(spinnerElem) - if (elems.length === 0) return - return hx`
${elems}
` + // Video fills the window, centered with black bars if necessary + // Audio gets a static poster image and a summary of the file metadata. + var style + if (state.playing.type === 'audio') { + style = { backgroundImage: cssBackgroundImagePoster(state) } + } else if (elems.length !== 0) { + style = { backgroundImage: cssBackgroundImageDarkGradient() } + } else { + return /* Video, not audio, and it isn't stalled, so no spinner. No overlay needed. */ + } + + return hx` +
+
${elems}
+
+ ` } function renderAudioMetadata (state) { @@ -201,9 +207,12 @@ function cssBackgroundImagePoster (state) { if (!torrentSummary || !torrentSummary.posterURL) return '' var posterURL = util.getAbsoluteStaticPath(torrentSummary.posterURL) var cleanURL = posterURL.replace(/\\/g, '/') + return cssBackgroundImageDarkGradient() + `, url(${cleanURL})` +} + +function cssBackgroundImageDarkGradient () { return 'radial-gradient(circle at center, ' + - 'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' + - `, url(${cleanURL})` + 'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' } function getPlayingTorrentSummary (state) {