From 3e992f8a1026c66fef23a9686c3198299fbd72b9 Mon Sep 17 00:00:00 2001 From: omar mashaal Date: Thu, 12 Jan 2017 16:27:59 +1100 Subject: [PATCH] clear player on album end --- components/player/index.js | 1 + index.js | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/player/index.js b/components/player/index.js index 7bd0012..8b62fcf 100644 --- a/components/player/index.js +++ b/components/player/index.js @@ -14,6 +14,7 @@ export default class Player { } next () { if (store.getState().player.next) this.playTrack(store.getState().player.next) + else this.stop() } stop () { remote.app.stop() diff --git a/index.js b/index.js index 3bcf209..4ad0cce 100644 --- a/index.js +++ b/index.js @@ -62,24 +62,26 @@ app.playTrack = file => { } else duration = false mainWindow.webContents.executeJavaScript(`window.player.setDuration(${duration})`) }) - player.on('exit', sss) - this.playing = this.cnt = true + player.on('exit', continous) + this.playing = true this.track = file } app.currentTrack = () => this.track -const sss = () => { - if (this.cnt) next() - else app.stop() +const continous = () => { + next() } let next = () => mainWindow.webContents.executeJavaScript('window.player.next()') app.stop = () => { - if (player) player.removeListener('exit', sss) - if (this.playing) player.kill() - player = this.playing = this.cnt = this.track = null + if (player) player.removeListener('exit', continous) + if (this.playing) { + player.kill() + mainWindow.webContents.executeJavaScript('window.player.stop()') + } + player = this.playing = this.track = null } app.pause = () => {