25 lines
848 B
JavaScript
25 lines
848 B
JavaScript
document.addEventListener("DOMContentLoaded", () => {
|
|
let bodies = document.getElementsByTagName("body");
|
|
if(bodies.length === 1) {
|
|
let body = bodies[0];
|
|
let xhr = new XMLHttpRequest();
|
|
let upstream = "{{ stream }}";
|
|
xhr.addEventListener("load", () => {
|
|
let video = document.createElement("video");
|
|
let ctype = xhr.getResponseHeader("Content-Type");
|
|
console.log(ctype);
|
|
let options = {};
|
|
options.controls = true;
|
|
options.liveui = true;
|
|
let player = videojs(video, options);
|
|
let source = {};
|
|
source.type = ctype;
|
|
source.src = upstream;
|
|
player.src(source);
|
|
body.appendChild(video);
|
|
});
|
|
xhr.open("HEAD", upstream, true);
|
|
xhr.send();
|
|
}
|
|
});
|