diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-10-10 10:46:23 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2021-10-10 10:48:58 -0300 |
commit | ec0b00d62f5fe02248de71552f5cd3d76589295c (patch) | |
tree | 6f96214fcc73d9bf5228ed530b4682bc67812b39 /backend.js | |
parent | 3fdb4b7961f55a6b0fa24a3f271c3c8090497856 (diff) |
"Loop mode" option: no loop, loop, shuffle
This also reorganizes the menubar options a little.
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/backend.js b/backend.js index e38fe2f..41107d7 100644 --- a/backend.js +++ b/backend.js @@ -66,7 +66,7 @@ class QueuePlayer extends EventEmitter { this.playingTrack = null this.queueGrouplike = {name: 'Queue', isTheQueue: true, items: []} this.pauseNextTrack = false - this.loopQueueAtEnd = false + this.queueEndMode = 'end' // end, loop, shuffle this.playedTrackToEnd = false this.timeData = null @@ -435,10 +435,18 @@ class QueuePlayer extends EventEmitter { if (playingThisTrack) { this.playedTrackToEnd = true if (!this.playNext(item)) { - if (this.loopQueueAtEnd) { - this.playFirst() - } else { - this.clearPlayingTrack() + switch (this.queueEndMode) { + case 'loop': + this.playFirst() + break + case 'shuffle': + this.clearPlayingTrack() + this.shuffleQueue() + this.playFirst() + break + case 'end': + default: + this.clearPlayingTrack() } } } |