added autoreload for offline streams
This commit is contained in:
parent
67feb20741
commit
64219a62f1
2 changed files with 53 additions and 15 deletions
|
@ -56,18 +56,21 @@ MistPlayer.prototype.timer = {
|
||||||
return i;
|
return i;
|
||||||
},
|
},
|
||||||
remove: function(i){
|
remove: function(i){
|
||||||
if (this.timers[i].interval) {
|
if (i in this.timers) {
|
||||||
clearInterval(i);
|
if (this.timers[i].interval) {
|
||||||
|
clearInterval(i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clearTimeout(i);
|
||||||
|
}
|
||||||
|
delete this.timers[i];
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
clearTimeout(i);
|
|
||||||
}
|
|
||||||
delete this.timers[i];
|
|
||||||
},
|
},
|
||||||
clear: function(){
|
clear: function(){
|
||||||
for (var i in this.timers) {
|
for (var i in this.timers) {
|
||||||
this.remove(i);
|
this.remove(i);
|
||||||
}
|
}
|
||||||
|
this.timers = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -900,12 +903,17 @@ function mistPlay(streamName,options) {
|
||||||
err.innerHTML = displaymsg.replace(new RegExp("\n",'g'),'<br>')+'<br>';
|
err.innerHTML = displaymsg.replace(new RegExp("\n",'g'),'<br>')+'<br>';
|
||||||
err.className = 'error';
|
err.className = 'error';
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
|
var i = document.createElement('div');
|
||||||
|
button.appendChild(i);
|
||||||
var t = document.createTextNode('Reload');
|
var t = document.createTextNode('Reload');
|
||||||
button.appendChild(t);
|
button.appendChild(t);
|
||||||
err.appendChild(button);
|
err.appendChild(button);
|
||||||
button.onclick = function(){
|
button.onclick = function(){
|
||||||
options.target.removeChild(err);
|
options.target.removeChild(err);
|
||||||
delete options.startCombo;
|
delete options.startCombo;
|
||||||
|
if (err.timeOut) {
|
||||||
|
clearTimeout(err.timeOut);
|
||||||
|
}
|
||||||
mistPlay(streamName,options);
|
mistPlay(streamName,options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,6 +921,20 @@ function mistPlay(streamName,options) {
|
||||||
|
|
||||||
protoplay.sendEvent('error',msg,options.target);
|
protoplay.sendEvent('error',msg,options.target);
|
||||||
|
|
||||||
|
if (!('type' in info) || (info.type != 'vod')) { //always show the button timer, unless its a vod
|
||||||
|
//reload timeout
|
||||||
|
var delay = ('type' in info ? 20 : 60);
|
||||||
|
i.className = 'countdown'+delay;
|
||||||
|
err.timeOut = protoplay.timer.add(function(){
|
||||||
|
protoplay.report({
|
||||||
|
type: 'playback',
|
||||||
|
warn: 'Automatically checking if the stream is working now'
|
||||||
|
});
|
||||||
|
embedLog('Triggering reload button because of timeout');
|
||||||
|
button.click();
|
||||||
|
},delay*1e3);
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,7 +996,7 @@ function mistPlay(streamName,options) {
|
||||||
function onstreaminfo() {
|
function onstreaminfo() {
|
||||||
options.target.innerHTML = '';
|
options.target.innerHTML = '';
|
||||||
options.target.removeAttribute('data-loading');
|
options.target.removeAttribute('data-loading');
|
||||||
embedLog('Stream info was loaded succesfully');
|
embedLog('Stream info was loaded succesfully.');
|
||||||
|
|
||||||
//get streaminfo data
|
//get streaminfo data
|
||||||
var streaminfo = mistvideo[streamName];
|
var streaminfo = mistvideo[streamName];
|
||||||
|
@ -982,12 +1004,22 @@ function mistPlay(streamName,options) {
|
||||||
streaminfo.initTime = new Date();
|
streaminfo.initTime = new Date();
|
||||||
|
|
||||||
if (!('source' in streaminfo)) {
|
if (!('source' in streaminfo)) {
|
||||||
mistError('Error while loading stream info.');
|
if ((streaminfo.type) && (streaminfo.type == 'live')) {
|
||||||
protoplay.report({
|
mistError('The live stream is currently offline.');
|
||||||
type: 'init',
|
return;
|
||||||
error: 'No sources'
|
}
|
||||||
});
|
else if ('error' in streaminfo) {
|
||||||
return;
|
mistError(streaminfo.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mistError('Error while parsing stream info.');
|
||||||
|
protoplay.report({
|
||||||
|
type: 'init',
|
||||||
|
error: 'No sources'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (('forceType' in options) && (options.forceType)) {
|
if (('forceType' in options) && (options.forceType)) {
|
||||||
|
|
|
@ -360,7 +360,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.countdown {
|
.countdown, .countdown20, .countdown60 {
|
||||||
height: 1em;
|
height: 1em;
|
||||||
width: 1em;
|
width: 1em;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -372,7 +372,7 @@
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
animation: appear 20s step-start 1;
|
animation: appear 20s step-start 1;
|
||||||
}
|
}
|
||||||
.countdown:before {
|
.countdown:before, .countdown20:before, .countdown60:before {
|
||||||
content: '';
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: 50%;
|
margin-left: 50%;
|
||||||
|
@ -382,6 +382,12 @@
|
||||||
transform-origin: 0 50%;
|
transform-origin: 0 50%;
|
||||||
animation: rotate 10s linear 2, bg 20s step-end 1;
|
animation: rotate 10s linear 2, bg 20s step-end 1;
|
||||||
}
|
}
|
||||||
|
.countdown60 {
|
||||||
|
animation: appear 60s step-start 1;
|
||||||
|
}
|
||||||
|
.coutndown60:before {
|
||||||
|
animation: rotate 30s linear 2, bg 60s step-end 1;
|
||||||
|
}
|
||||||
@keyframes rotate {
|
@keyframes rotate {
|
||||||
to { transform: rotate(.5turn); }
|
to { transform: rotate(.5turn); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue