Don't hide header when moused over player controls

This commit is contained in:
DC
2016-09-23 02:38:39 -07:00
parent 5155fca0e4
commit 789bd0ce82
7 changed files with 36 additions and 19 deletions

View File

@@ -6,7 +6,10 @@ class Header extends React.Component {
render () { render () {
const loc = this.props.state.location const loc = this.props.state.location
return ( return (
<div className='header' onMouseMove={dispatcher('mediaMouseMoved')}> <div className='header'
onMouseMove={dispatcher('mediaMouseMoved')}
onMouseEnter={dispatcher('mediaControlsMouseEnter')}
onMouseLeave={dispatcher('mediaControlsMouseLeave')}>
{this.getTitle()} {this.getTitle()}
<div className='nav left float-left'> <div className='nav left float-left'>
<i <i

View File

@@ -44,6 +44,16 @@ module.exports = class MediaController {
this.state.playing.mouseStationarySince = new Date().getTime() this.state.playing.mouseStationarySince = new Date().getTime()
} }
controlsMouseEnter () {
this.state.playing.mouseInControls = true
this.state.playing.mouseStationarySince = new Date().getTime()
}
controlsMouseLeave () {
this.state.playing.mouseInControls = false
this.state.playing.mouseStationarySince = new Date().getTime()
}
openExternalPlayer () { openExternalPlayer () {
const state = this.state const state = this.state
const mediaURL = Playlist.getCurrentLocalURL(this.state) const mediaURL = Playlist.getCurrentLocalURL(this.state)

View File

@@ -201,11 +201,7 @@ module.exports = class PlaybackController {
// * The video is playing remotely on Chromecast or Airplay // * The video is playing remotely on Chromecast or Airplay
showOrHidePlayerControls () { showOrHidePlayerControls () {
const state = this.state const state = this.state
const hideControls = state.location.url() === 'player' && const hideControls = state.shouldHidePlayerControls()
state.playing.mouseStationarySince !== 0 &&
new Date().getTime() - state.playing.mouseStationarySince > 2000 &&
!state.playing.isPaused &&
state.playing.location === 'local'
if (hideControls !== state.playing.hideControls) { if (hideControls !== state.playing.hideControls) {
state.playing.hideControls = hideControls state.playing.hideControls = hideControls
@@ -230,7 +226,7 @@ module.exports = class PlaybackController {
} }
// Starts WebTorrent server for media streaming // Starts WebTorrent server for media streaming
startServer (torrentSummary, cb) { startServer (torrentSummary) {
if (torrentSummary.status === 'paused') { if (torrentSummary.status === 'paused') {
dispatch('startTorrentingSummary', torrentSummary.torrentKey) dispatch('startTorrentingSummary', torrentSummary.torrentKey)
ipcRenderer.once('wt-ready-' + torrentSummary.infoHash, ipcRenderer.once('wt-ready-' + torrentSummary.infoHash,

View File

@@ -73,7 +73,8 @@ function getDefaultState () {
*/ */
getPlayingTorrentSummary, getPlayingTorrentSummary,
getPlayingFileSummary, getPlayingFileSummary,
getExternalPlayerName getExternalPlayerName,
shouldHidePlayerControls
} }
} }
@@ -180,6 +181,16 @@ function getExternalPlayerName () {
return path.basename(playerPath).split('.')[0] return path.basename(playerPath).split('.')[0]
} }
function shouldHidePlayerControls () {
return this.location.url() === 'player' &&
this.playing.mouseStationarySince !== 0 &&
new Date().getTime() - this.playing.mouseStationarySince > 2000 &&
!this.playing.mouseInControls &&
!this.playing.isPaused &&
this.playing.location === 'local' &&
this.playing.playbackRate === 1
}
function load (cb) { function load (cb) {
appConfig.read(function (err, saved) { appConfig.read(function (err, saved) {
if (err || !saved.version) { if (err || !saved.version) {

View File

@@ -222,6 +222,8 @@ const dispatchHandlers = {
'mediaSuccess': () => controllers.media.mediaSuccess(), 'mediaSuccess': () => controllers.media.mediaSuccess(),
'mediaTimeUpdate': () => controllers.media.mediaTimeUpdate(), 'mediaTimeUpdate': () => controllers.media.mediaTimeUpdate(),
'mediaMouseMoved': () => controllers.media.mediaMouseMoved(), 'mediaMouseMoved': () => controllers.media.mediaMouseMoved(),
'mediaControlsMouseEnter': () => controllers.media.controlsMouseEnter(),
'mediaControlsMouseLeave': () => controllers.media.controlsMouseLeave(),
'openExternalPlayer': () => controllers.media.openExternalPlayer(), 'openExternalPlayer': () => controllers.media.openExternalPlayer(),
'externalPlayerNotFound': () => controllers.media.externalPlayerNotFound(), 'externalPlayerNotFound': () => controllers.media.externalPlayerNotFound(),

View File

@@ -43,12 +43,7 @@ class App extends React.Component {
// * The mouse is over the controls or we're scrubbing (see CSS) // * The mouse is over the controls or we're scrubbing (see CSS)
// * The video is paused // * The video is paused
// * The video is playing remotely on Chromecast or Airplay // * The video is playing remotely on Chromecast or Airplay
const hideControls = state.location.url() === 'player' && const hideControls = state.shouldHidePlayerControls()
state.playing.mouseStationarySince !== 0 &&
new Date().getTime() - state.playing.mouseStationarySince > 2000 &&
!state.playing.isPaused &&
state.playing.location === 'local' &&
state.playing.playbackRate === 1
const cls = [ const cls = [
'view-' + state.location.url(), /* e.g. view-home, view-player */ 'view-' + state.location.url(), /* e.g. view-home, view-player */

View File

@@ -438,7 +438,7 @@ function renderPlayerControls (state) {
] ]
if (state.playing.type === 'video') { if (state.playing.type === 'video') {
// show closed captions icon // Show closed captions icon
elements.push(( elements.push((
<i <i
key='subtitles' key='subtitles'
@@ -506,8 +506,6 @@ function renderPlayerControls (state) {
'color-stop(' + (volume * 100) + '%, #727272))' 'color-stop(' + (volume * 100) + '%, #727272))'
} }
// TODO: dcposch change the range input to use value / onChanged instead of
// "readonly" / onMouse[Down,Move,Up]
elements.push(( elements.push((
<div key='volume' className='volume float-left'> <div key='volume' className='volume float-left'>
<i <i
@@ -533,7 +531,7 @@ function renderPlayerControls (state) {
</span> </span>
)) ))
// render playback rate // Render playback rate
if (state.playing.playbackRate !== 1) { if (state.playing.playbackRate !== 1) {
elements.push(( elements.push((
<span key='rate' className='rate float-left'> <span key='rate' className='rate float-left'>
@@ -543,7 +541,9 @@ function renderPlayerControls (state) {
} }
return ( return (
<div key='controls' className='controls'> <div key='controls' className='controls'
onMouseEnter={dispatcher('mediaControlsMouseEnter')}
onMouseLeave={dispatcher('mediaControlsMouseLeave')}>
{elements} {elements}
{renderCastOptions(state)} {renderCastOptions(state)}
{renderSubtitleOptions(state)} {renderSubtitleOptions(state)}