init.mp4 appended to media source buffer
This commit is contained in:
parent
e94d063422
commit
24b896824f
1 changed files with 9 additions and 3 deletions
|
@ -45,13 +45,19 @@ class VideoLoader {
|
||||||
this.playlist_loader = new PlaylistLoader();
|
this.playlist_loader = new PlaylistLoader();
|
||||||
this.player = document.getElementById(vid_tag_id);
|
this.player = document.getElementById(vid_tag_id);
|
||||||
this.media_source = new MediaSource();
|
this.media_source = new MediaSource();
|
||||||
this.prepare_buffer();
|
this.media_source.addEventListener('sourceopen', this.prepare_buffer.bind(this));
|
||||||
|
this.player.src = window.URL.createObjectURL(this.media_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
async prepare_buffer() {
|
async prepare_buffer(_) {
|
||||||
let init_frag = await this.fetch_video('/vid/' + this.stream_key + '/init.mp4');
|
let init_frag = await this.fetch_video('/vid/' + this.stream_key + '/init.mp4');
|
||||||
let mime = (new MP4Tree(init_frag)).get_mime();
|
let mime = (new MP4Tree(init_frag)).get_mime();
|
||||||
console.log(mime);
|
if (!MediaSource.isTypeSupported(mime)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.media_buffer = this.media_source.addSourceBuffer(mime);
|
||||||
|
this.media_buffer.mode = 'segments';
|
||||||
|
this.media_buffer.appendBuffer(init_frag);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch_video(uri) {
|
async fetch_video(uri) {
|
||||||
|
|
Loading…
Reference in a new issue