From 77a0c022fa755dd9bb1a040c29792b16f5b914d6 Mon Sep 17 00:00:00 2001 From: Killer069 <65385476+killer069@users.noreply.github.com> Date: Sun, 7 Nov 2021 16:00:56 +0530 Subject: [PATCH] Streams now gets ended when piping --- play-dl/SoundCloud/classes.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/play-dl/SoundCloud/classes.ts b/play-dl/SoundCloud/classes.ts index 22e59ba..b524eed 100644 --- a/play-dl/SoundCloud/classes.ts +++ b/play-dl/SoundCloud/classes.ts @@ -260,10 +260,15 @@ export class Stream { } private async loop() { - if (this.stream.destroyed || this.time.length === 0 || this.segment_urls.length === 0) { + if (this.stream.destroyed) { this.cleanup(); return; } + if(this.time.length === 0 || this.segment_urls.length === 0) { + this.cleanup(); + this.stream.push(null); + return; + } this.downloaded_time += this.time.shift() as number; this.downloaded_segments++; const stream = await request_stream(this.segment_urls.shift() as string).catch((err: Error) => err);