stream-api/script.js
2021-05-12 10:33:29 +02:00

21 lines
720 B
JavaScript

document.addEventListener("DOMContentLoaded", () => {
let bodies = document.getElementsByTagName("body");
if(bodies.length === 1) {
let body = bodies[0];
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
let video = document.createElement("video");
video.id = "video-player";
body.appendChild(video);
let ctype = xhr.getResponseHeader("Content-Type");
let player = videojs("video-player");
let source = {};
source.type = ctype;
source.src = "{{ stream }}";
player.src(source);
}
xhr.open("HEAD", "{{ stream }}", true);
xhr.send();
}
});