Disable playback controls while in external player (#909)

This commit is contained in:
Adam Gotlib
2016-09-07 22:13:50 +02:00
committed by DC
parent 8da5b955d6
commit d88229694a
3 changed files with 12 additions and 7 deletions

View File

@@ -58,7 +58,7 @@ function init () {
*/ */
ipc.on('onPlayerOpen', function () { ipc.on('onPlayerOpen', function () {
menu.setPlayerOpen(true) menu.togglePlaybackControls(true)
powerSaveBlocker.enable() powerSaveBlocker.enable()
shortcuts.enable() shortcuts.enable()
thumbar.enable() thumbar.enable()
@@ -70,7 +70,7 @@ function init () {
}) })
ipc.on('onPlayerClose', function () { ipc.on('onPlayerClose', function () {
menu.setPlayerOpen(false) menu.togglePlaybackControls(false)
powerSaveBlocker.disable() powerSaveBlocker.disable()
shortcuts.disable() shortcuts.disable()
thumbar.disable() thumbar.disable()
@@ -126,7 +126,12 @@ function init () {
}) })
}) })
ipc.on('openExternalPlayer', (e, ...args) => externalPlayer.spawn(...args)) ipc.on('openExternalPlayer', (e, ...args) => {
menu.togglePlaybackControls(false)
thumbar.disable()
externalPlayer.spawn(...args)
})
ipc.on('quitExternalPlayer', () => externalPlayer.kill()) ipc.on('quitExternalPlayer', () => externalPlayer.kill())
// Capture all events // Capture all events

View File

@@ -1,6 +1,6 @@
module.exports = { module.exports = {
init, init,
setPlayerOpen, togglePlaybackControls,
setWindowFocus, setWindowFocus,
setAllowNav, setAllowNav,
onPlayerUpdate, onPlayerUpdate,
@@ -24,7 +24,7 @@ function init () {
electron.Menu.setApplicationMenu(menu) electron.Menu.setApplicationMenu(menu)
} }
function setPlayerOpen (flag) { function togglePlaybackControls (flag) {
getMenuItem('Play/Pause').enabled = flag getMenuItem('Play/Pause').enabled = flag
getMenuItem('Skip Next').enabled = flag getMenuItem('Skip Next').enabled = flag
getMenuItem('Skip Previous').enabled = flag getMenuItem('Skip Previous').enabled = flag

View File

@@ -87,7 +87,7 @@ module.exports = class PlaybackController {
// Play next file in list (if any) // Play next file in list (if any)
nextTrack () { nextTrack () {
const state = this.state const state = this.state
if (Playlist.hasNext(state)) { if (Playlist.hasNext(state) && state.playing.location !== 'external') {
this.updatePlayer( this.updatePlayer(
state.playing.infoHash, Playlist.getNextIndex(state), false, (err) => { state.playing.infoHash, Playlist.getNextIndex(state), false, (err) => {
if (err) dispatch('error', err) if (err) dispatch('error', err)
@@ -99,7 +99,7 @@ module.exports = class PlaybackController {
// Play previous track in list (if any) // Play previous track in list (if any)
previousTrack () { previousTrack () {
const state = this.state const state = this.state
if (Playlist.hasPrevious(state)) { if (Playlist.hasPrevious(state) && state.playing.location !== 'external') {
this.updatePlayer( this.updatePlayer(
state.playing.infoHash, Playlist.getPreviousIndex(state), false, (err) => { state.playing.infoHash, Playlist.getPreviousIndex(state), false, (err) => {
if (err) dispatch('error', err) if (err) dispatch('error', err)