embed.js error fix

This commit is contained in:
Niels Groot Obbink 2012-08-29 16:19:34 +02:00
parent 4257ac6634
commit 8d5d15669f

View file

@ -1,8 +1,9 @@
function mistembed(video) function mistembed(streamname)
{
// add stuff to mistvideo object, if it doesn't exist yet
if(!mistvideo.hasSupport || !mistvideo.buildPlayer)
{ {
// add stuff to mistvideo object, if it doesn't exist yet
if(!mistvideo.hasSupport || !mistvideo.buildPlayer)
{
// return the current flash version // return the current flash version
mistvideo.flashVersion = function() mistvideo.flashVersion = function()
{ {
@ -61,30 +62,31 @@ if(!mistvideo.hasSupport || !mistvideo.buildPlayer)
break; break;
} }
}; };
} }
var container = document.createElement('div'), var video = mistvideo[streamname],
container = document.createElement('div'),
scripts = document.getElementsByTagName('script'), scripts = document.getElementsByTagName('script'),
me = scripts[scripts.length - 1]; me = scripts[scripts.length - 1];
// create the container // create the container
me.parentNode.insertBefore(container, me); me.parentNode.insertBefore(container, me);
// set the class to 'mistvideo' // set the class to 'mistvideo'
container.setAttribute('class', 'mistvideo'); container.setAttribute('class', 'mistvideo');
// remove script tag // remove script tag
me.parentNode.removeChild(me); me.parentNode.removeChild(me);
if(video.error) if(video.error)
{ {
// there was an error; display it // there was an error; display it
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join(''); container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join('');
}else if(video.source.length < 1) }else if(video.source.length < 1)
{ {
// no stream sources // no stream sources
container.innerHTML = '<strong>Error: no streams found</strong>'; container.innerHTML = '<strong>Error: no streams found</strong>';
}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
@ -109,7 +111,6 @@ if(video.error)
// of all the streams given, none was supported (eg. no flash and HTML5 video). Fall back. // of all the streams given, none was supported (eg. no flash and HTML5 video). Fall back.
container.innerHTML = 'fallback here'; container.innerHTML = 'fallback here';
} }
} }
} }