diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-03-15 20:57:02 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-03-15 20:57:02 -0300 |
commit | 7dfc24b445d96f46049ea680cd8b81e7200baa71 (patch) | |
tree | feacad19d97dfc722ab81a808f49a4cd6b73dd93 /backend.js | |
parent | 3d6c5b9bb1f9a42cebc61cbe3b0b5fb69bc146e8 (diff) | |
parent | e13e8790feaaa736aab69191996734a14c808012 (diff) |
Merge branch 'master' into socket-mtui
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/backend.js b/backend.js index f2610d0..d222d10 100644 --- a/backend.js +++ b/backend.js @@ -69,13 +69,14 @@ class QueuePlayer extends EventEmitter { this.playingTrack = null this.queueGrouplike = {name: 'Queue', isTheQueue: true, items: []} this.pauseNextTrack = false - this.alwaysStartPaused = false - this.waitWhenDonePlaying = false - + this.loopQueueAtEnd = false this.playedTrackToEnd = false this.timeData = null this.time = null + this.alwaysStartPaused = false + this.waitWhenDonePlaying = false + this.getPlayer = getPlayer this.getRecordFor = getRecordFor } @@ -460,8 +461,14 @@ class QueuePlayer extends EventEmitter { if (playingThisTrack) { this.playedTrackToEnd = true this.emit('done playing', this.playingTrack) - if (!this.waitWhenDonePlaying && !this.playNext(item)) { - this.clearPlayingTrack() + if (!this.waitWhenDonePlaying) { + if (!this.playNext(item)) { + if (this.loopQueueAtEnd) { + this.playFirst() + } else { + this.clearPlayingTrack() + } + } } } } @@ -524,6 +531,15 @@ class QueuePlayer extends EventEmitter { return true } + playFirst() { + const queue = this.queueGrouplike + if (queue.items.length) { + this.play(queue.items[0]) + return true + } + return false + } + clearPlayingTrack() { if (this.playingTrack !== null) { const oldTrack = this.playingTrack @@ -609,6 +625,10 @@ class QueuePlayer extends EventEmitter { this.emit('set-pause-next-track', !!value) } + setLoopQueueAtEnd(value) { + this.loopQueueAtEnd = !!value + } + get remainingTracks() { const index = this.queueGrouplike.items.indexOf(this.playingTrack) const length = this.queueGrouplike.items.length |