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') {
electron.ipcRenderer.send('toggleFullScreen')
}
if (action === 'fullscreenVideoMouseMoved') {
if (action === 'videoMouseMoved') {
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
var hideControls = state.isFullScreen &&
state.video.mouseStationarySince !== 0 &&
var hideControls = state.video.mouseStationarySince !== 0 &&
new Date().getTime() - state.video.mouseStationarySince > 2000
// Show the video as large as will fit in the window, play immediately
return hx`
<div class='player ${hideControls ? 'hide' : ''}' onmousemove=${onMouseMove}>
<div class='letterbox' onmousemove=${onMouseMove}>
<div
class='player ${hideControls ? 'hide' : ''}'
onmousemove=${() => dispatch('videoMouseMoved')}>
<div
class='letterbox'
onmousemove=${() => dispatch('videoMouseMoved')}>
<video
src='${state.server.localURL}'
onloadedmetadata=${onLoadedMetadata}
@@ -42,10 +45,6 @@ function Player (state, dispatch) {
</div>
`
function onMouseMove () {
if (state.isFullScreen) dispatch('fullscreenVideoMouseMoved')
}
// As soon as the video loads enough to know the video dimensions, resize the window
function onLoadedMetadata (e) {
var video = e.target

View File

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