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 () {
const loc = this.props.state.location
return (
<div className='header' onMouseMove={dispatcher('mediaMouseMoved')}>
<div className='header'
onMouseMove={dispatcher('mediaMouseMoved')}
onMouseEnter={dispatcher('mediaControlsMouseEnter')}
onMouseLeave={dispatcher('mediaControlsMouseLeave')}>
{this.getTitle()}
<div className='nav left float-left'>
<i

View File

@@ -44,6 +44,16 @@ module.exports = class MediaController {
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 () {
const state = 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
showOrHidePlayerControls () {
const state = this.state
const hideControls = state.location.url() === 'player' &&
state.playing.mouseStationarySince !== 0 &&
new Date().getTime() - state.playing.mouseStationarySince > 2000 &&
!state.playing.isPaused &&
state.playing.location === 'local'
const hideControls = state.shouldHidePlayerControls()
if (hideControls !== state.playing.hideControls) {
state.playing.hideControls = hideControls
@@ -230,7 +226,7 @@ module.exports = class PlaybackController {
}
// Starts WebTorrent server for media streaming
startServer (torrentSummary, cb) {
startServer (torrentSummary) {
if (torrentSummary.status === 'paused') {
dispatch('startTorrentingSummary', torrentSummary.torrentKey)
ipcRenderer.once('wt-ready-' + torrentSummary.infoHash,

View File

@@ -73,7 +73,8 @@ function getDefaultState () {
*/
getPlayingTorrentSummary,
getPlayingFileSummary,
getExternalPlayerName
getExternalPlayerName,
shouldHidePlayerControls
}
}
@@ -180,6 +181,16 @@ function getExternalPlayerName () {
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) {
appConfig.read(function (err, saved) {
if (err || !saved.version) {

View File

@@ -222,6 +222,8 @@ const dispatchHandlers = {
'mediaSuccess': () => controllers.media.mediaSuccess(),
'mediaTimeUpdate': () => controllers.media.mediaTimeUpdate(),
'mediaMouseMoved': () => controllers.media.mediaMouseMoved(),
'mediaControlsMouseEnter': () => controllers.media.controlsMouseEnter(),
'mediaControlsMouseLeave': () => controllers.media.controlsMouseLeave(),
'openExternalPlayer': () => controllers.media.openExternalPlayer(),
'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 video is paused
// * The video is playing remotely on Chromecast or Airplay
const hideControls = state.location.url() === 'player' &&
state.playing.mouseStationarySince !== 0 &&
new Date().getTime() - state.playing.mouseStationarySince > 2000 &&
!state.playing.isPaused &&
state.playing.location === 'local' &&
state.playing.playbackRate === 1
const hideControls = state.shouldHidePlayerControls()
const cls = [
'view-' + state.location.url(), /* e.g. view-home, view-player */

View File

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