diff options
author | Florrie <towerofnix@gmail.com> | 2019-07-30 21:49:04 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-07-30 21:49:04 -0300 |
commit | 0e9b316165f8b6585d5822a8a3b8199b7ec3e671 (patch) | |
tree | 3f9a7810d524319591ca7b05de303a9b4a9c5816 /backend.js | |
parent | 182514a1e8170d124907b982f5f87f1bffad147c (diff) |
"Pause when this track ends" option
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() } |