diff options
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/backend.js b/backend.js index 379a16b..0cceeea 100644 --- a/backend.js +++ b/backend.js @@ -57,6 +57,7 @@ async function download(item, record) { class QueuePlayer extends EventEmitter { constructor({ + getPlayer, getRecordFor }) { super() @@ -68,11 +69,12 @@ class QueuePlayer extends EventEmitter { this.playedTrackToEnd = false this.timeData = null + this.getPlayer = getPlayer this.getRecordFor = getRecordFor } async setup() { - this.player = await getPlayer() + this.player = await this.getPlayer() if (!this.player) { return { @@ -560,9 +562,19 @@ class QueuePlayer extends EventEmitter { } class Backend extends EventEmitter { - constructor() { + constructor({ + playerName = null, + playerOptions = [] + } = {}) { super() + this.playerName = playerName; + this.playerOptions = playerOptions; + + if (playerOptions && !playerName) { + throw new Error(`Must specify playerName to specify playerOptions`); + } + this.queuePlayers = [] this.recordStore = new RecordStore() @@ -586,6 +598,7 @@ class Backend extends EventEmitter { async addQueuePlayer() { const queuePlayer = new QueuePlayer({ + getPlayer: () => getPlayer(this.playerName, this.playerOptions), getRecordFor: item => this.getRecordFor(item) }) |