From bf4010e89c4403d73c4573553dd550018e262893 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Fri, 30 Dec 2016 12:46:34 +0000 Subject: [PATCH] Simplify broadcast creation --- src/client/voice/player/AudioPlayer.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/client/voice/player/AudioPlayer.js b/src/client/voice/player/AudioPlayer.js index b43edb443..22b5ae953 100644 --- a/src/client/voice/player/AudioPlayer.js +++ b/src/client/voice/player/AudioPlayer.js @@ -35,12 +35,6 @@ class AudioPlayer extends EventEmitter { } destroyStream(stream) { - if (stream instanceof VoiceBroadcast && this.streams.has(stream)) { - const data = this.streams.get(stream); - if (data.dispatcher) data.dispatcher.destroy('end'); - this.streams.delete(stream); - return; - } const data = this.streams.get(stream); if (!data) return; const transcoder = data.transcoder; @@ -89,11 +83,11 @@ class AudioPlayer extends EventEmitter { playBroadcast(broadcast, { volume = 1, passes = 1 } = {}) { const options = { volume, passes }; this.destroyAllStreams(); - this.streams.set(broadcast, broadcast); const dispatcher = new StreamDispatcher(this, broadcast, options); dispatcher.on('end', () => this.destroyStream(broadcast)); dispatcher.on('error', () => this.destroyStream(broadcast)); dispatcher.on('speaking', value => this.voiceConnection.setSpeaking(value)); + this.streams.set(broadcast, { dispatcher, input: broadcast }); broadcast.registerDispatcher(dispatcher); return dispatcher; }