add video tag from js
This commit is contained in:
parent
8efc686f83
commit
8fbf8a4f62
@ -5,6 +5,5 @@
|
|||||||
<script src="{{ script }}"></script>
|
<script src="{{ script }}"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<video class="video-js" id="player" controls></video>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
26
script.js
26
script.js
@ -1,13 +1,19 @@
|
|||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
let xhr = new XMLHttpRequest();
|
let bodies = document.getElementsByTagName("body");
|
||||||
xhr.onreadystatechange = () => {
|
if(bodies.length === 1) {
|
||||||
let ctype = xhr.getResponseHeader("Content-Type");
|
let body = bodies[0];
|
||||||
let player = videojs("player");
|
let xhr = new XMLHttpRequest();
|
||||||
let source = {};
|
xhr.onreadystatechange = () => {
|
||||||
source.type = ctype;
|
let video = document.createElement("video");
|
||||||
source.src = "{{ stream }}";
|
body.appendChild(video);
|
||||||
player.src(source);
|
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();
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user