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 =
|
||||
[
|
||||
['kb_total', 'Total bandwidth'],
|
||||
['kbps_max', 'Current bandwidth'],
|
||||
['users', 'Concurrent users'],
|
||||
['geo', 'Geolimited'],
|
||||
|
@ -36,6 +35,7 @@
|
|||
];
|
||||
|
||||
/* Not currently supported but may return at a later time:
|
||||
['kb_total', 'Total bandwidth'],
|
||||
['duration', 'Duration'],
|
||||
['str_kbps_min', 'Minimum 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>");
|
||||
$tbody = $('<tbody>');
|
||||
|
||||
var i, tr, limit, stream, clims,
|
||||
var i, tr, limit, stream, currentlims,
|
||||
alllimits = settings.settings.config.limits;
|
||||
|
||||
for(stream in settings.settings.streams)
|
||||
{
|
||||
clims = settings.settings.streams[stream].limits;
|
||||
currentlims = settings.settings.streams[stream].limits;
|
||||
|
||||
$.each(clims, function(k, v)
|
||||
{
|
||||
this.appliesto = stream;
|
||||
this.appliesi = k;
|
||||
});
|
||||
for (index in currentlims) {
|
||||
currentlims[index].appliesto = stream;
|
||||
currentlims[index].appliesi = index;
|
||||
}
|
||||
|
||||
alllimits = alllimits.concat(clims);
|
||||
alllimits = alllimits.concat(currentlims);
|
||||
}
|
||||
|
||||
len = alllimits.length;
|
||||
|
@ -1090,14 +1089,42 @@
|
|||
limit = alllimits[i];
|
||||
$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);
|
||||
$('#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
|
||||
$('#page').append(
|
||||
$('<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(
|
||||
$('<button>').text('Save all').click(function(){
|
||||
|
@ -1139,8 +1166,10 @@
|
|||
}
|
||||
if($(this).find('.new-limit-appliesto').val() == 'server') {
|
||||
settings.settings.config.limits.push(obj);
|
||||
console.log('new server limit',obj);
|
||||
}else{
|
||||
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(){
|
||||
|
|
|
@ -1,164 +1,167 @@
|
|||
function mistembed(streamname)
|
||||
{
|
||||
// return the current flash version
|
||||
function flash_version()
|
||||
{
|
||||
var version = 0;
|
||||
// return the current flash version
|
||||
function flash_version()
|
||||
{
|
||||
var version = 0;
|
||||
|
||||
try
|
||||
{
|
||||
// check in the mimeTypes
|
||||
version = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description.replace(/([^0-9\.])/g, '').split('.')[0];
|
||||
}catch(e){}
|
||||
try
|
||||
{
|
||||
// for our special friend IE
|
||||
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable("$version").replace(/([^0-9\,])/g, '').split(',')[0];
|
||||
}catch(e){}
|
||||
try
|
||||
{
|
||||
// check in the mimeTypes
|
||||
version = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description.replace(/([^0-9\.])/g, '').split('.')[0];
|
||||
}catch(e){}
|
||||
try
|
||||
{
|
||||
// for our special friend IE
|
||||
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable("$version").replace(/([^0-9\,])/g, '').split(',')[0];
|
||||
}catch(e){}
|
||||
|
||||
return parseInt(version, 10);
|
||||
};
|
||||
return parseInt(version, 10);
|
||||
};
|
||||
|
||||
function html5_video_type(type)
|
||||
{
|
||||
var support = false;
|
||||
function html5_video_type(type)
|
||||
{
|
||||
var support = false;
|
||||
|
||||
try
|
||||
{
|
||||
var v = document.createElement('video');
|
||||
try
|
||||
{
|
||||
var v = document.createElement('video');
|
||||
|
||||
if( v && v.canPlayType(type) != "" )
|
||||
{
|
||||
support = true;
|
||||
}
|
||||
}catch(e){}
|
||||
if( v && v.canPlayType(type) != "" )
|
||||
{
|
||||
support = true;
|
||||
}
|
||||
}catch(e){}
|
||||
|
||||
return support;
|
||||
}
|
||||
return support;
|
||||
}
|
||||
|
||||
// what does the browser support - used in hasSupport()
|
||||
supports =
|
||||
{
|
||||
flashversion: flash_version(),
|
||||
hls: html5_video_type('application/vnd.apple.mpegURL'),
|
||||
ism: html5_video_type('application/vnd.ms-ss')
|
||||
};
|
||||
// what does the browser support - used in hasSupport()
|
||||
supports =
|
||||
{
|
||||
flashversion: flash_version(),
|
||||
hls: html5_video_type('application/vnd.apple.mpegURL'),
|
||||
ism: html5_video_type('application/vnd.ms-ss')
|
||||
};
|
||||
|
||||
// return true if a type is supported
|
||||
function hasSupport(type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 'f4v': return supports.flashversion >= 11; break;
|
||||
case 'rtmp': return supports.flashversion >= 10; break;
|
||||
case 'flv': return supports.flashversion >= 7; break;
|
||||
// return true if a type is supported
|
||||
function hasSupport(type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 'f4v': return supports.flashversion >= 11; break;
|
||||
case 'rtmp': return supports.flashversion >= 10; break;
|
||||
case 'flv': return supports.flashversion >= 7; break;
|
||||
|
||||
case 'hls': return supports.hls; break;
|
||||
case 'ism': return supports.ism; break;
|
||||
case 'hls': return supports.hls; break;
|
||||
case 'ism': return supports.ism; break;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
};
|
||||
default: return false;
|
||||
}
|
||||
};
|
||||
|
||||
// build HTML for certain kinds of types
|
||||
function buildPlayer(src, container, videowidth, videoheight, vtype)
|
||||
{
|
||||
// used to recalculate the width/height
|
||||
var ratio;
|
||||
// build HTML for certain kinds of types
|
||||
function buildPlayer(src, container, videowidth, videoheight, vtype)
|
||||
{
|
||||
// used to recalculate the width/height
|
||||
var ratio;
|
||||
|
||||
// get the container's width/height
|
||||
var containerwidth = parseInt(container.scrollWidth, 10);
|
||||
var containerheight = parseInt(container.scrollHeight, 10);
|
||||
// get the container's width/height
|
||||
var containerwidth = parseInt(container.scrollWidth, 10);
|
||||
var containerheight = parseInt(container.scrollHeight, 10);
|
||||
|
||||
if(videowidth > containerwidth && containerwidth > 0)
|
||||
{
|
||||
ratio = videowidth / containerwidth;
|
||||
if(videowidth > containerwidth && containerwidth > 0)
|
||||
{
|
||||
ratio = videowidth / containerwidth;
|
||||
|
||||
videowidth /= ratio;
|
||||
videoheight /= ratio;
|
||||
}
|
||||
videowidth /= ratio;
|
||||
videoheight /= ratio;
|
||||
}
|
||||
|
||||
if(videoheight > containerheight && containerheight > 0)
|
||||
{
|
||||
ratio = videoheight / containerheight;
|
||||
if(videoheight > containerheight && containerheight > 0)
|
||||
{
|
||||
ratio = videoheight / containerheight;
|
||||
|
||||
videowidth /= ratio;
|
||||
videoheight /= ratio;
|
||||
}
|
||||
videowidth /= ratio;
|
||||
videoheight /= ratio;
|
||||
}
|
||||
|
||||
// if the video type is 'live',
|
||||
lappend = vtype == 'live' ? "&streamType=live" : "";
|
||||
// if the video type is 'live',
|
||||
lappend = vtype == 'live' ? "&streamType=live" : "";
|
||||
|
||||
switch(src.type)
|
||||
{
|
||||
case 'f4v':
|
||||
case 'rtmp':
|
||||
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>';
|
||||
break;
|
||||
switch(src.type)
|
||||
{
|
||||
case 'f4v':
|
||||
case 'rtmp':
|
||||
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>';
|
||||
break;
|
||||
|
||||
|
||||
case 'hls':
|
||||
case 'ism':
|
||||
container.innerHTML = '<video width="' + videowidth + '" height="' + videoheight + '" src="' + encodeURI(src.url) + '" controls="controls" ><strong>No HTML5 video support</strong></video>';
|
||||
break;
|
||||
case 'hls':
|
||||
case 'ism':
|
||||
container.innerHTML = '<video width="' + videowidth + '" height="' + videoheight + '" src="' + encodeURI(src.url) + '" controls="controls" ><strong>No HTML5 video support</strong></video>';
|
||||
break;
|
||||
|
||||
|
||||
case 'fallback':
|
||||
container.innerHTML = '<strong>No support for any player found</strong>';
|
||||
break;
|
||||
}
|
||||
case 'fallback':
|
||||
container.innerHTML = '<strong>No support for any player found</strong>';
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
var video = mistvideo[streamname],
|
||||
container = document.createElement('div'),
|
||||
scripts = document.getElementsByTagName('script'),
|
||||
me = scripts[scripts.length - 1];
|
||||
var video = mistvideo[streamname],
|
||||
container = document.createElement('div'),
|
||||
scripts = document.getElementsByTagName('script'),
|
||||
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
|
||||
me.parentNode.insertBefore(container, me);
|
||||
// set the class to 'mistvideo'
|
||||
container.setAttribute('class', 'mistvideo');
|
||||
// remove script tag
|
||||
me.parentNode.removeChild(me);
|
||||
|
||||
if(video.error)
|
||||
{
|
||||
// there was an error; display it
|
||||
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join('');
|
||||
}else if(video.source.length < 1)
|
||||
{
|
||||
// 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,
|
||||
if(video.error)
|
||||
{
|
||||
// there was an error; display it
|
||||
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join('');
|
||||
}else if(video.source.length < 1)
|
||||
{
|
||||
// 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';
|
||||
foundPlayer = false,
|
||||
len = video.source.length;
|
||||
foundPlayer = false,
|
||||
len = video.source.length;
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
if( hasSupport( video.source[i].type ) )
|
||||
{
|
||||
// we support this kind of video, so build it.
|
||||
buildPlayer(video.source[i], container.parentNode, video.width, video.height, vtype);
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
if( hasSupport( video.source[i].type ) )
|
||||
{
|
||||
// we support this kind of video, so build it.
|
||||
buildPlayer(video.source[i], container.parentNode, video.width, video.height, vtype);
|
||||
|
||||
// we've build a player, so we're done here
|
||||
foundPlayer = true;
|
||||
break; // break for() loop
|
||||
}
|
||||
}
|
||||
// we've build a player, so we're done here
|
||||
foundPlayer = true;
|
||||
break; // break for() loop
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundPlayer)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
if(!foundPlayer)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue