From 8512c44b6403c126bf961c0fd0c2798d6bfdfcea Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 6 Jul 2019 00:16:02 -0300 Subject: Experimental telnet server --- backend.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'backend.js') diff --git a/backend.js b/backend.js index c59121a..35362b3 100644 --- a/backend.js +++ b/backend.js @@ -175,6 +175,7 @@ class Backend extends EventEmitter { } recursivelyAddTracks(topItem) + this.emitQueueUpdated() // This is the first new track, if a group was queued. const newTrack = items[newTrackIndex] @@ -249,6 +250,8 @@ class Backend extends EventEmitter { items.splice(insertIndex, 0, item) } } + + this.emitQueueUpdated() } unqueue(topItem, focusItem = null) { @@ -292,6 +295,7 @@ class Backend extends EventEmitter { } recursivelyUnqueueTracks(topItem) + this.emitQueueUpdated() return focusItem } @@ -323,6 +327,7 @@ class Backend extends EventEmitter { const remainingItems = queue.items.slice(index) const newItems = initialItems.concat(shuffleArray(remainingItems)) queue.items = newItems + this.emitQueueUpdated() } clearQueue() { @@ -330,8 +335,12 @@ class Backend extends EventEmitter { // the track that's currently playing). this.queueGrouplike.items = this.queueGrouplike.items .filter(item => item === this.playingTrack) + this.emitQueueUpdated() } + emitQueueUpdated() { + this.emit('queue updated') + } seekAhead(seconds) { this.player.seekAhead(seconds) @@ -369,11 +378,11 @@ class Backend extends EventEmitter { this.player.setVolume(value) } - stopPlaying() { + async stopPlaying() { // We emit this so playTrack doesn't immediately start a new track. // We aren't *actually* about to play a new track. this.emit('playing new track') - this.player.kill() + await this.player.kill() this.clearPlayingTrack() } -- cgit 1.3.0-6-gf8a5