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);