diff options
author | liam4 <towerofnix@gmail.com> | 2017-07-21 22:27:34 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-07-21 22:27:34 -0300 |
commit | b6e90e8f380569803b9a83f8997159b34d64e501 (patch) | |
tree | b2ac9c18415301e90dc9980255ea48e54a87b9f7 /src/loop-play.js | |
parent | 13ec7f5c5408c787e8e424a79ffeea281b044b6f (diff) |
Make some error handling for YouTube downloads
Diffstat (limited to 'src/loop-play.js')
-rw-r--r-- | src/loop-play.js | 26 |
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', [ |