Add VoiceBroadcast.pause and VoiceBroadcast.resume

This commit is contained in:
Amish Shah
2016-12-29 21:59:36 +00:00
parent ad18b05d66
commit 12605575fb
2 changed files with 15 additions and 0 deletions

View File

@@ -77,6 +77,20 @@ class VoiceBroadcast extends EventEmitter {
return this;
}
pause() {
for (const dispatcher of this.dispatchers) {
dispatcher.pause();
}
clearInterval(this.tickInterval);
}
resume() {
for (const dispatcher of this.dispatchers) {
dispatcher.resume();
}
this._startPlaying();
}
_startPlaying() {
if (this.tickInterval) clearInterval(this.tickInterval);
this.tickInterval = this.client.setInterval(this.tick.bind(this), 20);

View File

@@ -183,6 +183,7 @@ class StreamDispatcher extends EventEmitter {
}
if (this.paused) {
this.setSpeaking(false);
// data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
data.pausedTime += data.length * 10;
// if buffer is provided we are assuming a master process is controlling the dispatcher