diff --git a/index.html b/index.html index 0b0575f..e2a9560 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,5 @@ - diff --git a/script.js b/script.js index 3146d60..dd9e21e 100644 --- a/script.js +++ b/script.js @@ -1,13 +1,19 @@ document.addEventListener("DOMContentLoaded", () => { - let xhr = new XMLHttpRequest(); - xhr.onreadystatechange = () => { - let ctype = xhr.getResponseHeader("Content-Type"); - let player = videojs("player"); - let source = {}; - source.type = ctype; - source.src = "{{ stream }}"; - player.src(source); + let bodies = document.getElementsByTagName("body"); + if(bodies.length === 1) { + let body = bodies[0]; + let xhr = new XMLHttpRequest(); + xhr.onreadystatechange = () => { + let video = document.createElement("video"); + body.appendChild(video); + let ctype = xhr.getResponseHeader("Content-Type"); + let player = videojs(video); + let source = {}; + source.type = ctype; + source.src = "{{ stream }}"; + player.src(source); + } + xhr.open("HEAD", "{{ stream }}", true); + xhr.send(); } - xhr.open("HEAD", "{{ stream }}", true); - xhr.send(); });