Last active
August 29, 2015 13:59
-
-
Save kaitwalla/10747012 to your computer and use it in GitHub Desktop.
VideoJS dynamic load
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
function makeVid(vidSrc,width,height,poster,id,div) { | |
if (typeof vidSrc === 'undefined') { | |
console.log('You need to include a video source in order to call a video'); | |
return false; | |
} | |
div = typeof div !== 'undefined' ? div : 'body'; | |
width = typeof width !== 'undefined' ? width : 640; | |
height = typeof height !== 'undefined' ? height : 480; | |
poster = typeof poster !== 'undefined' ? poster : 'none'; | |
id = typeof id !== 'undefined' ? id : 'player' ; | |
var attributes = { | |
'id': id, | |
'class': 'video-js vjs-default-skin', | |
'width': width, | |
'height': height, | |
'controls': '', | |
'poster':poster, | |
'preload':'auto' | |
}; | |
source = document.createElement('source'); | |
$(source).attr('type','video/mp4'); | |
$(source).attr('src',vidSrc); | |
obj = $('<video />').attr(attributes); | |
$(div).append(obj); | |
$(obj).append(source); | |
_V_(document.getElementById('player'+id)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment