diff options
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/backend.js b/backend.js index 35362b3..23a9309 100644 --- a/backend.js +++ b/backend.js @@ -37,6 +37,8 @@ class Backend extends EventEmitter { this.throttleMetadata = throttlePromise(10) this.metadataDictionary = {} this.queueGrouplike = {name: 'Queue', isTheQueue: true, items: []} + this.pauseNextTrack = false + this.playedTrackToEnd = false this.rootDirectory = process.env.HOME + '/.mtui' this.metadataPath = this.rootDirectory + '/track-metadata.json' @@ -378,6 +380,10 @@ class Backend extends EventEmitter { this.player.setVolume(value) } + setPauseNextTrack(value) { + this.pauseNextTrack = !!value + } + async stopPlaying() { // We emit this so playTrack doesn't immediately start a new track. // We aren't *actually* about to play a new track. @@ -431,6 +437,13 @@ class Backend extends EventEmitter { this.emit('playing', this.playingTrack, oldTrack) await this.player.kill() + if (this.playedTrackToEnd) { + this.player.setPause(this.pauseNextTrack) + this.pauseNextTrack = false + this.playedTrackToEnd = false + } else { + this.player.setPause(false) + } await this.player.playFile(downloadFile) } @@ -438,6 +451,7 @@ class Backend extends EventEmitter { // (true), or was stopped by a different track being started (false). if (playingThisTrack) { + this.playedTrackToEnd = true if (!this.playNext(item)) { this.clearPlayingTrack() } |