(() => { let upstream = "{{ stream }}"; let xhr = new XMLHttpRequest(); xhr.open("HEAD", upstream, true); xhr.send(); let count = 2; let handleCount = () => { if(--count === 0) { handle(); } } let handle = () => { let bodies = document.getElementsByTagName("body"); if(bodies.length === 1) { let body = bodies[0]; let video = document.createElement("video"); video.className = "video-js vjs-big-play-centered"; body.appendChild(video); let ctype = xhr.getResponseHeader("Content-Type"); console.log(ctype); let options = {}; options.controls = true; options.liveui = true; options.responsive = true; options.fill = true; options.techOrder = ["chromecast", "html5"]; options.plugins = {}; options.plugins.chromecast = {}; player.plugins.chromecast.requestTitleFn = (src) => { return "{{ title }}"; } let player = videojs(video, options); let source = {}; source.type = ctype; source.src = upstream; player.src(source); } } document.addEventListener("DOMContentLoaded", handleCount); xhr.addEventListener("load", handleCount); })();