Merge branch 'development' into LTS_development
This commit is contained in:
commit
a633c346cf
19 changed files with 6023 additions and 8441 deletions
14
embed/controls.js
vendored
14
embed/controls.js
vendored
|
@ -93,14 +93,20 @@ function MistUI(MistVideo,structure) {
|
|||
|
||||
//apply skin CSS
|
||||
var uid = MistUtil.createUnique();
|
||||
var toload = MistVideo.skin.css.length;
|
||||
if (toload) { container.style.opacity = "0"; }
|
||||
var loaded = 0;
|
||||
if (MistVideo.skin.css.length) { container.style.opacity = 0; }
|
||||
for (var i in MistVideo.skin.css) {
|
||||
var style = MistVideo.skin.css[i];
|
||||
style.callback = function(css) {
|
||||
if (css == "/*Failed to load*/") {
|
||||
this.textContent = css;
|
||||
MistVideo.showError("Failed to load CSS from "+this.getAttribute("data-source"));
|
||||
}
|
||||
else {
|
||||
this.textContent = MistUtil.css.prependClass(css,uid,true);
|
||||
toload--;
|
||||
if (toload <= 0) {
|
||||
}
|
||||
loaded++;
|
||||
if (MistVideo.skin.css.length <= loaded) {
|
||||
container.style.opacity = "";
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
mistplayers.dashjs={name:"Dash.js player",mimes:["dash/video/mp4"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,i){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}if(location.protocol=="file:"){i.log("This source ("+e+") won't load if the page is run via file://");return false}return"MediaSource"in window},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/dashjs.js"}};var p=mistplayers.dashjs.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=this;this.onDashLoad=function(){if(e.destroyed){return}e.log("Building DashJS player..");var r=document.createElement("video");if("Proxy"in window){var a={get:{},set:{}};e.player.api=new Proxy(r,{get:function(e,t,i){if(t in a.get){return a.get[t].apply(e,arguments)}var r=e[t];if(typeof r==="function"){return function(){return r.apply(e,arguments)}}return r},set:function(e,t,i){if(t in a.set){return a.set[t].call(e,i)}return e[t]=i}});if(e.info.type=="live"){a.get.duration=function(){var t=0;if(this.buffered.length){t=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-e.player.api.lastProgress.getTime())*.001;return t+i+-1*e.player.api.liveOffset+45};a.set.currentTime=function(t){var i=t-e.player.api.duration;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");e.video.currentTime=t};MistUtil.event.addListener(r,"progress",function(){e.player.api.lastProgress=new Date});e.player.api.lastProgress=new Date;e.player.api.liveOffset=0}}else{i.api=r}if(e.options.autoplay){r.setAttribute("autoplay","")}if(e.options.loop&&e.info.type!="live"){r.setAttribute("loop","")}if(e.options.poster){r.setAttribute("poster",e.options.poster)}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}var s=dashjs.MediaPlayer().create();s.initialize(r,e.source.url,e.options.autoplay);i.dash=s;var o=["METRIC_ADDED","METRIC_CHANGED","METRICS_CHANGED","FRAGMENT_LOADING_STARTED","FRAGMENT_LOADING_COMPLETED","LOG","PLAYBACK_TIME_UPDATED","PLAYBACK_PROGRESS"];for(var n in dashjs.MediaPlayer.events){if(o.indexOf(n)<0){i.dash.on(dashjs.MediaPlayer.events[n],function(t){e.log("Player event fired: "+t.type)})}}e.player.setSize=function(e){this.api.style.width=e.width+"px";this.api.style.height=e.height+"px"};e.player.api.setSource=function(t){e.player.dash.attachSource(t)};var l=false;i.dash.on("allTextTracksAdded",function(){l=true});e.player.api.setSubtitle=function(t){if(!l){var r=function(){e.player.api.setSubtitle(t);i.dash.off("allTextTracksAdded",r)};i.dash.on("allTextTracksAdded",r);return}if(!t){i.dash.enableText(false);return}var a=i.dash.getTracksFor("text");for(var s in a){var o="idx"in t?t.idx:t.trackid;if(a[s].id==o){i.dash.setTextTrack(s);if(!i.dash.isTextEnabled()){i.dash.enableText()}return true}}return false};MistUtil.event.addListener(r,"progress",function(t){if(e.container.getAttribute("data-loading")=="stalled"){e.container.removeAttribute("data-loading")}});i.api.unload=function(){i.dash.reset()};e.log("Built html");t(r)};if("dashjs"in window){this.onDashLoad()}else{var r=MistUtil.scripts.insert(e.urlappend(mistplayers.dashjs.scriptsrc(e.options.host)),{onerror:function(t){var i="Failed to load dashjs.js";if(t.message){i+=": "+t.message}e.showError(i)},onload:i.onDashLoad},e)}};
|
||||
mistplayers.dashjs={name:"Dash.js player",mimes:["dash/video/mp4"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,i){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}if(location.protocol=="file:"){i.log("This source ("+e+") won't load if the page is run via file://");return false}return"MediaSource"in window},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/dashjs.js"}};var p=mistplayers.dashjs.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=this;this.onDashLoad=function(){if(e.destroyed){return}e.log("Building DashJS player..");var r=document.createElement("video");if("Proxy"in window){var a={get:{},set:{}};e.player.api=new Proxy(r,{get:function(e,t,i){if(t in a.get){return a.get[t].apply(e,arguments)}var r=e[t];if(typeof r==="function"){return function(){return r.apply(e,arguments)}}return r},set:function(e,t,i){if(t in a.set){return a.set[t].call(e,i)}return e[t]=i}});if(e.info.type=="live"){a.get.duration=function(){var t=0;if(this.buffered.length){t=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-e.player.api.lastProgress.getTime())*.001;return t+i+-1*e.player.api.liveOffset+45};a.set.currentTime=function(t){var i=t-e.player.api.duration;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");e.video.currentTime=t};MistUtil.event.addListener(r,"progress",function(){e.player.api.lastProgress=new Date});e.player.api.lastProgress=new Date;e.player.api.liveOffset=0}}else{i.api=r}if(e.options.autoplay){r.setAttribute("autoplay","")}if(e.options.loop&&e.info.type!="live"){r.setAttribute("loop","")}if(e.options.poster){r.setAttribute("poster",e.options.poster)}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}var s=dashjs.MediaPlayer().create();s.initialize(r,e.source.url,e.options.autoplay);i.dash=s;var o=["METRIC_ADDED","METRIC_UPDATED","METRIC_CHANGED","METRICS_CHANGED","FRAGMENT_LOADING_STARTED","FRAGMENT_LOADING_COMPLETED","LOG","PLAYBACK_TIME_UPDATED","PLAYBACK_PROGRESS"];for(var n in dashjs.MediaPlayer.events){if(o.indexOf(n)<0){i.dash.on(dashjs.MediaPlayer.events[n],function(t){e.log("Player event fired: "+t.type)})}}e.player.setSize=function(e){this.api.style.width=e.width+"px";this.api.style.height=e.height+"px"};e.player.api.setSource=function(t){e.player.dash.attachSource(t)};var l=false;i.dash.on("allTextTracksAdded",function(){l=true});e.player.api.setSubtitle=function(t){if(!l){var r=function(){e.player.api.setSubtitle(t);i.dash.off("allTextTracksAdded",r)};i.dash.on("allTextTracksAdded",r);return}if(!t){i.dash.enableText(false);return}var a=i.dash.getTracksFor("text");for(var s in a){var o="idx"in t?t.idx:t.trackid;if(a[s].id==o){i.dash.setTextTrack(s);if(!i.dash.isTextEnabled()){i.dash.enableText()}return true}}return false};MistUtil.event.addListener(r,"progress",function(t){if(e.container.getAttribute("data-loading")=="stalled"){e.container.removeAttribute("data-loading")}});i.api.unload=function(){i.dash.reset()};e.log("Built html");t(r)};if("dashjs"in window){this.onDashLoad()}else{var r=MistUtil.scripts.insert(e.urlappend(mistplayers.dashjs.scriptsrc(e.options.host)),{onerror:function(t){var i="Failed to load dashjs.js";if(t.message){i+=": "+t.message}e.showError(i)},onload:i.onDashLoad},e)}};
|
|
@ -1 +1 @@
|
|||
mistplayers.html5={name:"HTML5 video player",mimes:["html5/application/vnd.apple.mpegurl","html5/video/mp4","html5/video/ogg","html5/video/webm","html5/audio/mp3","html5/audio/webm","html5/audio/ogg","html5/audio/wav"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(t){return MistUtil.array.indexOf(this.mimes,t)==-1?false:true},isBrowserSupported:function(t,e,i){if(location.protocol!=MistUtil.http.url.split(e.url).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(e.url).protocol=="http:"){i.log("This page was loaded over file://, the player might not behave as intended.")}else{i.log("HTTP/HTTPS mismatch for this source");return false}}var r=false;var a=t.split("/");a.shift();try{a=a.join("/");function n(t){var e=document.createElement("video");if(e&&e.canPlayType(t)!=""){r=e.canPlayType(t)}return r}if(a=="video/mp4"){function o(t){function e(e){return("0"+t.init.charCodeAt(e).toString(16)).slice(-2)}switch(t.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp3";case"AC3":return"ec-3";case"H264":return"avc1."+e(1)+e(2)+e(3);case"HEVC":return"hev1."+e(1)+e(6)+e(7)+e(8)+e(9)+e(10)+e(11)+e(12);default:return t.codec.toLowerCase()}}var s={};for(var l in i.info.meta.tracks){if(i.info.meta.tracks[l].type!="meta"){s[o(i.info.meta.tracks[l])]=1}}s=MistUtil.object.keys(s);if(s.length){if(s.length>e.simul_tracks){var p=0;for(var l in s){var u=n(a+';codecs="'+s[l]+'"');if(u){p++}}return p>=e.simul_tracks}a+=';codecs="'+s.join(",")+'"'}}r=n(a)}catch(t){}return r},player:function(){this.onreadylist=[]},mistControls:true};var p=mistplayers.html5.player;p.prototype=new MistPlayer;p.prototype.build=function(t,e){var i=t.source.type.split("/");i.shift();var r=document.createElement("video");r.setAttribute("crossorigin","anonymous");var a=document.createElement("source");a.setAttribute("src",t.source.url);r.source=a;r.appendChild(a);a.type=i.join("/");var n=["autoplay","loop","poster"];for(var o in n){var s=n[o];if(t.options[s]){r.setAttribute(s,t.options[s]===true?"":t.options[s])}}if(t.options.muted){r.muted=true}if(t.options.controls=="stock"){r.setAttribute("controls","")}if(t.info.type=="live"){r.loop=false}if("Proxy"in window&&"Reflect"in window){var l={get:{},set:{}};t.player.api=new Proxy(r,{get:function(t,e,i){if(e in l.get){return l.get[e].apply(t,arguments)}var r=t[e];if(typeof r==="function"){return function(){return r.apply(t,arguments)}}return r},set:function(t,e,i){if(e in l.set){return l.set[e].call(t,i)}return t[e]=i}});if(t.source.type=="html5/audio/mp3"){l.set.currentTime=function(){t.log("Seek attempted, but MistServer does not currently support seeking in MP3.");return false}}if(t.info.type=="live"){l.get.duration=function(){var e=0;if(this.buffered.length){e=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-t.player.api.lastProgress.getTime())*.001;return e+i-t.player.api.liveOffset};l.set.currentTime=function(e){var i=e-t.player.api.duration;if(i>0){i=0}t.player.api.liveOffset=i;t.log("Seeking to "+MistUtil.format.time(e)+" ("+Math.round(i*-10)/10+"s from live)");var r={startunix:i};if(i==0){r={}}t.player.api.setSource(MistUtil.http.url.addParam(t.source.url,r))};MistUtil.event.addListener(r,"progress",function(){t.player.api.lastProgress=new Date});t.player.api.lastProgress=new Date;t.player.api.liveOffset=0;MistUtil.event.addListener(r,"pause",function(){t.player.api.pausedAt=new Date});l.get.play=function(){return function(){if(t.player.api.paused&&t.player.api.pausedAt&&new Date-t.player.api.pausedAt>5e3){r.load();t.log("Reloading source..")}return r.play.apply(r,arguments)}};if(t.source.type=="html5/video/mp4"){l.get.currentTime=function(){return this.currentTime-t.player.api.liveOffset+t.info.lastms*.001}}}else{if(!isFinite(r.duration)){var p=0;for(var o in t.info.meta.tracks){p=Math.max(p,t.info.meta.tracks[o].lastms)}l.get.duration=function(){if(isFinite(this.duration)){return this.duration}return p*.001}}}}else{t.player.api=r}t.player.api.setSource=function(t){if(t!=this.source.src){this.source.src=t;this.load()}};t.player.api.setSubtitle=function(t){var e=r.getElementsByTagName("track");for(var i=e.length-1;i>=0;i--){r.removeChild(e[i])}if(t){var a=document.createElement("track");r.appendChild(a);a.kind="subtitles";a.label=t.label;a.srclang=t.lang;a.src=t.src;a.setAttribute("default","")}};t.player.setSize=function(t){this.api.style.width=t.width+"px";this.api.style.height=t.height+"px"};e(r)};
|
||||
mistplayers.html5={name:"HTML5 video player",mimes:["html5/application/vnd.apple.mpegurl","html5/video/mp4","html5/video/ogg","html5/video/webm","html5/audio/mp3","html5/audio/webm","html5/audio/ogg","html5/audio/wav"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(t){return MistUtil.array.indexOf(this.mimes,t)==-1?false:true},isBrowserSupported:function(t,e,i){if(location.protocol!=MistUtil.http.url.split(e.url).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(e.url).protocol=="http:"){i.log("This page was loaded over file://, the player might not behave as intended.")}else{i.log("HTTP/HTTPS mismatch for this source");return false}}if(t=="html5/application/vnd.apple.mpegurl"){var r=MistUtil.getAndroid();if(r&&parseFloat(r)<7){i.log("Skipping native HLS as videojs will do better");return false}}var a=false;var n=t.split("/");n.shift();try{n=n.join("/");function o(t){var e=document.createElement("video");if(e&&e.canPlayType(t)!=""){a=e.canPlayType(t)}return a}if(n=="video/mp4"){function s(t){function e(e){return("0"+t.init.charCodeAt(e).toString(16)).slice(-2)}switch(t.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp3";case"AC3":return"ec-3";case"H264":return"avc1."+e(1)+e(2)+e(3);case"HEVC":return"hev1."+e(1)+e(6)+e(7)+e(8)+e(9)+e(10)+e(11)+e(12);default:return t.codec.toLowerCase()}}var l={};for(var p in i.info.meta.tracks){if(i.info.meta.tracks[p].type!="meta"){l[s(i.info.meta.tracks[p])]=1}}l=MistUtil.object.keys(l);if(l.length){if(l.length>e.simul_tracks){var u=0;for(var p in l){var c=o(n+';codecs="'+l[p]+'"');if(c){u++}}return u>=e.simul_tracks}n+=';codecs="'+l.join(",")+'"'}}a=o(n)}catch(t){}return a},player:function(){this.onreadylist=[]},mistControls:true};var p=mistplayers.html5.player;p.prototype=new MistPlayer;p.prototype.build=function(t,e){var i=t.source.type.split("/");i.shift();var r=document.createElement("video");r.setAttribute("crossorigin","anonymous");var a=document.createElement("source");a.setAttribute("src",t.source.url);r.source=a;r.appendChild(a);a.type=i.join("/");var n=["autoplay","loop","poster"];for(var o in n){var s=n[o];if(t.options[s]){r.setAttribute(s,t.options[s]===true?"":t.options[s])}}if(t.options.muted){r.muted=true}if(t.options.controls=="stock"){r.setAttribute("controls","")}if(t.info.type=="live"){r.loop=false}if("Proxy"in window&&"Reflect"in window){var l={get:{},set:{}};t.player.api=new Proxy(r,{get:function(t,e,i){if(e in l.get){return l.get[e].apply(t,arguments)}var r=t[e];if(typeof r==="function"){return function(){return r.apply(t,arguments)}}return r},set:function(t,e,i){if(e in l.set){return l.set[e].call(t,i)}return t[e]=i}});if(t.source.type=="html5/audio/mp3"){l.set.currentTime=function(){t.log("Seek attempted, but MistServer does not currently support seeking in MP3.");return false}}if(t.info.type=="live"){l.get.duration=function(){var e=0;if(this.buffered.length){e=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-t.player.api.lastProgress.getTime())*.001;return e+i-t.player.api.liveOffset};l.set.currentTime=function(e){var i=e-t.player.api.duration;if(i>0){i=0}t.player.api.liveOffset=i;t.log("Seeking to "+MistUtil.format.time(e)+" ("+Math.round(i*-10)/10+"s from live)");var r={startunix:i};if(i==0){r={}}t.player.api.setSource(MistUtil.http.url.addParam(t.source.url,r))};MistUtil.event.addListener(r,"progress",function(){t.player.api.lastProgress=new Date});t.player.api.lastProgress=new Date;t.player.api.liveOffset=0;MistUtil.event.addListener(r,"pause",function(){t.player.api.pausedAt=new Date});l.get.play=function(){return function(){if(t.player.api.paused&&t.player.api.pausedAt&&new Date-t.player.api.pausedAt>5e3){r.load();t.log("Reloading source..")}return r.play.apply(r,arguments)}};if(t.source.type=="html5/video/mp4"){l.get.currentTime=function(){return this.currentTime-t.player.api.liveOffset+t.info.lastms*.001}}}else{if(!isFinite(r.duration)){var p=0;for(var o in t.info.meta.tracks){p=Math.max(p,t.info.meta.tracks[o].lastms)}l.get.duration=function(){if(isFinite(this.duration)){return this.duration}return p*.001}}}}else{t.player.api=r}t.player.api.setSource=function(t){if(t!=this.source.src){this.source.src=t;this.load()}};t.player.api.setSubtitle=function(t){var e=r.getElementsByTagName("track");for(var i=e.length-1;i>=0;i--){r.removeChild(e[i])}if(t){var a=document.createElement("track");r.appendChild(a);a.kind="subtitles";a.label=t.label;a.srclang=t.lang;a.src=t.src;a.setAttribute("default","")}};t.player.setSize=function(t){this.api.style.width=t.width+"px";this.api.style.height=t.height+"px"};e(r)};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -286,12 +286,12 @@ function MistVideo(streamName,options) {
|
|||
MistVideo.log("Stream info was loaded succesfully.");
|
||||
|
||||
if ("error" in d) {
|
||||
var e = data.error;
|
||||
var e = d.error;
|
||||
if ("on_error" in d) {
|
||||
MistVideo.log(e);
|
||||
e = data.on_error;
|
||||
e = d.on_error;
|
||||
}
|
||||
MistVideo.showError(e,{reload:true});
|
||||
MistVideo.showError(e,{reload:true,hideTitle:true});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,15 @@ function MistVideo(streamName,options) {
|
|||
msg = "An error was encountered.";
|
||||
//console.log("Err:",e);
|
||||
}
|
||||
if (MistVideo.state == "Stream is online") {
|
||||
MistVideo.showError(msg);
|
||||
}
|
||||
else {
|
||||
//it was probaby an error like "PIPELINE_ERROR_READ: FFmpegDemuxer: data source error" because the live stream has ended. Print it in the log, but display the stream state instead.
|
||||
MistVideo.log(msg,"error");
|
||||
MistVideo.showError(MistVideo.state,{polling:true});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//add general resize function
|
||||
|
@ -874,7 +882,7 @@ function MistVideo(streamName,options) {
|
|||
MistVideo.container.setAttribute("data-loading","");
|
||||
|
||||
//listen for changes to the srteam status
|
||||
//TODO switch to polling-mode if websockets are not supported
|
||||
//switch to polling-mode if websockets are not supported
|
||||
|
||||
function openWithGet() {
|
||||
var url = MistVideo.urlappend(options.host+"/json_"+encodeURIComponent(MistVideo.stream)+".js");
|
||||
|
@ -892,7 +900,7 @@ function MistVideo(streamName,options) {
|
|||
});
|
||||
}
|
||||
|
||||
if ("WebSocket" in window) {
|
||||
if (false) {
|
||||
function openSocket() {
|
||||
MistVideo.log("Opening stream status stream..");
|
||||
var url = MistVideo.options.host.replace(/^http/i,"ws");
|
||||
|
@ -920,6 +928,8 @@ function MistVideo(streamName,options) {
|
|||
openWithGet();
|
||||
|
||||
};
|
||||
var on_ended_show_state = false;
|
||||
var on_waiting_show_state = false;
|
||||
socket.addEventListener("message",function(e){
|
||||
var data = JSON.parse(e.data);
|
||||
if (!data) { MistVideo.showError("Error while parsing stream status stream. Obtained: "+e.data.toString(),{reload:true}); }
|
||||
|
@ -940,8 +950,23 @@ function MistVideo(streamName,options) {
|
|||
case "Stream is booting":
|
||||
case "Stream is waiting for data":
|
||||
case "Stream is shutting down":
|
||||
case "Stream status is invalid?!":
|
||||
if ((MistVideo.player) && (MistVideo.player.api) && (!MistVideo.player.api.paused)) {
|
||||
//something is (still) playing
|
||||
MistVideo.log(data.error,"error");
|
||||
|
||||
//on ended, show state
|
||||
if (!on_ended_show_state) {
|
||||
on_ended_show_state = MistUtil.event.addListener(MistVideo.video,"ended",function(){
|
||||
MistVideo.showError(data.error,{polling:true});
|
||||
});
|
||||
}
|
||||
if (!on_waiting_show_state) {
|
||||
on_ended_show_state = MistUtil.event.addListener(MistVideo.video,"waiting",function(){
|
||||
MistVideo.showError(data.error,{polling:true});
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
buttons = {polling:true};
|
||||
|
@ -957,6 +982,8 @@ function MistVideo(streamName,options) {
|
|||
//console.log("stream status stream said",data);
|
||||
MistVideo.state = "Stream is online";
|
||||
MistVideo.clearError();
|
||||
if (on_ended_show_state) { MistUtil.event.removeListener(on_ended_show_state); }
|
||||
if (on_waiting_show_state) { MistUtil.event.removeListener(on_waiting_show_state); }
|
||||
|
||||
if (!MistVideo.info) {
|
||||
onStreamInfo(data);
|
||||
|
|
33
embed/players/dash.all.min.js
vendored
33
embed/players/dash.all.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -5,4 +5,4 @@ wget https://cdn.dashjs.org/latest/dash.all.min.js -O dash.all.min.js
|
|||
|
||||
echo "Videojs"
|
||||
echo "You'll want to check for the latest version at https://videojs.com/getting-started/#download-cdn"
|
||||
wget https://vjs.zencdn.net/7.5.4/video.min.js -O video.min.js
|
||||
wget https://vjs.zencdn.net/7.6.6/video.min.js -O video.min.js
|
||||
|
|
13894
embed/players/video.js
13894
embed/players/video.js
File diff suppressed because it is too large
Load diff
23
embed/players/video.min.js
vendored
23
embed/players/video.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -418,7 +418,9 @@ MistSkins["default"] = {
|
|||
//remove all the things when unmuted
|
||||
var fu = function(){
|
||||
if (!MistVideo.video.muted) {
|
||||
if (largeMutedButton.parentNode) {
|
||||
MistVideo.container.removeChild(largeMutedButton);
|
||||
}
|
||||
MistVideo.video.removeEventListener("volumechange",fu);
|
||||
document.body.removeEventListener("click",i);
|
||||
MistVideo.video.removeEventListener("mouseenter",f);
|
||||
|
@ -900,6 +902,7 @@ MistSkins["default"] = {
|
|||
//obey video states
|
||||
MistUtil.event.addListener(video,"playing",function(){
|
||||
button.setState("playing");
|
||||
MistVideo.options.autoplay = true;
|
||||
},button);
|
||||
MistUtil.event.addListener(video,"pause",function(){
|
||||
button.setState("paused");
|
||||
|
@ -919,6 +922,7 @@ MistSkins["default"] = {
|
|||
}
|
||||
else {
|
||||
MistVideo.player.api.pause();
|
||||
MistVideo.options.autoplay = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -926,7 +930,10 @@ MistSkins["default"] = {
|
|||
if (MistVideo.player.api) {
|
||||
MistUtil.event.addListener(MistVideo.video,"click",function(){
|
||||
if (MistVideo.player.api.paused) { MistVideo.player.api.play(); }
|
||||
else if (!MistUtil.isTouchDevice()) { MistVideo.player.api.pause(); }
|
||||
else if (!MistUtil.isTouchDevice()) {
|
||||
MistVideo.player.api.pause();
|
||||
MistVideo.options.autoplay = false;
|
||||
}
|
||||
},button);
|
||||
}
|
||||
|
||||
|
@ -1699,7 +1706,7 @@ MistSkins["default"] = {
|
|||
message_container.className = "message";
|
||||
this.appendChild(message_container);
|
||||
|
||||
if (!options.polling && !options.passive) {
|
||||
if (!options.polling && !options.passive && !options.hideTitle) {
|
||||
var header = document.createElement("h3");
|
||||
message_container.appendChild(header);
|
||||
header.appendChild(document.createTextNode("The player has encountered a problem"));
|
||||
|
@ -1709,7 +1716,8 @@ MistSkins["default"] = {
|
|||
message_container.appendChild(p);
|
||||
message_container.update = function(message){
|
||||
MistUtil.empty(p);
|
||||
p.appendChild(document.createTextNode(message));
|
||||
//p.appendChild(document.createTextNode(message));
|
||||
p.innerHTML = message; //allow custom html messages (configured in MI/HTTP/nostreamtext)
|
||||
};
|
||||
if (message) {
|
||||
if (MistVideo.info.on_error) {
|
||||
|
@ -1905,7 +1913,7 @@ MistSkins["default"] = {
|
|||
container.clear();
|
||||
}
|
||||
};
|
||||
container.clear = function(message){
|
||||
container.clear = function(){
|
||||
var countdowns = container.querySelectorAll("svg.icon.timeout");
|
||||
for (var i = 0; i < countdowns.length; i++) {
|
||||
MistVideo.timers.stop(countdowns[i].timeout);
|
||||
|
@ -2479,16 +2487,6 @@ MistSkins.dev.structure.submenu.children.unshift({
|
|||
style: {"flex-wrap": "wrap"},
|
||||
children: [
|
||||
{
|
||||
if: function(){ return !!(this.player && this.player.api); },
|
||||
then: {
|
||||
type: "button",
|
||||
title: "Reload the video source",
|
||||
label: "video.load();",
|
||||
onclick: function(){
|
||||
this.player.api.load();
|
||||
}
|
||||
}
|
||||
},{
|
||||
type: "button",
|
||||
title: "Build MistVideo again",
|
||||
label: "MistVideo.reload();",
|
||||
|
@ -2615,10 +2613,10 @@ function MistSkin(MistVideo) {
|
|||
|
||||
//load css
|
||||
var styles = [];
|
||||
var toload = 0;
|
||||
for (var i in this.css) {
|
||||
if (typeof this.css[i] == "string") {
|
||||
styles.push(MistUtil.css.load(MistVideo.urlappend(this.css[i]),this.colors));
|
||||
var a = MistUtil.css.load(MistVideo.urlappend(this.css[i]),this.colors);
|
||||
styles.push(a);
|
||||
}
|
||||
}
|
||||
this.css = styles; //overwrite
|
||||
|
|
|
@ -363,10 +363,8 @@ var MistUtil = {
|
|||
callback(xhr.response);
|
||||
}
|
||||
else if (errorCallback) {
|
||||
xhr.onerror = function() {
|
||||
errorCallback(xhr);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (errorCallback) {
|
||||
xhr.onerror = function() {
|
||||
|
@ -421,7 +419,7 @@ var MistUtil = {
|
|||
sanitizeHost: function(host){
|
||||
var split = MistUtil.http.url.split(host);
|
||||
var out = split.protocol + "//" + split.host + (split.port && (split.port != "") ? ":"+split.port : "") + (split.hash && (split.hash != "") ? "#"+split.hash : "") + (split.path ? (split.path.charAt(0) == "/" ? split.path : "/"+split.path) : "");
|
||||
console.log("converted",host,"to",out);
|
||||
//console.log("converted",host,"to",out);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +459,12 @@ var MistUtil = {
|
|||
}
|
||||
cache[url] = d;
|
||||
},function(){
|
||||
throw "Failed to load CSS from "+url;
|
||||
var d = "/*Failed to load*/";
|
||||
for (var i in cache[url]) {
|
||||
cache[url][i](d);
|
||||
}
|
||||
cache[url] = d;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -998,5 +1001,9 @@ var MistUtil = {
|
|||
return "firefox";
|
||||
}
|
||||
return false; //unknown
|
||||
},
|
||||
getAndroid: function(){
|
||||
var match = navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);
|
||||
return match ? match[1] : false;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -118,7 +118,7 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
me.dash = player;
|
||||
|
||||
//add listeners for events that we can log
|
||||
var skipEvents = ["METRIC_ADDED","METRIC_CHANGED","METRICS_CHANGED","FRAGMENT_LOADING_STARTED","FRAGMENT_LOADING_COMPLETED","LOG","PLAYBACK_TIME_UPDATED","PLAYBACK_PROGRESS"];
|
||||
var skipEvents = ["METRIC_ADDED","METRIC_UPDATED","METRIC_CHANGED","METRICS_CHANGED","FRAGMENT_LOADING_STARTED","FRAGMENT_LOADING_COMPLETED","LOG","PLAYBACK_TIME_UPDATED","PLAYBACK_PROGRESS"];
|
||||
for (var i in dashjs.MediaPlayer.events) {
|
||||
if (skipEvents.indexOf(i) < 0) {
|
||||
me.dash.on(dashjs.MediaPlayer.events[i],function(e){
|
||||
|
|
|
@ -18,6 +18,14 @@ mistplayers.html5 = {
|
|||
}
|
||||
}
|
||||
|
||||
if (mimetype == "html5/application/vnd.apple.mpegurl") {
|
||||
var android = MistUtil.getAndroid();
|
||||
if (android && (parseFloat(android) < 7)) {
|
||||
MistVideo.log("Skipping native HLS as videojs will do better");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var support = false;
|
||||
var shortmime = mimetype.split("/");
|
||||
|
|
|
@ -82,6 +82,19 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
vjsopts.controls = false;
|
||||
}
|
||||
|
||||
//for android < 7, enable override native
|
||||
function androidVersion(){
|
||||
var match = navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);
|
||||
return match ? match[1] : false;
|
||||
}
|
||||
var android = MistUtil.getAndroid();
|
||||
if (android && (parseFloat(android) < 7)) {
|
||||
MistVideo.log("Detected android < 7: instructing videojs to override native playback");
|
||||
vjsopts.html5 = {hls: {overrideNative: true}};
|
||||
vjsopts.nativeAudioTracks = false;
|
||||
vjsopts.nativeVideoTracks = false;
|
||||
}
|
||||
|
||||
me.onready(function(){
|
||||
MistVideo.log("Building videojs");
|
||||
me.videojs = videojs(ele,vjsopts,function(){
|
||||
|
@ -96,37 +109,6 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
}
|
||||
};
|
||||
|
||||
//special HLS live when-stream-ends code because holy crap latency
|
||||
MistUtil.event.addListener(MistVideo.options.target,"error",function(e){
|
||||
var eventdata = false;
|
||||
switch (e.message) {
|
||||
case "Stream is shutting down": {
|
||||
//MistVideo.clearError(); //we've probably got loads of buffer left to play
|
||||
e.preventDefault();
|
||||
break;
|
||||
}
|
||||
case "Stream is offline": {
|
||||
MistVideo.clearError(); //we've probably got loads of buffer left to play
|
||||
e.preventDefault();
|
||||
|
||||
if (MistVideo.video) {
|
||||
eventdata = MistUtil.event.addListener(MistVideo.video,"ended",function(){
|
||||
//show stream offline error
|
||||
MistVideo.showError("Stream is offline ",{polling:true});
|
||||
|
||||
if (eventdata) { MistUtil.event.removeListener(eventdata); }
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Stream is waiting for data": {
|
||||
if (eventdata) { MistUtil.event.removeListener(eventdata); }
|
||||
me.api.pause();
|
||||
MistVideo.reload();
|
||||
break;
|
||||
}
|
||||
}
|
||||
},MistVideo.video);
|
||||
});
|
||||
|
||||
MistVideo.log("Built html");
|
||||
|
@ -160,7 +142,6 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
MistVideo.player.api.load = function(){};
|
||||
|
||||
overrides.set.currentTime = function(value){
|
||||
console.log("seeking to",value);
|
||||
MistVideo.player.videojs.currentTime(value); //seeking backwards does not work if we set it on the video directly
|
||||
//MistVideo.video.currentTime = value;
|
||||
};
|
||||
|
@ -276,23 +257,58 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
else {
|
||||
//load the videojs player
|
||||
|
||||
var timer = false;
|
||||
function reloadVJSrateLimited(){
|
||||
try {
|
||||
MistVideo.video.pause();
|
||||
} catch (e) {}
|
||||
MistVideo.showError("Error in videojs player");
|
||||
|
||||
|
||||
//rate limit the reload
|
||||
if (!window.mistplayer_videojs_failures) {
|
||||
window.mistplayer_videojs_failures = 1;
|
||||
MistVideo.reload();
|
||||
}
|
||||
else {
|
||||
if (!timer) {
|
||||
var delay = 0.05*Math.pow(2,window.mistplayer_videojs_failures)
|
||||
MistVideo.log("Rate limiter activated: MistPlayer reload delayed by "+Math.round(delay*10)/10+" seconds.","error");
|
||||
timer = MistVideo.timers.start(function(){
|
||||
timer = false;
|
||||
delete window.videojs;
|
||||
MistVideo.reload();
|
||||
},delay*1e3);
|
||||
window.mistplayer_videojs_failures++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var scripturl = MistVideo.urlappend(mistplayers.videojs.scriptsrc(MistVideo.options.host));
|
||||
var scripttag;
|
||||
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
||||
var f = function (msg, url, lineNo, columnNo, error) {
|
||||
if (!scripttag) { return; }
|
||||
|
||||
if (url == scripttag.src) {
|
||||
//error in internal videojs code
|
||||
//console.error(me.videojs,MistVideo.video,ele,arguments);
|
||||
|
||||
ele.pause();
|
||||
|
||||
MistVideo.showError("Error in videojs player");
|
||||
|
||||
MistVideo.reload();
|
||||
window.removeEventListener("error",f);
|
||||
reloadVJSrateLimited();
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
window.addEventListener("error",f);
|
||||
|
||||
var old_console_error = console.error;
|
||||
console.error = function(){
|
||||
if (arguments[0] == "VIDEOJS:") {
|
||||
//videojs reports an error
|
||||
console.error = old_console_error;
|
||||
reloadVJSrateLimited();
|
||||
}
|
||||
return old_console_error.apply(this,arguments);
|
||||
};
|
||||
|
||||
scripttag = MistUtil.scripts.insert(scripturl,{
|
||||
onerror: function(e){
|
||||
|
|
|
@ -66,6 +66,20 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
MistUtil.event.addListener(video,"loadeddata",correctSubtitleSync);
|
||||
MistUtil.event.addListener(video,"seeked",correctSubtitleSync);
|
||||
|
||||
if (!MistVideo.options.autoplay) {
|
||||
MistUtil.event.addListener(video,"canplay",function(){
|
||||
var onplay = MistUtil.event.addListener(video,"play",function(){
|
||||
MistVideo.log("Pausing because autoplay is disabled");
|
||||
var onpause = MistUtil.event.addListener(video,"pause",function(){
|
||||
MistVideo.options.autoplay = false;
|
||||
MistUtil.event.removeListener(onpause);
|
||||
});
|
||||
me.api.pause();
|
||||
MistUtil.event.removeListener(onplay);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var seekoffset = 0;
|
||||
var hasended = false;
|
||||
var currenttracks = [];
|
||||
|
@ -84,10 +98,11 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
If a live stream ends, we receive an on_disconnect, but no on_stop
|
||||
If MistOutWebRTC crashes, we receive an on_stop and then an on_disconnect
|
||||
*/
|
||||
if (hasended) {
|
||||
if (!hasended) {
|
||||
MistVideo.showError("Connection to media server ended unexpectedly.");
|
||||
}
|
||||
video.pause();
|
||||
}
|
||||
|
||||
},
|
||||
on_answer_sdp: function (ev) {
|
||||
if (!ev.result) {
|
||||
|
@ -113,8 +128,8 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
MistUtil.event.send("durationchange",d,video);
|
||||
}
|
||||
|
||||
if (currenttracks != ev.tracks) {
|
||||
var tracks = MistUtil.tracks.parse(MistVideo.info.meta.tracks);
|
||||
if ((ev.tracks) && (currenttracks != ev.tracks)) {
|
||||
var tracks = MistVideo.info ? MistUtil.tracks.parse(MistVideo.info.meta.tracks) : [];
|
||||
for (var i in ev.tracks) {
|
||||
if (currenttracks.indexOf(ev.tracks[i]) < 0) {
|
||||
//find track type
|
||||
|
@ -169,6 +184,7 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
},
|
||||
on_stop: function(){
|
||||
MistVideo.log("Websocket sent on_stop");
|
||||
video.pause();
|
||||
MistUtil.event.send("ended",null,video);
|
||||
hasended = true;
|
||||
}
|
||||
|
@ -247,7 +263,19 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
};
|
||||
this.seek = function(seekTime){
|
||||
var p = new Promise(function(resolve,reject){
|
||||
if (!thisWebRTCPlayer.isConnected || !thisWebRTCPlayer.signaling) { return reject("Failed seek: not connected"); }
|
||||
if (!thisWebRTCPlayer.isConnected || !thisWebRTCPlayer.signaling) {
|
||||
if (thisWebRTCPlayer.isConnecting) {
|
||||
|
||||
var listener = MistUtil.event.addListener(MistVideo.video,"loadstart",function(){
|
||||
thisWebRTCPlayer.seek(seekTime);
|
||||
MistUtil.event.removeListener(listener);
|
||||
});
|
||||
return reject("Not connected yet, will seek once connected");
|
||||
}
|
||||
else {
|
||||
return reject("Failed seek: not connected");
|
||||
}
|
||||
}
|
||||
thisWebRTCPlayer.signaling.send({type: "seek", "seek_time": (seekTime == "live" ? "live" : seekTime*1e3)});
|
||||
if ("seekPromise" in thisWebRTCPlayer.signaling) {
|
||||
thisWebRTCPlayer.signaling.seekPromise.reject("Doing new seek");
|
||||
|
@ -368,8 +396,15 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
set: function(value){
|
||||
seekoffset = value - video.currentTime;
|
||||
video.pause();
|
||||
me.webrtc.seek(value);
|
||||
var promise = me.webrtc.seek(value);
|
||||
MistUtil.event.send("seeking",value,video);
|
||||
if (promise) {
|
||||
promise.catch(function(e){
|
||||
//do nothing
|
||||
//keep this code because not handling this shows an error message in the console:
|
||||
// (Uncaught (in promise) Failed seek: not connected)
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ f.submenu[e]))}else if("hiddenmenu"in f)for(e in o=$("<span>").addClass("hiddenm
|
|||
a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,c){if("capabilities"in mist.data){var d=!1,b=mist.data.capabilities[a];c in b&&(d=b[c]);c+".exe"in b&&(d=b[c+".exe"]);return d}throw"Request capabilities first";},buildUI:function(a){var c=$("<div>").addClass("input_container"),d;for(d in a){var b=a[d];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));
|
||||
c.append(f);if("classes"in b)for(var n in b.classes)f.addClass(b.classes[n])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"==b.type)for(n in f=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&f.css(b.css),c.append(f),b.buttons){var o=b.buttons[n],e=$("<button>").text(o.label).data("opts",o);"css"in o&&e.css(o.css);
|
||||
if("classes"in o)for(var r in o.classes)e.addClass(o.classes[r]);f.append(e);switch(o.type){case "cancel":e.addClass("cancel").click(o["function"]);break;case "save":e.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a=
|
||||
$(this).getval(),b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(o["function"])}}else{o=$("<label>").addClass("UIelement");c.append(o);"css"in b&&o.css(b.css);o.append($("<span>").addClass("label").html("label"in b?b.label+":":""));if("classes"in b)for(r in b.classes)o.addClass(b.classes[r]);e=$("<span>").addClass("field_container");
|
||||
$(this).getval(),b=$(this).data("pointer");if(""===a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(o["function"])}}else{o=$("<label>").addClass("UIelement");c.append(o);"css"in b&&o.css(b.css);o.append($("<span>").addClass("label").html("label"in b?b.label+":":""));if("classes"in b)for(r in b.classes)o.addClass(b.classes[r]);e=$("<span>").addClass("field_container");
|
||||
o.append(e);switch(b.type){case "password":f=$("<input>").attr("type","password");break;case "int":f=$("<input>").attr("type","number");"min"in b&&f.attr("min",b.min);"max"in b&&f.attr("max",b.max);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":f=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],
|
||||
[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":f=$("<select>");for(n in b.select){var i=$("<option>");"string"==typeof b.select[n]?i.text(b.select[n]):i.val(b.select[n][0]).text(b.select[n][1]);
|
||||
f.append(i)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden":f=$("<input>").attr("type","hidden");o.hide();break;case "email":f=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":f=$("<input>").attr("type","text");"filetypes"in b&&f.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":f=$("<input>").attr("type",
|
||||
|
@ -85,12 +85,13 @@ type:"str",validate:["required"],help:"Enter your desired username. In the futur
|
|||
mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");
|
||||
else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},
|
||||
{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var f=$("<span>").text("Loading.."),n=$("<span>"),o=$("<span>").addClass("logs"),e=$("<span>"),r=$("<span>"),i=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,
|
||||
defaultStream:mist.data.config.defaultStream},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
|
||||
defaultStream:mist.data.config.defaultStream,trustedproxy:mist.data.config.trustedproxy},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
|
||||
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:i,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:n},{type:"span",
|
||||
label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:o},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},
|
||||
{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+
|
||||
b+"/PASSPHRASE.json.",LTSonly:!0},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",
|
||||
LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
|
||||
b+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",LTSonly:!0,pointer:{main:g,index:"trustedproxy"}},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",
|
||||
LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,
|
||||
index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
|
||||
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?k.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var j=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},
|
||||
{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&j(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");
|
||||
else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");
|
||||
|
@ -229,7 +230,7 @@ b+'~="'+$(this).getval()+'"]) { display: none; }\n';$(c).data("content",c.innerH
|
|||
a&&b.push({type:"help",help:a.desc});if("sort"in a){var n=[],o;for(o in f)if(a[f[o]])for(var e in a[f[o]]){var r=a[f[o]][e];if(Array.isArray(r))for(var i in r){if(!("validate"in r[i]))r[i].validate=[];r[i].validate=f[o];r[i].id=e;n.push(r[i])}else{if(!("validate"in r))r.validate=[];r.validate.push(f[o]);r.id=e;n.push(r)}}n.sort(function(b,c){return(""+b[a.sort]).localeCompare(c[a.sort])});for(e in n){r=n[e];b.push(d(r.validate,r.id,r))}}else for(o in f)if(a[f[o]]){b.push($("<h4>").text(UI.format.capital(f[o])+
|
||||
" parameters"));for(e in a[f[o]]){r=a[f[o]][e];if(Array.isArray(r))for(i in r)b.push(d(o,e,r[i]));else b.push(d(o,e,r))}}return b},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};
|
||||
function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
|
||||
$.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "debug":c=Number($(this).val());break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))});
|
||||
$.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "debug":c=$(this).val()==""?null:Number($(this).val());break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))});
|
||||
break;case "unix":c!=""&&(c=Math.round(new Date($(this).val())/1E3));break;case "selectinput":c=$(this).children("select").first().val();c=="CUSTOM"&&(c=$(this).children("label").first().find(".field_container").children().first().getval());break;case "inputlist":c=[];$(this).children().each(function(){$(this).val()!=""&&c.push($(this).val())});break;case "sublist":c=$(this).data("savelist")}return c};
|
||||
$.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),d;for(d in a)c.values.append(c.prototype.clone(true).val(a[d]));c.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
|
||||
"undefined")return $(this);d=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&d.children("select").val(a[1]);break;case "checklist":c=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(d in a)c.filter('[name="'+a[d]+'"]').prop("checked",true);break;case "unix":if(typeof a!="undefined"){a=new Date(Math.round(a)*1E3);a.setMinutes(a.getMinutes()-a.getTimezoneOffset());a=a.toISOString();$(this).val(a.split("Z")[0])}break;case "selectinput":a===
|
||||
|
|
16
lsp/mist.js
16
lsp/mist.js
|
@ -468,7 +468,7 @@ var UI = {
|
|||
var val = $(this).getval();
|
||||
var pointer = $(this).data('pointer');
|
||||
|
||||
if (val == '') {
|
||||
if (val === '') {
|
||||
if ('default' in $(this).data('opts')) {
|
||||
val = $(this).data('opts')['default'];
|
||||
}
|
||||
|
@ -2367,7 +2367,8 @@ var UI = {
|
|||
debug: mist.data.config.debug,
|
||||
accesslog: mist.data.config.accesslog,
|
||||
prometheus: mist.data.config.prometheus,
|
||||
defaultStream: mist.data.config.defaultStream
|
||||
defaultStream: mist.data.config.defaultStream,
|
||||
trustedproxy: mist.data.config.trustedproxy
|
||||
};
|
||||
var b = {};
|
||||
if ("bandwidth" in mist.data) {
|
||||
|
@ -2494,6 +2495,15 @@ var UI = {
|
|||
},
|
||||
help: "Make stats available in Prometheus format. These can be accessed via "+host+"/PASSPHRASE or "+host+"/PASSPHRASE.json.",
|
||||
LTSonly: true
|
||||
},{
|
||||
type: "inputlist",
|
||||
label: "Trusted proxies",
|
||||
help: "List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",
|
||||
LTSonly: true,
|
||||
pointer: {
|
||||
main: s,
|
||||
index: "trustedproxy"
|
||||
}
|
||||
},{
|
||||
type: "selectinput",
|
||||
label: "Load balancer bandwidth limit",
|
||||
|
@ -6878,7 +6888,7 @@ $.fn.getval = function(){
|
|||
val = $(this).html();
|
||||
break;
|
||||
case 'debug':
|
||||
val = Number($(this).val());
|
||||
val = $(this).val() == "" ? null : Number($(this).val());
|
||||
break;
|
||||
case 'checkbox':
|
||||
val = $(this).prop('checked');
|
||||
|
|
Loading…
Add table
Reference in a new issue