Video controls: never hide when paused

Also simplifies CSS
This commit is contained in:
DC
2016-03-08 01:47:32 -08:00
parent 4085dd1062
commit 4c03e98a19
5 changed files with 26 additions and 23 deletions

View File

@@ -11,10 +11,21 @@ var TorrentList = require('./torrent-list')
var isOSX = process.platform === 'darwin'
function App (state, dispatch) {
// Hide player controls while playing video, if the mouse stays still for a while
// Never hide the controls when:
// * The mouse is over the controls or we're scrubbing (see CSS)
// * The video is paused
var isVideoPlayer = state.url === '/player'
var hideControls = isVideoPlayer &&
state.video.mouseStationarySince !== 0 &&
new Date().getTime() - state.video.mouseStationarySince > 2000 &&
!state.video.isPaused
var cls = [
process.platform,
process.platform, /* 'windows', 'linux', or 'darwin' for OSX */
state.isFullScreen ? 'fullscreen' : 'not-fullscreen',
state.url === '/player' ? 'view-player' : ''
isVideoPlayer ? 'view-player' : '',
hideControls ? 'hide-video-controls' : ''
]
return hx`

View File

@@ -5,12 +5,8 @@ var hyperx = require('hyperx')
var hx = hyperx(h)
function Header (state, dispatch) {
var hideControls = state.url === '/player' &&
state.video.mouseStationarySince !== 0 &&
new Date().getTime() - state.video.mouseStationarySince > 2000
return hx`
<div class='header ${hideControls ? 'hide' : ''}'>
<div class='header'>
${getTitle()}
<div class='nav left'>
<i

View File

@@ -23,14 +23,10 @@ function Player (state, dispatch) {
state.video.duration = videoElement.duration
}
// When in fullscreen, hide player controls if the mouse stays still for a while
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' : ''}'
class='player'
onmousemove=${() => dispatch('videoMouseMoved')}>
<div
class='letterbox'