mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +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.count++;
|
||||||
data.sequence = (data.sequence + 1) < 65536 ? data.sequence + 1 : 0;
|
data.sequence = (data.sequence + 1) < 65536 ? data.sequence + 1 : 0;
|
||||||
data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
||||||
|
|
||||||
this.sendBuffer(buffer, data.sequence, data.timestamp);
|
this.sendBuffer(buffer, data.sequence, data.timestamp);
|
||||||
|
|
||||||
const nextTime = data.length + (data.startTime + data.pausedTime + (data.count * data.length) - Date.now());
|
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.length = 20;
|
||||||
data.missed = 0;
|
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)); }
|
setPaused(paused) { this.setSpeaking(!(this.paused = paused)); }
|
||||||
|
|||||||
@@ -169,7 +169,9 @@ client.on('message', msg => {
|
|||||||
if (msg.content.startsWith('/play')) {
|
if (msg.content.startsWith('/play')) {
|
||||||
console.log('I am now going to play', msg.content);
|
console.log('I am now going to play', msg.content);
|
||||||
const chan = msg.content.split(' ').slice(1).join(' ');
|
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')) {
|
if (msg.content.startsWith('/join')) {
|
||||||
const chan = msg.content.split(' ').slice(1).join(' ');
|
const chan = msg.content.split(' ').slice(1).join(' ');
|
||||||
@@ -177,7 +179,9 @@ client.on('message', msg => {
|
|||||||
.then(conn => {
|
.then(conn => {
|
||||||
con = conn;
|
con = conn;
|
||||||
msg.reply('done');
|
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('debug', console.log);
|
||||||
conn.player.on('error', err => console.log(123, err));
|
conn.player.on('error', err => console.log(123, err));
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user