Merge pull request #39 from feross/fix-37

Hide player controls when mouse is still, even when not fullscreened
This commit is contained in:
Nate Goldman
2016-03-05 19:47:30 -08:00
3 changed files with 11 additions and 12 deletions

View File

@@ -208,7 +208,7 @@ function dispatch (action, ...args) {
if (action === 'toggleFullScreen') { if (action === 'toggleFullScreen') {
electron.ipcRenderer.send('toggleFullScreen') electron.ipcRenderer.send('toggleFullScreen')
} }
if (action === 'fullscreenVideoMouseMoved') { if (action === 'videoMouseMoved') {
state.video.mouseStationarySince = new Date().getTime() state.video.mouseStationarySince = new Date().getTime()
} }
} }

View File

@@ -24,14 +24,17 @@ function Player (state, dispatch) {
} }
// When in fullscreen, hide player controls if the mouse stays still for a while // When in fullscreen, hide player controls if the mouse stays still for a while
var hideControls = state.isFullScreen && var hideControls = state.video.mouseStationarySince !== 0 &&
state.video.mouseStationarySince !== 0 &&
new Date().getTime() - state.video.mouseStationarySince > 2000 new Date().getTime() - state.video.mouseStationarySince > 2000
// Show the video as large as will fit in the window, play immediately // Show the video as large as will fit in the window, play immediately
return hx` return hx`
<div class='player ${hideControls ? 'hide' : ''}' onmousemove=${onMouseMove}> <div
<div class='letterbox' onmousemove=${onMouseMove}> class='player ${hideControls ? 'hide' : ''}'
onmousemove=${() => dispatch('videoMouseMoved')}>
<div
class='letterbox'
onmousemove=${() => dispatch('videoMouseMoved')}>
<video <video
src='${state.server.localURL}' src='${state.server.localURL}'
onloadedmetadata=${onLoadedMetadata} onloadedmetadata=${onLoadedMetadata}
@@ -42,10 +45,6 @@ function Player (state, dispatch) {
</div> </div>
` `
function onMouseMove () {
if (state.isFullScreen) dispatch('fullscreenVideoMouseMoved')
}
// As soon as the video loads enough to know the video dimensions, resize the window // As soon as the video loads enough to know the video dimensions, resize the window
function onLoadedMetadata (e) { function onLoadedMetadata (e) {
var video = e.target var video = e.target

View File

@@ -46,9 +46,9 @@ function renderTorrent (torrent, dispatch) {
// Renders the torrent name and download progress // Renders the torrent name and download progress
function renderTorrentMetadata (torrent) { function renderTorrentMetadata (torrent) {
var progress = Math.floor(100 * (torrent.progress || 0)) var progress = Math.floor(100 * torrent.progress)
var downloaded = prettyBytes(torrent.downloaded || 0) var downloaded = prettyBytes(torrent.downloaded)
var total = prettyBytes(torrent.length || 0) var total = prettyBytes(torrent.ready ? torrent.length : 0)
if (downloaded !== total) downloaded += ` / ${total}` if (downloaded !== total) downloaded += ` / ${total}`