mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Fix some stream bugs
This commit is contained in:
@@ -151,6 +151,7 @@ class VoiceBroadcast extends EventEmitter {
|
||||
if (this.currentTranscoder) {
|
||||
if (this.currentTranscoder.transcoder) this.currentTranscoder.transcoder.kill();
|
||||
this.currentTranscoder = null;
|
||||
this.emit('end');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,10 +226,7 @@ class VoiceBroadcast extends EventEmitter {
|
||||
* Emitted once the broadcast (the audio stream) ends
|
||||
* @event VoiceBroadcast#end
|
||||
*/
|
||||
transcoder.once('end', () => {
|
||||
this.emit('end');
|
||||
this.killCurrentTranscoder();
|
||||
});
|
||||
transcoder.once('end', () => this.killCurrentTranscoder());
|
||||
this.currentTranscoder = {
|
||||
transcoder,
|
||||
options,
|
||||
@@ -245,7 +243,6 @@ class VoiceBroadcast extends EventEmitter {
|
||||
*/
|
||||
playConvertedStream(stream, { seek = 0, volume = 1, passes = 1 } = {}) {
|
||||
this.killCurrentTranscoder();
|
||||
stream.once('end', () => this.emit('end'));
|
||||
const options = { seek, volume, passes, stream };
|
||||
this.currentTranscoder = { options };
|
||||
stream.once('readable', () => this._startPlaying());
|
||||
|
||||
@@ -160,7 +160,7 @@ class VoiceConnection extends EventEmitter {
|
||||
this.sockets.udp = new VoiceUDP(this);
|
||||
this.sockets.ws.on('error', e => this.emit('error', e));
|
||||
this.sockets.udp.on('error', e => this.emit('error', e));
|
||||
this.sockets.ws.once('ready', d => {
|
||||
this.sockets.ws.on('ready', d => {
|
||||
this.authentication.port = d.port;
|
||||
this.authentication.ssrc = d.ssrc;
|
||||
/**
|
||||
@@ -173,7 +173,7 @@ class VoiceConnection extends EventEmitter {
|
||||
this.sockets.udp.createUDPSocket(address);
|
||||
}, e => this.emit('error', e));
|
||||
});
|
||||
this.sockets.ws.once('sessionDescription', (mode, secret) => {
|
||||
this.sockets.ws.on('sessionDescription', (mode, secret) => {
|
||||
this.authentication.encryptionMode = mode;
|
||||
this.authentication.secretKey = secret;
|
||||
/**
|
||||
|
||||
@@ -172,7 +172,10 @@ class StreamDispatcher extends EventEmitter {
|
||||
this.setSpeaking(true);
|
||||
while (repeats--) {
|
||||
this.player.voiceConnection.sockets.udp.send(packet)
|
||||
.catch(e => this.emit('debug', `Failed to send a packet ${e}`));
|
||||
.catch(e => {
|
||||
this.setSpeaking(false);
|
||||
this.emit('debug', `Failed to send a packet ${e}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user