mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fix weird audio playback bug between subsequent streams on an AudioPlayer
This commit is contained in:
@@ -217,7 +217,6 @@ class StreamDispatcher extends EventEmitter {
|
||||
data.count++;
|
||||
data.sequence = (data.sequence + 1) < 65536 ? data.sequence + 1 : 0;
|
||||
data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
||||
|
||||
this.sendBuffer(buffer, data.sequence, data.timestamp);
|
||||
|
||||
const nextTime = data.length + (data.startTime + data.pausedTime + (data.count * data.length) - Date.now());
|
||||
@@ -247,7 +246,11 @@ class StreamDispatcher extends EventEmitter {
|
||||
data.length = 20;
|
||||
data.missed = 0;
|
||||
|
||||
this.stream.once('readable', () => this.process());
|
||||
this.stream.once('readable', () => {
|
||||
data.startTime = null;
|
||||
data.count = 0;
|
||||
this.process();
|
||||
});
|
||||
}
|
||||
|
||||
setPaused(paused) { this.setSpeaking(!(this.paused = paused)); }
|
||||
|
||||
@@ -169,7 +169,9 @@ client.on('message', msg => {
|
||||
if (msg.content.startsWith('/play')) {
|
||||
console.log('I am now going to play', msg.content);
|
||||
const chan = msg.content.split(' ').slice(1).join(' ');
|
||||
con.playStream(ytdl(chan, {filter : 'audioonly'}), { passes : 4 });
|
||||
const s = ytdl(chan, {filter:'audioonly'}, { passes : 3 });
|
||||
s.on('error', e => console.log(`e w stream 1 ${e}`));
|
||||
con.playStream(s);
|
||||
}
|
||||
if (msg.content.startsWith('/join')) {
|
||||
const chan = msg.content.split(' ').slice(1).join(' ');
|
||||
@@ -177,7 +179,9 @@ client.on('message', msg => {
|
||||
.then(conn => {
|
||||
con = conn;
|
||||
msg.reply('done');
|
||||
disp = conn.playStream(ytdl(song, {filter:'audioonly'}), { passes : 3 });
|
||||
const s = ytdl(song, {filter:'audioonly'}, { passes : 3 });
|
||||
s.on('error', e => console.log(`e w stream 2 ${e}`));
|
||||
disp = conn.playStream(s);
|
||||
conn.player.on('debug', console.log);
|
||||
conn.player.on('error', err => console.log(123, err));
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user