From ec0b00d62f5fe02248de71552f5cd3d76589295c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 10 Oct 2021 10:46:23 -0300 Subject: "Loop mode" option: no loop, loop, shuffle This also reorganizes the menubar options a little. --- backend.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'backend.js') 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() } } } -- cgit 1.3.0-6-gf8a5