2019-09-28 21:43:25 -05:00
|
|
|
{% extends "base.njk" %}
|
2019-12-07 10:51:26 -06:00
|
|
|
{% block head %}
|
2020-10-18 09:23:28 -05:00
|
|
|
<script src="/shaka-player.compiled.js"></script>
|
|
|
|
<script>
|
|
|
|
shakaPolyFilled = false;
|
2020-10-25 10:26:07 -05:00
|
|
|
var manifestUri = document.location.protocol+'//'+document.location.host+'/live/{{ username }}/index.mpd';
|
2020-10-18 09:23:28 -05:00
|
|
|
async function initPlayer() {
|
|
|
|
if(!shakaPolyFilled){
|
|
|
|
shaka.polyfill.installAll();
|
|
|
|
shakaPolyFilled = true;
|
|
|
|
}
|
2021-01-08 16:13:21 -06:00
|
|
|
var live = JSON.parse(await makeRequest("GET", "/api/{{ username }}/config")).live;
|
|
|
|
if(live){
|
|
|
|
// Create a Player instance.
|
|
|
|
const video = document.getElementById('video');
|
|
|
|
const player = new shaka.Player(video);
|
|
|
|
// Listen for error events.
|
|
|
|
player.addEventListener('error', onErrorEvent);
|
2020-10-17 05:26:31 -05:00
|
|
|
|
2021-01-08 16:13:21 -06:00
|
|
|
video.addEventListener('play', () => {
|
|
|
|
document.getElementById('playbtn').style.visibility = 'hidden';
|
|
|
|
});
|
|
|
|
video.addEventListener('pause', () => {
|
|
|
|
document.getElementById('playbtn').style.visibility = 'visible';
|
|
|
|
});
|
|
|
|
// Try to load a manifest.
|
|
|
|
// This is an asynchronous process.
|
|
|
|
try {
|
|
|
|
await player.load(manifestUri);
|
|
|
|
// This runs if the asynchronous load is successful.
|
|
|
|
console.log('The video has now been loaded!');
|
|
|
|
} catch (e) {
|
|
|
|
// onError is executed if the asynchronous load fails.
|
|
|
|
onError(e);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setTimeout(initPlayer, 5000);
|
2020-10-18 09:23:28 -05:00
|
|
|
}
|
|
|
|
}
|
2020-10-17 05:26:31 -05:00
|
|
|
|
2020-10-18 09:23:28 -05:00
|
|
|
function onErrorEvent(event) {
|
|
|
|
// Extract the shaka.util.Error object from the event.
|
|
|
|
onError(event.detail);
|
2020-10-17 05:26:31 -05:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:23:28 -05:00
|
|
|
function onError(error) {
|
|
|
|
// Log the error.
|
|
|
|
console.error('Error code', error.code, 'object', error);
|
2020-10-17 05:26:31 -05:00
|
|
|
}
|
2020-10-18 09:23:28 -05:00
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', initPlayer);
|
|
|
|
</script>
|
2019-12-07 10:51:26 -06:00
|
|
|
{% endblock %}
|
2019-09-28 21:43:25 -05:00
|
|
|
{% block content %}
|
2019-10-20 16:09:28 -05:00
|
|
|
<script>
|
|
|
|
function newPopup(url) {
|
|
|
|
popupWindow = window.open(
|
|
|
|
url,'popUpWindow','height=700,width=450,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
|
|
|
|
}
|
2021-01-15 23:14:57 -06:00
|
|
|
async function updateViewers(){
|
|
|
|
let vc = document.getElementById('viewercount');
|
|
|
|
if(!vc) return false;
|
|
|
|
let path = window.location.pathname;
|
|
|
|
if(path.substring(path.length - 1).indexOf('/') !== -1)
|
|
|
|
var usr = path.substring(7, path.length - 1);
|
|
|
|
else var usr = path.substring(7);
|
|
|
|
let viewers = JSON.parse(await makeRequest("GET", "/api/"+usr+"/config")).viewers;
|
|
|
|
vc.innerHTML = "[Viewers: "+viewers+"]";
|
|
|
|
setTimeout(updateViewers, 2000);
|
|
|
|
}
|
2019-10-20 16:09:28 -05:00
|
|
|
</script>
|
2019-10-05 14:34:57 -05:00
|
|
|
</br>
|
2021-01-15 23:14:57 -06:00
|
|
|
<span style="float: left;font-size: large;"><a href="/live/{{ username }}/index.mpd">{{ username }}</a> | {{ title | escape }}<span id="viewercount" onload="updateViewers">[Viewers: {{viewers}}]</span>
|
|
|
|
<script>updateViewers()</script>
|
|
|
|
</b></span><span style="float: right;font-size: large;"> Links | <a href="rtmp://{{ domain }}/live/{{ username }}">Watch</a> <a href="JavaScript:newPopup('/chat?room={{ username }}');">Chat</a> <a href="/vods/{{ username }}">VODs</a></span>
|
2019-09-28 21:43:25 -05:00
|
|
|
<div id="jscontainer">
|
2020-10-19 10:27:35 -05:00
|
|
|
<div id="jschild" style="width: 70%;height: 100%;position: relative;">
|
2021-01-16 00:02:39 -06:00
|
|
|
<image id="playbtn" src="/play.svg" alt="Play Stream" style="width:100%;height:100%;height: 100%;position: absolute;" onclick="document.getElementById('video').paused ? document.getElementById('video').play() : document.getElementById('video') .pause();"></image>
|
|
|
|
<video id="video" style="width:100%;height:100%;width: 100%;height: 100%;background-color: rgb(0, 0, 0);" poster="/thumbnail.jpg" autoplay onclick="this.paused ? this.play() : this.pause();"></video>
|
2019-09-28 21:43:25 -05:00
|
|
|
</div>
|
2021-01-16 00:02:39 -06:00
|
|
|
<div id="jschild" class="webchat" style="width: 30%;height: 100%;">
|
|
|
|
<iframe src="/chat?room={{ username }}" frameborder="0" style="min-width: 100%;min-height: 100%;" allowfullscreen></iframe>
|
2019-09-28 21:43:25 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-12-07 10:51:26 -06:00
|
|
|
</br>
|
|
|
|
<noscript>The webclients for the stream and the chat require javascript, but feel free to use the direct links above!</br></br></noscript>
|
|
|
|
{{ about | escape }}
|
2019-09-28 21:43:25 -05:00
|
|
|
{% endblock %}
|