diff --git a/src/client/voice/dispatcher/StreamDispatcher.js b/src/client/voice/dispatcher/StreamDispatcher.js index 6e3cfd207..49c883b7a 100644 --- a/src/client/voice/dispatcher/StreamDispatcher.js +++ b/src/client/voice/dispatcher/StreamDispatcher.js @@ -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)); } diff --git a/test/random.js b/test/random.js index e4a0569a8..0a4a2e071 100644 --- a/test/random.js +++ b/test/random.js @@ -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)); })