mirror of
https://github.com/danbulant/discord.js
synced 2026-06-07 08:41:29 +00:00
fix: StreamDispatcher doesn't emit finish if ended while paused (#2648)
This commit is contained in:
parent
edf9c448fb
commit
bfde1dd8f2
1 changed files with 5 additions and 1 deletions
|
|
@ -121,8 +121,11 @@ class StreamDispatcher extends Writable {
|
||||||
* Pauses playback
|
* Pauses playback
|
||||||
*/
|
*/
|
||||||
pause() {
|
pause() {
|
||||||
|
if (this.paused) return;
|
||||||
|
if (this.streams.opus) this.streams.opus.unpipe(this);
|
||||||
|
this._writeCallback();
|
||||||
this._setSpeaking(false);
|
this._setSpeaking(false);
|
||||||
if (!this.paused) this.pausedSince = Date.now();
|
this.pausedSince = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -142,6 +145,7 @@ class StreamDispatcher extends Writable {
|
||||||
*/
|
*/
|
||||||
resume() {
|
resume() {
|
||||||
if (!this.pausedSince) return;
|
if (!this.pausedSince) return;
|
||||||
|
if (this.streams.opus) this.streams.opus.pipe(this);
|
||||||
this._pausedTime += Date.now() - this.pausedSince;
|
this._pausedTime += Date.now() - this.pausedSince;
|
||||||
this.pausedSince = null;
|
this.pausedSince = null;
|
||||||
if (typeof this._writeCallback === 'function') this._writeCallback();
|
if (typeof this._writeCallback === 'function') this._writeCallback();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue