Merge pull request 'web-player -> develop' (#8) from web-player into develop
Reviewed-on: https://pond.waldn.net/git/knotteye/satyr/pulls/8pull/13/head
commit
47e036cde6
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "satyr",
|
||||
"version": "0.10.0",
|
||||
"version": "0.10.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -634,6 +634,11 @@
|
|||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
|
||||
},
|
||||
"eme-encryption-scheme-polyfill": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.0.1.tgz",
|
||||
"integrity": "sha512-Wz+Ro1c0/2Wsx2RLFvTOO0m4LvYn+7cSnq3XOvRvLLBq8jbvUACH/zpU9s0/5+mQa5oaelkU69x+q0z/iWYrFA=="
|
||||
},
|
||||
"encodeurl": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
|
@ -1947,6 +1952,14 @@
|
|||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
|
||||
},
|
||||
"shaka-player": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/shaka-player/-/shaka-player-3.0.5.tgz",
|
||||
"integrity": "sha512-LYq56q9DA7yTLBD1yQwZrMlJZOovb2yRmo0C3AsddL1J0ee+U4BXr1QZd5amtpBvl8fOiLgkW/12UuChMR764A==",
|
||||
"requires": {
|
||||
"eme-encryption-scheme-polyfill": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"signal-exit": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
"socket.io": "^2.3.0",
|
||||
"strftime": "^0.10.0",
|
||||
"ts-node": "^8.5.4",
|
||||
"typescript": "^3.6.3"
|
||||
"typescript": "^3.6.3",
|
||||
"shaka-player": "^3.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.67"
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
# dash.js BSD License Agreement
|
||||
|
||||
The copyright in this software is being made available under the BSD License, included below. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
|
||||
|
||||
**Copyright (c) 2015, Dash Industry Forum.
|
||||
**All rights reserved.**
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Dash Industry Forum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
**THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@
|
|||
|
||||
<script src="/nunjucks-slim.js"></script>
|
||||
<script src="/templates.js"></script>
|
||||
<script src="/dashjs/dash.all.min.js"></script>
|
||||
<script src="/shaka-player.compiled.js"></script>
|
||||
|
||||
<script>
|
||||
nunjucks.configure({ autoescape: true });
|
||||
|
|
|
@ -82,7 +82,7 @@ async function render(path, s){
|
|||
if(!config.title){document.body.innerHTML = nunjucks.render('404.njk', context); break;}
|
||||
document.body.innerHTML = nunjucks.render('user.njk', Object.assign({about: config.about, title: config.title, username: config.username}, context));
|
||||
modifyLinks();
|
||||
startVideo();
|
||||
initPlayer(usr);
|
||||
break;
|
||||
case (path.match(/^\/vods\/.+\/manage\/?$/) || {}).input: // /vods/:user/manage
|
||||
var usr = path.substring(6, (path.length - 7));
|
||||
|
@ -179,41 +179,47 @@ function internalLink(path){
|
|||
return false;
|
||||
}
|
||||
|
||||
//start dash.js
|
||||
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'))
|
||||
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));
|
||||
}
|
||||
|
||||
var shakaPolyFilled = false;
|
||||
async function initPlayer(usr) {
|
||||
var manifestUri = document.location.protocol+'//'+document.location.host+'/live/'+usr+'/index.mpd';
|
||||
if(!shakaPolyFilled){
|
||||
shaka.polyfill.installAll();
|
||||
shakaPolyFilled = true;
|
||||
}
|
||||
// Create a Player instance.
|
||||
const video = document.getElementById('video');
|
||||
const player = new shaka.Player(video);
|
||||
// Listen for error events.
|
||||
player.addEventListener('error', onErrorEvent);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function onErrorEvent(event) {
|
||||
// Extract the shaka.util.Error object from the event.
|
||||
onError(event.detail);
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
// Log the error.
|
||||
console.error('Error code', error.code, 'object', error);
|
||||
}
|
|
@ -0,0 +1,385 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:ns1="http://sozi.baierouge.fr"
|
||||
id="svg1307"
|
||||
sodipodi:docname="media-playback-start.svg"
|
||||
inkscape:export-filename="/home/lapo/Desktop/Grafica/Icone/media-actions-outlines.png"
|
||||
viewBox="0 0 48 48"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
inkscape:export-ydpi="90"
|
||||
inkscape:version="0.46"
|
||||
sodipodi:docbase="/home/jimmac/src/cvs/tango-icon-theme/scalable/actions"
|
||||
>
|
||||
<defs
|
||||
id="defs1309"
|
||||
>
|
||||
<linearGradient
|
||||
id="linearGradient2306"
|
||||
y2="95"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="70.827"
|
||||
gradientTransform="translate(-45 -71.094)"
|
||||
y1="124.12"
|
||||
x1="71.289"
|
||||
inkscape:collect="always"
|
||||
>
|
||||
<stop
|
||||
id="stop5077"
|
||||
style="stop-color:#adb0a8"
|
||||
offset="0"
|
||||
/>
|
||||
<stop
|
||||
id="stop5079"
|
||||
style="stop-color:#464744"
|
||||
offset="1"
|
||||
/>
|
||||
</linearGradient
|
||||
>
|
||||
<radialGradient
|
||||
id="radialGradient2314"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cy="83.991"
|
||||
cx="107.59"
|
||||
gradientTransform="matrix(.053243 -.83624 2.0195 .12857 -151.92 108.08)"
|
||||
r="12.552"
|
||||
inkscape:collect="always"
|
||||
>
|
||||
<stop
|
||||
id="stop2693"
|
||||
style="stop-color:#ffffff"
|
||||
offset="0"
|
||||
/>
|
||||
<stop
|
||||
id="stop2695"
|
||||
style="stop-color:#d3d7cf"
|
||||
offset="1"
|
||||
/>
|
||||
</radialGradient
|
||||
>
|
||||
<linearGradient
|
||||
id="linearGradient2690"
|
||||
y2="88.924"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="70.952"
|
||||
gradientTransform="matrix(1.1282 0 0 1.1282 -53.993 -83.36)"
|
||||
y1="101.74"
|
||||
x1="70.914"
|
||||
inkscape:collect="always"
|
||||
>
|
||||
<stop
|
||||
id="stop2686"
|
||||
style="stop-color:#ffffff"
|
||||
offset="0"
|
||||
/>
|
||||
<stop
|
||||
id="stop2688"
|
||||
style="stop-color:#000000"
|
||||
offset="1"
|
||||
/>
|
||||
</linearGradient
|
||||
>
|
||||
</defs
|
||||
>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
inkscape:showpageshadow="false"
|
||||
inkscape:zoom="1"
|
||||
borderopacity="0.19607843"
|
||||
inkscape:current-layer="layer1"
|
||||
stroke="#555753"
|
||||
guidetolerance="1px"
|
||||
fill="#555753"
|
||||
inkscape:grid-points="true"
|
||||
inkscape:grid-bbox="true"
|
||||
showgrid="false"
|
||||
showguides="false"
|
||||
bordercolor="#666666"
|
||||
inkscape:window-x="326"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:window-y="160"
|
||||
inkscape:window-width="872"
|
||||
inkscape:pageopacity="0.0000000"
|
||||
inkscape:pageshadow="2"
|
||||
pagecolor="#ffffff"
|
||||
inkscape:cx="-117.42449"
|
||||
inkscape:cy="12.980288"
|
||||
inkscape:document-units="px"
|
||||
inkscape:window-height="688"
|
||||
showborder="true"
|
||||
>
|
||||
<sodipodi:guide
|
||||
id="guide2194"
|
||||
position="38.996647"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide2196"
|
||||
position="9.0140845"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide2198"
|
||||
position="9.0140845"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide2200"
|
||||
position="38.975184"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide2202"
|
||||
position="22.988281"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide2204"
|
||||
position="23.908786"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide4332"
|
||||
position="157.99417"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide4334"
|
||||
position="-36.062446"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide4336"
|
||||
position="-58.02695"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide4338"
|
||||
position="180.00287"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide4417"
|
||||
position="107.92217"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide4419"
|
||||
position="129.93087"
|
||||
orientation="vertical"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide5106"
|
||||
position="19.996875"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide5119"
|
||||
position="63.039674"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide5121"
|
||||
position="49.066305"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide5307"
|
||||
position="-86.007168"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide5309"
|
||||
position="-108.09009"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<sodipodi:guide
|
||||
id="guide3111"
|
||||
position="-100.15429"
|
||||
orientation="horizontal"
|
||||
/>
|
||||
<inkscape:grid
|
||||
id="GridFromPre046Settings"
|
||||
opacity=".2"
|
||||
color="#0000ff"
|
||||
originy="0px"
|
||||
originx="0px"
|
||||
empspacing="2"
|
||||
spacingy="0.5px"
|
||||
spacingx="0.5px"
|
||||
empopacity="0.4"
|
||||
type="xygrid"
|
||||
empcolor="#0000ff"
|
||||
/>
|
||||
</sodipodi:namedview
|
||||
>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
>
|
||||
<path
|
||||
id="path2682"
|
||||
style="stroke-linejoin:round;opacity:.15;color:#000000;stroke:url(#linearGradient2690);stroke-linecap:square;stroke-width:2;fill:none"
|
||||
inkscape:r_cy="true"
|
||||
inkscape:r_cx="true"
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m12 39.5v-30.5l26.07 14.817-26.07 15.683z"
|
||||
/>
|
||||
<path
|
||||
id="path3375"
|
||||
style="fill-rule:evenodd;color:#000000;fill:url(#radialGradient2314)"
|
||||
inkscape:r_cy="true"
|
||||
inkscape:r_cx="true"
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m12.499 37.811v-27.811l24.104 13.906-24.104 13.905z"
|
||||
/>
|
||||
<path
|
||||
id="path2479"
|
||||
style="stroke-linejoin:round;color:#000000;stroke:url(#linearGradient2306);stroke-linecap:square;fill:none"
|
||||
inkscape:r_cy="true"
|
||||
inkscape:r_cx="true"
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m12.499 37.811v-27.811l24.104 13.906-24.104 13.905z"
|
||||
/>
|
||||
<path
|
||||
id="path2481"
|
||||
style="fill-rule:evenodd;color:#000000;fill:#ffffff"
|
||||
inkscape:r_cy="true"
|
||||
inkscape:r_cx="true"
|
||||
sodipodi:nodetypes="cccccccc"
|
||||
d="m12.999 10.874v26.063l22.594-13.031-22.594-13.032zm1 1.75l19.563 11.282-19.563 11.281v-22.563z"
|
||||
/>
|
||||
<path
|
||||
id="path2339"
|
||||
style="opacity:.5;color:#000000;display:block;fill:#ffffff"
|
||||
inkscape:r_cy="true"
|
||||
inkscape:r_cx="true"
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m13.938 12.562v11.688c4.269-0.045 9.164-0.346 17.062-1.875l-17.062-9.813z"
|
||||
/>
|
||||
</g
|
||||
>
|
||||
<metadata
|
||||
>
|
||||
<rdf:RDF
|
||||
>
|
||||
<cc:Work
|
||||
>
|
||||
<dc:format
|
||||
>image/svg+xml</dc:format
|
||||
>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
|
||||
/>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
|
||||
/>
|
||||
<dc:publisher
|
||||
>
|
||||
<cc:Agent
|
||||
rdf:about="http://openclipart.org/"
|
||||
>
|
||||
<dc:title
|
||||
>Openclipart</dc:title
|
||||
>
|
||||
</cc:Agent
|
||||
>
|
||||
</dc:publisher
|
||||
>
|
||||
<dc:title
|
||||
>tango media start</dc:title
|
||||
>
|
||||
<dc:date
|
||||
>2010-03-11T09:12:20</dc:date
|
||||
>
|
||||
<dc:description
|
||||
>"Play" or "start" icon from <A href="http://tango.freedesktop.org/Tango_Desktop_Project"> Tango Project </A> \n<BR><BR> \nSince version 0.8.90 Tango Project icons are Public Domain: <A href="http://tango.freedesktop.org/Frequently_Asked_Questions#Terms_of_Use.3F"> Tango Project FAQ </A></dc:description
|
||||
>
|
||||
<dc:source
|
||||
>https://openclipart.org/detail/31003/tango-media-start-by-warszawianka</dc:source
|
||||
>
|
||||
<dc:creator
|
||||
>
|
||||
<cc:Agent
|
||||
>
|
||||
<dc:title
|
||||
>warszawianka</dc:title
|
||||
>
|
||||
</cc:Agent
|
||||
>
|
||||
</dc:creator
|
||||
>
|
||||
<dc:subject
|
||||
>
|
||||
<rdf:Bag
|
||||
>
|
||||
<rdf:li
|
||||
>audio</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>button</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>externalsource</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>icon</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>play</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>playback</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>sign</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>start</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>symbol</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>tango</rdf:li
|
||||
>
|
||||
<rdf:li
|
||||
>triangle</rdf:li
|
||||
>
|
||||
</rdf:Bag
|
||||
>
|
||||
</dc:subject
|
||||
>
|
||||
</cc:Work
|
||||
>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/publicdomain/"
|
||||
>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction"
|
||||
/>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution"
|
||||
/>
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
|
||||
/>
|
||||
</cc:License
|
||||
>
|
||||
</rdf:RDF
|
||||
>
|
||||
</metadata
|
||||
>
|
||||
</svg
|
||||
>
|
After Width: | Height: | Size: 9.8 KiB |
|
@ -59,6 +59,13 @@ async function init(){
|
|||
await initAPI();
|
||||
//static files if nothing else matches
|
||||
app.use(express.static(config['http']['directory']));
|
||||
//Fake static files
|
||||
app.get('/shaka-player.compiled.js', (req, res) => {
|
||||
res.sendFile(process.cwd()+'/node_modules/shaka-player/dist/shaka-player.compiled.js');
|
||||
});
|
||||
app.get('/shaka-player.compiled.map', (req, res) => {
|
||||
res.sendFile(process.cwd()+'/node_modules/shaka-player/dist/shaka-player.compiled.map');
|
||||
});
|
||||
//client-side site routes
|
||||
if(!config['http']['server_side_render'])
|
||||
await initFE();
|
||||
|
|
|
@ -1,47 +1,50 @@
|
|||
{% extends "base.njk" %}
|
||||
{% block head %}
|
||||
<!--<script src="/videojs/video.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/videojs/video-js.min.css">-->
|
||||
<script src="/dashjs/dash.all.min.js"></script>
|
||||
<script>
|
||||
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'))
|
||||
break;
|
||||
<script src="/shaka-player.compiled.js"></script>
|
||||
<script>
|
||||
shakaPolyFilled = false;
|
||||
var manifestUri = document.location.protocol+'//'+document.location.host+'/live/{{ username }}/index.mpd';
|
||||
async function initPlayer() {
|
||||
if(!shakaPolyFilled){
|
||||
shaka.polyfill.installAll();
|
||||
shakaPolyFilled = true;
|
||||
}
|
||||
// Create a Player instance.
|
||||
const video = document.getElementById('video');
|
||||
const player = new shaka.Player(video);
|
||||
// Listen for error events.
|
||||
player.addEventListener('error', onErrorEvent);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
function onErrorEvent(event) {
|
||||
// Extract the shaka.util.Error object from the event.
|
||||
onError(event.detail);
|
||||
}
|
||||
</script>
|
||||
|
||||
function onError(error) {
|
||||
// Log the error.
|
||||
console.error('Error code', error.code, 'object', error);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initPlayer);
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<script>
|
||||
|
@ -53,13 +56,9 @@ function newPopup(url) {
|
|||
</br>
|
||||
<span style="float: left;font-size: large;"><a href="/live/{{ username }}/index.mpd">{{ username }}</a> | {{ title | escape }}</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>
|
||||
<div id="jscontainer">
|
||||
<div id="jschild" style="width: 70%;height: 100%;">
|
||||
<!--<video controls poster="/thumbnail.jpg" class="video-js vjs-default-skin" id="live-video" style="width:100%;height:100%;min-height: 500px;"></video>-->
|
||||
<video id="videoPlayer" style="width:100%;height:100%;width: 950px;height: 534px;background-color: rgb(0, 0, 0);" poster="/thumbnail.jpg" autoplay muted></video>
|
||||
|
||||
<!--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>startVideo()</script>
|
||||
<div id="jschild" style="width: 70%;height: 100%;position: relative;">
|
||||
<image id="playbtn" src="/play.svg" alt="Play Stream" style="width:100%;height:100%;width: 950px;height: 534px;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: 950px;height: 534px;background-color: rgb(0, 0, 0);" poster="/thumbnail.jpg" autoplay onclick="this.paused ? this.play() : this.pause();"></video>
|
||||
</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>
|
||||
|
@ -68,21 +67,4 @@ function newPopup(url) {
|
|||
</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 }}
|
||||
<!--<script>
|
||||
window.HELP_IMPROVE_VIDEOJS = false;
|
||||
var player = videojs('live-video', {
|
||||
html: {
|
||||
nativeCaptions: false,
|
||||
},
|
||||
});
|
||||
player.ready(function() {
|
||||
player.on("error", () => {
|
||||
document.querySelector(".vjs-modal-dialog-content").textContent = "The stream is currently offline.";
|
||||
});
|
||||
player.src({
|
||||
src: '/live/{{ username }}/index.mpd',
|
||||
type: 'application/dash+xml'
|
||||
});
|
||||
})
|
||||
</script>-->
|
||||
{% endblock %}
|
Reference in New Issue