stream-api/script.js

22 lines
762 B
JavaScript
Raw Normal View History

2021-05-12 07:50:51 +00:00
document.addEventListener("DOMContentLoaded", () => {
2021-05-12 08:26:15 +00:00
let bodies = document.getElementsByTagName("body");
if(bodies.length === 1) {
let body = bodies[0];
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
let video = document.createElement("video");
2021-05-12 08:33:29 +00:00
video.id = "video-player";
2021-05-12 08:35:15 +00:00
video.className = "video-js";
2021-05-12 08:26:15 +00:00
body.appendChild(video);
let ctype = xhr.getResponseHeader("Content-Type");
2021-05-12 08:33:29 +00:00
let player = videojs("video-player");
2021-05-12 08:26:15 +00:00
let source = {};
source.type = ctype;
source.src = "{{ stream }}";
player.src(source);
}
xhr.open("HEAD", "{{ stream }}", true);
xhr.send();
2021-05-12 07:50:51 +00:00
}
});