Last active
December 24, 2015 15:59
-
-
Save prochor666/6824476 to your computer and use it in GitHub Desktop.
Autoloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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