mirror of
https://git.waldn.net/git/knotteye/satyr.git
synced 2025-10-21 16:12:42 +00:00
Fix the start video function to avoid redudant calls
This commit is contained in:
@@ -4,12 +4,43 @@
|
||||
<link rel="stylesheet" type="text/css" href="/videojs/video-js.min.css">-->
|
||||
<script src="/dashjs/dash.all.min.js"></script>
|
||||
<script>
|
||||
function startVideo(){
|
||||
var url = "/live/{{username}}/index.mpd";
|
||||
var player = dashjs.MediaPlayer().create();
|
||||
player.initialize(document.querySelector("#videoPlayer"), url, true);
|
||||
console.log('called startvideo');
|
||||
}
|
||||
async function startVideo(){
|
||||
//var url = "/live/{{username}}/index.mpd";
|
||||
//var player = dashjs.MediaPlayer().create();
|
||||
//player.initialize(document.querySelector("#videoPlayer"), url, true);
|
||||
//console.log('called startvideo');
|
||||
while(true){
|
||||
if(document.querySelector('#videoPlayer') === null)
|
||||
break;
|
||||
|
||||
if(window.location.pathname.substring(window.location.pathname.length - 1) !== '/'){
|
||||
var url = "/api/"+window.location.pathname.substring(7)+"/config";
|
||||
console.log(url)
|
||||
var xhr = JSON.parse(await makeRequest("GET", url));
|
||||
if(xhr.live){
|
||||
var player = dashjs.MediaPlayer().create();
|
||||
player.initialize(document.querySelector("#videoPlayer"), url, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
var url = "/api/"+window.location.pathname.substring(7, window.location.pathname.length - 1)+"/config";
|
||||
console.log(url)
|
||||
var xhr = JSON.parse(await makeRequest("GET", url));
|
||||
if(xhr.live){
|
||||
var player = dashjs.MediaPlayer().create();
|
||||
player.initialize(document.querySelector("#videoPlayer"), url, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
await sleep(60000);
|
||||
}
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
@@ -28,7 +59,7 @@ function newPopup(url) {
|
||||
|
||||
<!--this spits errors fucking constantly after it tries to reload a video that's already running.. I dunno if it's bad or causing problems so let's just push it to develop and wait for issues!-->
|
||||
<!--it plays the stream without reloading the page tho lol-->
|
||||
<script>window.setInterval(startVideo, 60000)</script>
|
||||
<script>startVideo()</script>
|
||||
</div>
|
||||
<div id="jschild" class="webchat" style="width: 30%;height: 100%;position: relative;">
|
||||
<iframe src="/chat?room={{ username }}" frameborder="0" style="width: 100%;height: 100%; min-height: 534px;" allowfullscreen></iframe>
|
||||
|
Reference in New Issue
Block a user