22 lines
762 B
JavaScript
22 lines
762 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";
|
|
video.className = "video-js";
|
|
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();
|
|
}
|
|
});
|