mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
Delete stream setups after they have ended or errored
This commit is contained in:
@@ -57,7 +57,7 @@ class AudioPlayer extends EventEmitter {
|
|||||||
media: stream,
|
media: stream,
|
||||||
ffmpegArguments: ffmpegArguments.concat(['-ss', String(seek)]),
|
ffmpegArguments: ffmpegArguments.concat(['-ss', String(seek)]),
|
||||||
});
|
});
|
||||||
this.streams.set(stream, { transcoder });
|
this.streams.set(transcoder.output, { transcoder, input: stream });
|
||||||
transcoder.on('error', e => {
|
transcoder.on('error', e => {
|
||||||
this.destroyStream(stream);
|
this.destroyStream(stream);
|
||||||
if (this.listenerCount('error') > 0) this.emit('error', e);
|
if (this.listenerCount('error') > 0) this.emit('error', e);
|
||||||
@@ -68,11 +68,13 @@ class AudioPlayer extends EventEmitter {
|
|||||||
|
|
||||||
playPCMStream(stream, { seek = 0, volume = 1, passes = 1 } = {}) {
|
playPCMStream(stream, { seek = 0, volume = 1, passes = 1 } = {}) {
|
||||||
const options = { seek, volume, passes };
|
const options = { seek, volume, passes };
|
||||||
this.destroyAllStreams(true);
|
this.destroyAllStreams(stream);
|
||||||
const dispatcher = new StreamDispatcher(this, stream, options);
|
const dispatcher = new StreamDispatcher(this, stream, options);
|
||||||
dispatcher.on('speaking', value => this.voiceConnection.setSpeaking(value));
|
dispatcher.on('speaking', value => this.voiceConnection.setSpeaking(value));
|
||||||
if (!this.streams.has(stream)) this.streams.set(stream, { dispatcher });
|
if (!this.streams.has(stream)) this.streams.set(stream, { dispatcher, input: stream });
|
||||||
this.streams.get(stream).dispatcher = dispatcher;
|
this.streams.get(stream).dispatcher = dispatcher;
|
||||||
|
dispatcher.on('end', () => this.destroyStream(stream));
|
||||||
|
dispatcher.on('error', () => this.destroyStream(stream));
|
||||||
return dispatcher;
|
return dispatcher;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user