From 88dd9466e513bb562e242d152765ec204e2e2b2d Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 22 Sep 2019 12:43:34 -0300 Subject: Basic multiple player UI Currently uses meta+(c, x, n, p, up, down) keys as the only interaction method, but that'll change soon! --- backend.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'backend.js') diff --git a/backend.js b/backend.js index e8601c5..d3e0db7 100644 --- a/backend.js +++ b/backend.js @@ -374,7 +374,7 @@ class QueuePlayer extends EventEmitter { } this.playingTrack = item - this.emit('playing', this.playingTrack, oldTrack) + this.emit('playing', this.playingTrack, oldTrack, this) await this.player.kill() if (this.playedTrackToEnd) { @@ -455,7 +455,7 @@ class QueuePlayer extends EventEmitter { const oldTrack = this.playingTrack this.playingTrack = null this.timeData = null - this.emit('playing', null, oldTrack) + this.emit('playing', null, oldTrack, this) } } @@ -574,6 +574,13 @@ class Backend extends EventEmitter { return queuePlayer } + removeQueuePlayer(queuePlayer) { + if (this.queuePlayers.length > 1) { + this.queuePlayers.splice(this.queuePlayers.indexOf(queuePlayer), 1) + this.emit('removed queue player', queuePlayer) + } + } + async readMetadata() { try { return JSON.parse(await readFile(this.metadataPath)) -- cgit 1.3.0-6-gf8a5