« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'backend.js')
-rw-r--r--backend.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/backend.js b/backend.js
index 36344be..59c4a48 100644
--- a/backend.js
+++ b/backend.js
@@ -338,9 +338,11 @@ class QueuePlayer extends EventEmitter {
     }
   }
 
-  shuffleQueue() {
+  shuffleQueue(pastPlayingTrackOnly = true) {
     const queue = this.queueGrouplike
-    const index = queue.items.indexOf(this.playingTrack) + 1 // This is 0 if no track is playing
+    const index = (pastPlayingTrackOnly
+      ? queue.items.indexOf(this.playingTrack) + 1 // This is 0 if no track is playing
+      : 0)
     const initialItems = queue.items.slice(0, index)
     const remainingItems = queue.items.slice(index)
     const newItems = initialItems.concat(shuffleArray(remainingItems))
@@ -517,8 +519,7 @@ class QueuePlayer extends EventEmitter {
         this.playFirst()
         return true
       case 'shuffle':
-        this.clearPlayingTrack()
-        this.shuffleQueue()
+        this.shuffleQueue(false)
         this.playFirst()
         return true
       case 'end':