« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/loop-play.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/loop-play.js')
-rw-r--r--src/loop-play.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index c95c1c4..24134b0 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -350,10 +350,12 @@ class PlayController extends EventEmitter {
     })
   }
 
-  startNextDownload() {
+  startNextDownload(moveTimelineIndex = true) {
     this.isDownloading = true
 
-    const picked = this.historyController.getNextTrack()
+    const picked = (moveTimelineIndex
+      ? this.historyController.getNextTrack()
+      : this.historyController.currentTrack)
     this.nextTrack = picked
 
     if (!picked) {
@@ -413,8 +415,13 @@ class PlayController extends EventEmitter {
       await safeUnlink(this.nextFile, this.playlist)
     }
 
+    // The timeline is always one index ahead.
+    const tl = this.historyController.timeline
+    tl.splice(this.historyController.timelineIndex - 1, 1)
+    this.historyController.fillTimeline()
+
     this.downloadController.cancel()
-    return this.startNextDownload()
+    return this.startNextDownload(false)
   }
 
   async stop() {