video segment fetch loop, it just works

This commit is contained in:
Muaz Ahmad 2023-08-24 00:11:09 +05:00
parent 24b896824f
commit 85cbf0e335

View file

@ -58,6 +58,16 @@ class VideoLoader {
this.media_buffer = this.media_source.addSourceBuffer(mime);
this.media_buffer.mode = 'segments';
this.media_buffer.appendBuffer(init_frag);
this.fetch_new_segments();
}
async fetch_new_segments() {
while (this.playlist_loader.new_segments.length > 0) {
let segment_uri = this.playlist_loader.new_segments.shift();
let segment_stream = await this.fetch_video(segment_uri);
this.media_buffer.appendBuffer(segment_stream);
}
setTimeout(this.fetch_new_segments.bind(this), this.playlist_loader.refresh_interval * 1000);
}
async fetch_video(uri) {