Skip to content

Instantly share code, notes, and snippets.

@prochor666
Last active December 24, 2015 15:59
Show Gist options
  • Save prochor666/6824476 to your computer and use it in GitHub Desktop.
Save prochor666/6824476 to your computer and use it in GitHub Desktop.
Autoloader
autoLoader : function(){
if($('video').length > 0)
{
$('video').each( function(index)
{
var videoParent = $(this).parent();
var videoSource = $(this).attr('src');
var videoWidth = $(this).attr('width');
var videoHeight = $(this).attr('height');
var videoPoster = $(this).attr('poster');
var idVideoContainer = 'video-element-' + index;
aspectR = videoHeight / videoWidth;
// resample to screen
newWidth = 700;
newHeight = parseInt(aspectR * 700);
if(videoSource)
{
if(videoSource.match("^http")!='http')
{
videoSource = videoSource.match("^/")=='/' ? weeboPublic.siteUrl+videoSource: weeboPublic.siteUrl+'/'+videoSource;
}
if(videoPoster && videoPoster.match("^http")!='http')
{
videoPoster = videoPoster.match("^/")=='/' ? weeboPublic.siteUrl+videoPoster: weeboPublic.siteUrl+'/'+videoPoster;
}
var newContainer = $('<div id="'+idVideoContainer+'"></div>');
newContainer.insertAfter(videoParent);
videoParent.remove();
var opts = {
elementID : idVideoContainer,
file : videoSource,
width : newWidth,
height : newHeight,
autostart : false,
repeat : false
}
if(videoPoster)
{
opts.image = videoPoster;
}
weeboMedia.options = opts;
weeboMedia.init();
weeboMedia.create();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment