« 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.js26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index 884d3cb..8fdbdf3 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -95,8 +95,11 @@ class PlayController {
 
     while (this.nextTrack) {
       this.currentTrack = this.nextTrack
+
       await Promise.all([
-        this.playFile(nextFile),
+        // If the downloader returns false, the file failed to download; that
+        // means we'll just skip this track and wait for the next.
+        nextFile !== false ? this.playFile(nextFile) : Promise.resolve(),
         downloadNext()
       ])
     }
@@ -115,27 +118,6 @@ class PlayController {
     }
   }
 
-  async old_loopPlay() {
-    // Playing music in a loop isn't particularly complicated; essentially, we
-    // just want to keep picking and playing tracks until none is picked.
-
-    let nextTrack = await this.picker()
-
-    await this.downloadManager.download(getDownloaderFor(nextTrack), nextTrack)
-
-    let downloadNext
-
-    while (nextTrack) {
-      this.currentTrack = nextTrack
-
-      this.downloadManager.download(getDownloaderFor(nextTrack), nextTrack)
-
-      await this.playFile(nextTrack[1])
-
-      nextTrack = await this.picker()
-    }
-  }
-
   playFile(file) {
     this.fifo = new FIFO()
     this.process = spawn('mpv', [