added HLS and ISM support to embed.js
This commit is contained in:
parent
5e57ae56c4
commit
2e1296cf5e
1 changed files with 39 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
function mistembed(streamname)
|
function mistembed(streamname)
|
||||||
{
|
{
|
||||||
// return the current flash version
|
// return the current flash version
|
||||||
function flashVersion()
|
function flash_version()
|
||||||
{
|
{
|
||||||
var version = 0;
|
var version = 0;
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ function mistembed(streamname)
|
||||||
// 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
|
||||||
|
@ -20,10 +19,29 @@ function mistembed(streamname)
|
||||||
return parseInt(version, 10);
|
return parseInt(version, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function html5_video_type(type)
|
||||||
|
{
|
||||||
|
var support = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var v = document.createElement('video');
|
||||||
|
|
||||||
|
if( v && v.canPlayType(type) != "" )
|
||||||
|
{
|
||||||
|
support = true;
|
||||||
|
}
|
||||||
|
}catch(e){}
|
||||||
|
|
||||||
|
return support;
|
||||||
|
}
|
||||||
|
|
||||||
// what does the browser support - used in hasSupport()
|
// what does the browser support - used in hasSupport()
|
||||||
supports =
|
supports =
|
||||||
{
|
{
|
||||||
flashversion: flashVersion()
|
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
|
// return true if a type is supported
|
||||||
|
@ -35,12 +53,15 @@ function mistembed(streamname)
|
||||||
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 '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)
|
function buildPlayer(src, container, videowidth, videoheight, vtype)
|
||||||
{
|
{
|
||||||
// used to recalculate the width/height
|
// used to recalculate the width/height
|
||||||
var ratio;
|
var ratio;
|
||||||
|
@ -65,14 +86,24 @@ function mistembed(streamname)
|
||||||
videoheight /= ratio;
|
videoheight /= ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the video type is '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"></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 'ism':
|
||||||
|
container.innerHTML = '<video width="' + videowidth + '" height="' + videoheight + '" src="' + encodeURI(src.url) + '" controls="controls" ><strong>No HTML5 video support</strong></video>';
|
||||||
|
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;
|
||||||
|
@ -105,7 +136,8 @@ function mistembed(streamname)
|
||||||
}else{
|
}else{
|
||||||
// no error, and sources found. Check the video types and output the best
|
// no error, and sources found. Check the video types and output the best
|
||||||
// available video player.
|
// available video player.
|
||||||
var i, video
|
var i, video,
|
||||||
|
vtype = video.type ? video.type : 'unknown';
|
||||||
foundPlayer = false,
|
foundPlayer = false,
|
||||||
len = video.source.length;
|
len = video.source.length;
|
||||||
|
|
||||||
|
@ -114,7 +146,7 @@ function mistembed(streamname)
|
||||||
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);
|
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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue