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); } xhr.open("HEAD", "{{ stream }}", true); xhr.send(); });