diff options
author | liam4 <towerofnix@gmail.com> | 2017-06-26 13:18:52 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-06-26 13:18:52 -0300 |
commit | 5145e5b38e5da33d18ce50181ba80040867bc8be (patch) | |
tree | d21637937ca4e2a582701be6f4d40464413d9d43 /src | |
parent | 3c0bfaf8560c13fc2efd80d3699ecb71122d3015 (diff) | |
parent | 4074b66746ac87aa1a655dfaa914e5e02b8f8221 (diff) |
Merge branch 'master' of https://github.com/liam4/http-music
Diffstat (limited to 'src')
-rw-r--r-- | src/loop-play.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/loop-play.js b/src/loop-play.js index e43cb31..597b58d 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -33,10 +33,10 @@ class DownloadController extends EventEmitter { async downloadNextHelper() { this.isDownloading = true - let wasDestroyed = false + const destroyedObj = {wasDestroyed: false} this._destroyDownload = () => { - wasDestroyed = true + destroyedObj.wasDestroyed = true } // We need to actually pick something to download; we'll use the picker @@ -79,13 +79,13 @@ class DownloadController extends EventEmitter { if (supportedFormats.includes(format)) { this.playFile = fromFile } else { - this.playFile = await this.convert(picked, fromFile) + this.playFile = await this.convert(picked, fromFile, destroyedObj) } // If this download was destroyed, we quit now; we don't want to emit that // the download was finished if the finished download was the destroyed // one! - if (wasDestroyed) { + if (destroyedObj.wasDestroyed) { return } @@ -131,7 +131,7 @@ class DownloadController extends EventEmitter { return formats } - async convert(picked, fromFile) { + async convert(picked, fromFile, destroyedObj) { // The "to" file is simply an MP3 file. We give this MP3 file a specific // name - the title of the track we got earlier, sanitized to be file-safe // - so that when `play` outputs the name of the song, it's obvious to the @@ -179,7 +179,7 @@ class DownloadController extends EventEmitter { // Usually we'll log a warning message saying that the convertion failed, // but if this download was destroyed, it's expected for the avconv // process to fail; so in that case we don't bother warning the user. - if (!wasDestroyed) { + if (!destroyedObj.wasDestroyed) { console.warn("Failed to convert " + title) console.warn("Selecting a new track") |