LSP: lots of fixes
This commit is contained in:
parent
353d58e98f
commit
5bc15ea794
3 changed files with 207 additions and 205 deletions
102
lsp/functions.js
102
lsp/functions.js
File diff suppressed because one or more lines are too long
49
lsp/main.js
49
lsp/main.js
|
@ -28,7 +28,6 @@
|
||||||
*/
|
*/
|
||||||
var ltypes =
|
var ltypes =
|
||||||
[
|
[
|
||||||
['kb_total', 'Total bandwidth'],
|
|
||||||
['kbps_max', 'Current bandwidth'],
|
['kbps_max', 'Current bandwidth'],
|
||||||
['users', 'Concurrent users'],
|
['users', 'Concurrent users'],
|
||||||
['geo', 'Geolimited'],
|
['geo', 'Geolimited'],
|
||||||
|
@ -36,6 +35,7 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
/* Not currently supported but may return at a later time:
|
/* Not currently supported but may return at a later time:
|
||||||
|
['kb_total', 'Total bandwidth'],
|
||||||
['duration', 'Duration'],
|
['duration', 'Duration'],
|
||||||
['str_kbps_min', 'Minimum bitrate'],
|
['str_kbps_min', 'Minimum bitrate'],
|
||||||
['str_kbps_max', 'Maximum bitrate']
|
['str_kbps_max', 'Maximum bitrate']
|
||||||
|
@ -1063,20 +1063,19 @@
|
||||||
$table.html("<thead><th>Hard/soft</th><th>Type</th><th>Value</th><th>Applies to</th><th>Action</th></thead>");
|
$table.html("<thead><th>Hard/soft</th><th>Type</th><th>Value</th><th>Applies to</th><th>Action</th></thead>");
|
||||||
$tbody = $('<tbody>');
|
$tbody = $('<tbody>');
|
||||||
|
|
||||||
var i, tr, limit, stream, clims,
|
var i, tr, limit, stream, currentlims,
|
||||||
alllimits = settings.settings.config.limits;
|
alllimits = settings.settings.config.limits;
|
||||||
|
|
||||||
for(stream in settings.settings.streams)
|
for(stream in settings.settings.streams)
|
||||||
{
|
{
|
||||||
clims = settings.settings.streams[stream].limits;
|
currentlims = settings.settings.streams[stream].limits;
|
||||||
|
|
||||||
$.each(clims, function(k, v)
|
for (index in currentlims) {
|
||||||
{
|
currentlims[index].appliesto = stream;
|
||||||
this.appliesto = stream;
|
currentlims[index].appliesi = index;
|
||||||
this.appliesi = k;
|
}
|
||||||
});
|
|
||||||
|
|
||||||
alllimits = alllimits.concat(clims);
|
alllimits = alllimits.concat(currentlims);
|
||||||
}
|
}
|
||||||
|
|
||||||
len = alllimits.length;
|
len = alllimits.length;
|
||||||
|
@ -1090,14 +1089,42 @@
|
||||||
limit = alllimits[i];
|
limit = alllimits[i];
|
||||||
$tbody.append(BuildLimitRow(limit));
|
$tbody.append(BuildLimitRow(limit));
|
||||||
}
|
}
|
||||||
|
for (stream in settings.settings.streams) {
|
||||||
|
for (limit in settings.settings.streams[stream].limits) {
|
||||||
|
delete settings.settings.streams[stream].limits[limit].appliesto;
|
||||||
|
delete settings.settings.streams[stream].limits[limit].appliesi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$table.append($tbody);
|
$table.append($tbody);
|
||||||
$('#page').append($table);
|
$('#page').append($table);
|
||||||
|
|
||||||
|
//tooltip
|
||||||
|
$('.limits_type').add('.limits_name').hover(function(e){
|
||||||
|
removeTooltip();
|
||||||
|
showTooltip(e,undefined,$(this).children(':selected').data('desc'));
|
||||||
|
},function(){
|
||||||
|
removeTooltip();
|
||||||
|
});
|
||||||
|
|
||||||
|
//change limit value box on type change
|
||||||
|
$('.limits_name').change(function(){
|
||||||
|
var value = $(this).parents('.limits_row').find(".limits_val").val();
|
||||||
|
$(this).parents('.limits_row').children('.limit_input_container').html('');
|
||||||
|
BuildLimitRowInput(
|
||||||
|
$(this).parents('.limits_row').children('.limit_input_container'),
|
||||||
|
{
|
||||||
|
'name': $(this).parents('.limits_row').find(".limits_name").val(),
|
||||||
|
'type': $(this).parents('.limits_row').find(".limits_type").val(),
|
||||||
|
'val': value
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
//build buttons
|
//build buttons
|
||||||
$('#page').append(
|
$('#page').append(
|
||||||
$('<button>').text('Add limit').click(function(){
|
$('<button>').text('Add limit').click(function(){
|
||||||
$tbody.append(BuildLimitRow({"name":"kb_total", "val":0, "type":"soft"}));
|
$tbody.append(BuildLimitRow({"name":"kbps_max", "val":0, "type":"soft"}));
|
||||||
})
|
})
|
||||||
).append($('<br>')).append(
|
).append($('<br>')).append(
|
||||||
$('<button>').text('Save all').click(function(){
|
$('<button>').text('Save all').click(function(){
|
||||||
|
@ -1139,8 +1166,10 @@
|
||||||
}
|
}
|
||||||
if($(this).find('.new-limit-appliesto').val() == 'server') {
|
if($(this).find('.new-limit-appliesto').val() == 'server') {
|
||||||
settings.settings.config.limits.push(obj);
|
settings.settings.config.limits.push(obj);
|
||||||
|
console.log('new server limit',obj);
|
||||||
}else{
|
}else{
|
||||||
settings.settings.streams[$(this).find('.new-limit-appliesto').val()].limits.push(obj);
|
settings.settings.streams[$(this).find('.new-limit-appliesto').val()].limits.push(obj);
|
||||||
|
console.log('new stream limit',$(this).find('.new-limit-appliesto').val(),obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
loadSettings(function(){
|
loadSettings(function(){
|
||||||
|
|
|
@ -1,164 +1,167 @@
|
||||||
function mistembed(streamname)
|
function mistembed(streamname)
|
||||||
{
|
{
|
||||||
// return the current flash version
|
// return the current flash version
|
||||||
function flash_version()
|
function flash_version()
|
||||||
{
|
{
|
||||||
var version = 0;
|
var version = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// check in the mimeTypes
|
// check in the mimeTypes
|
||||||
version = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description.replace(/([^0-9\.])/g, '').split('.')[0];
|
version = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description.replace(/([^0-9\.])/g, '').split('.')[0];
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// for our special friend IE
|
// for our special friend IE
|
||||||
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable("$version").replace(/([^0-9\,])/g, '').split(',')[0];
|
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable("$version").replace(/([^0-9\,])/g, '').split(',')[0];
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
|
|
||||||
return parseInt(version, 10);
|
return parseInt(version, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
function html5_video_type(type)
|
function html5_video_type(type)
|
||||||
{
|
{
|
||||||
var support = false;
|
var support = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var v = document.createElement('video');
|
var v = document.createElement('video');
|
||||||
|
|
||||||
if( v && v.canPlayType(type) != "" )
|
if( v && v.canPlayType(type) != "" )
|
||||||
{
|
{
|
||||||
support = true;
|
support = true;
|
||||||
}
|
}
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
|
|
||||||
return support;
|
return support;
|
||||||
}
|
}
|
||||||
|
|
||||||
// what does the browser support - used in hasSupport()
|
// what does the browser support - used in hasSupport()
|
||||||
supports =
|
supports =
|
||||||
{
|
{
|
||||||
flashversion: flash_version(),
|
flashversion: flash_version(),
|
||||||
hls: html5_video_type('application/vnd.apple.mpegURL'),
|
hls: html5_video_type('application/vnd.apple.mpegURL'),
|
||||||
ism: html5_video_type('application/vnd.ms-ss')
|
ism: html5_video_type('application/vnd.ms-ss')
|
||||||
};
|
};
|
||||||
|
|
||||||
// return true if a type is supported
|
// return true if a type is supported
|
||||||
function hasSupport(type)
|
function hasSupport(type)
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case 'f4v': return supports.flashversion >= 11; break;
|
case 'f4v': return supports.flashversion >= 11; break;
|
||||||
case 'rtmp': return supports.flashversion >= 10; break;
|
case 'rtmp': return supports.flashversion >= 10; break;
|
||||||
case 'flv': return supports.flashversion >= 7; break;
|
case 'flv': return supports.flashversion >= 7; break;
|
||||||
|
|
||||||
case 'hls': return supports.hls; break;
|
case 'hls': return supports.hls; break;
|
||||||
case 'ism': return supports.ism; break;
|
case 'ism': return supports.ism; break;
|
||||||
|
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// build HTML for certain kinds of types
|
// build HTML for certain kinds of types
|
||||||
function buildPlayer(src, container, videowidth, videoheight, vtype)
|
function buildPlayer(src, container, videowidth, videoheight, vtype)
|
||||||
{
|
{
|
||||||
// used to recalculate the width/height
|
// used to recalculate the width/height
|
||||||
var ratio;
|
var ratio;
|
||||||
|
|
||||||
// get the container's width/height
|
// get the container's width/height
|
||||||
var containerwidth = parseInt(container.scrollWidth, 10);
|
var containerwidth = parseInt(container.scrollWidth, 10);
|
||||||
var containerheight = parseInt(container.scrollHeight, 10);
|
var containerheight = parseInt(container.scrollHeight, 10);
|
||||||
|
|
||||||
if(videowidth > containerwidth && containerwidth > 0)
|
if(videowidth > containerwidth && containerwidth > 0)
|
||||||
{
|
{
|
||||||
ratio = videowidth / containerwidth;
|
ratio = videowidth / containerwidth;
|
||||||
|
|
||||||
videowidth /= ratio;
|
videowidth /= ratio;
|
||||||
videoheight /= ratio;
|
videoheight /= ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(videoheight > containerheight && containerheight > 0)
|
if(videoheight > containerheight && containerheight > 0)
|
||||||
{
|
{
|
||||||
ratio = videoheight / containerheight;
|
ratio = videoheight / containerheight;
|
||||||
|
|
||||||
videowidth /= ratio;
|
videowidth /= ratio;
|
||||||
videoheight /= ratio;
|
videoheight /= ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the video type is 'live',
|
// if the video type is 'live',
|
||||||
lappend = vtype == 'live' ? "&streamType=live" : "";
|
lappend = vtype == 'live' ? "&streamType=live" : "";
|
||||||
|
|
||||||
switch(src.type)
|
switch(src.type)
|
||||||
{
|
{
|
||||||
case 'f4v':
|
case 'f4v':
|
||||||
case 'rtmp':
|
case 'rtmp':
|
||||||
case 'flv':
|
case 'flv':
|
||||||
container.innerHTML = '<object width="' + videowidth + '" height="' + videoheight + '"><param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf"></param><param name="flashvars" value="src=' + encodeURI(src.url) + '&controlBarMode=floating&expandedBufferTime=4&minContinuousPlaybackTime=10' + lappend + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + videowidth + '" height="' + videoheight + '" flashvars="src=' + encodeURI(src.url) + '&controlBarMode=floating&expandedBufferTime=4&minContinuousPlaybackTime=10"></embed></object>';
|
container.innerHTML = '<object width="' + videowidth + '" height="' + videoheight + '"><param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf"></param><param name="flashvars" value="src=' + encodeURI(src.url) + '&controlBarMode=floating&expandedBufferTime=4&minContinuousPlaybackTime=10' + lappend + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + videowidth + '" height="' + videoheight + '" flashvars="src=' + encodeURI(src.url) + '&controlBarMode=floating&expandedBufferTime=4&minContinuousPlaybackTime=10"></embed></object>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'hls':
|
case 'hls':
|
||||||
case 'ism':
|
case 'ism':
|
||||||
container.innerHTML = '<video width="' + videowidth + '" height="' + videoheight + '" src="' + encodeURI(src.url) + '" controls="controls" ><strong>No HTML5 video support</strong></video>';
|
container.innerHTML = '<video width="' + videowidth + '" height="' + videoheight + '" src="' + encodeURI(src.url) + '" controls="controls" ><strong>No HTML5 video support</strong></video>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'fallback':
|
case 'fallback':
|
||||||
container.innerHTML = '<strong>No support for any player found</strong>';
|
container.innerHTML = '<strong>No support for any player found</strong>';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var video = mistvideo[streamname],
|
var video = mistvideo[streamname],
|
||||||
container = document.createElement('div'),
|
container = document.createElement('div'),
|
||||||
scripts = document.getElementsByTagName('script'),
|
scripts = document.getElementsByTagName('script'),
|
||||||
me = scripts[scripts.length - 1];
|
me = scripts[scripts.length - 1];
|
||||||
|
|
||||||
|
if (video.width == 0) { video.width = 250; }
|
||||||
|
if (video.height == 0) { video.height = 250; }
|
||||||
|
|
||||||
|
// create the container
|
||||||
|
me.parentNode.insertBefore(container, me);
|
||||||
|
// set the class to 'mistvideo'
|
||||||
|
container.setAttribute('class', 'mistvideo');
|
||||||
|
// remove script tag
|
||||||
|
me.parentNode.removeChild(me);
|
||||||
|
|
||||||
// create the container
|
if(video.error)
|
||||||
me.parentNode.insertBefore(container, me);
|
{
|
||||||
// set the class to 'mistvideo'
|
// there was an error; display it
|
||||||
container.setAttribute('class', 'mistvideo');
|
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join('');
|
||||||
// remove script tag
|
}else if(video.source.length < 1)
|
||||||
me.parentNode.removeChild(me);
|
{
|
||||||
|
// no stream sources
|
||||||
if(video.error)
|
container.innerHTML = '<strong>Error: no streams found</strong>';
|
||||||
{
|
}else{
|
||||||
// there was an error; display it
|
// no error, and sources found. Check the video types and output the best
|
||||||
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join('');
|
// available video player.
|
||||||
}else if(video.source.length < 1)
|
var i, video,
|
||||||
{
|
|
||||||
// no stream sources
|
|
||||||
container.innerHTML = '<strong>Error: no streams found</strong>';
|
|
||||||
}else{
|
|
||||||
// no error, and sources found. Check the video types and output the best
|
|
||||||
// available video player.
|
|
||||||
var i, video,
|
|
||||||
vtype = video.type ? video.type : 'unknown';
|
vtype = video.type ? video.type : 'unknown';
|
||||||
foundPlayer = false,
|
foundPlayer = false,
|
||||||
len = video.source.length;
|
len = video.source.length;
|
||||||
|
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if( hasSupport( video.source[i].type ) )
|
if( hasSupport( video.source[i].type ) )
|
||||||
{
|
{
|
||||||
// we support this kind of video, so build it.
|
// we support this kind of video, so build it.
|
||||||
buildPlayer(video.source[i], container.parentNode, video.width, video.height, vtype);
|
buildPlayer(video.source[i], container.parentNode, video.width, video.height, vtype);
|
||||||
|
|
||||||
// we've build a player, so we're done here
|
// we've build a player, so we're done here
|
||||||
foundPlayer = true;
|
foundPlayer = true;
|
||||||
break; // break for() loop
|
break; // break for() loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!foundPlayer)
|
if(!foundPlayer)
|
||||||
{
|
{
|
||||||
// of all the streams given, none was supported (eg. no flash and HTML5 video). Display error
|
// of all the streams given, none was supported (eg. no flash and HTML5 video). Display error
|
||||||
buildPlayer({type: 'fallback'}, container.parentNode, video.width, video.height);
|
buildPlayer({type: 'fallback'}, container.parentNode, video.width, video.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue