Hide player controls when mouse is still, even when not fullscreened (fix #37)

This commit is contained in:
Feross Aboukhadijeh
2016-03-05 19:24:42 -08:00
parent 1b269189b7
commit 52427dd183
2 changed files with 8 additions and 9 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