Streams now gets ended when piping

This commit is contained in:
Killer069 2021-11-07 16:00:56 +05:30 committed by GitHub
parent 0e881ea0c5
commit 77a0c022fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -260,10 +260,15 @@ export class Stream {
} }
private async loop() { private async loop() {
if (this.stream.destroyed || this.time.length === 0 || this.segment_urls.length === 0) { if (this.stream.destroyed) {
this.cleanup(); this.cleanup();
return; 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_time += this.time.shift() as number;
this.downloaded_segments++; this.downloaded_segments++;
const stream = await request_stream(this.segment_urls.shift() as string).catch((err: Error) => err); const stream = await request_stream(this.segment_urls.shift() as string).catch((err: Error) => err);