Created
June 29, 2016 18:23
-
-
Save iamandycohen/152299a0444d0e7dd98364e56908ac41 to your computer and use it in GitHub Desktop.
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
<div id="kalturaVideoContainer" class="video"> | |
<script src="http://cdnapi.kaltura.com/p/1727781/sp/172778100/embedIframeJs/uiconf_id/28706061/partner_id/1727781"></script> | |
<div id="kaltura_player_1427290942" style="width: 100%; height: 100%;" itemprop="video" itemscope itemtype="http://schema.org/VideoObject"></div> | |
<script> | |
kWidget.embed({ | |
"targetId": "kaltura_player_1427290942", | |
"wid": "_1727781", | |
"uiconf_id": 28706061, | |
"flashvars": { | |
"streamerType": "auto", | |
"IframeCustomPluginCss1" : '/styles/KalturaVideo1.css' | |
}, | |
"cache_st": 1427290942, | |
"entry_id": '1_tphfiiq7' | |
}); | |
//the following will use javascript to calculate the height for a responsive Kaltura video | |
function SizeVideo() { | |
/*the folowing vars determin the size of the video*/ | |
var videoRat = 9/16; /*video aspect ratio*/ | |
var maxX = 684; /*maximum width of video*/ | |
var listY = 0; /*height of the chapter carousel*/ | |
/*these vars calculate the precise height based on the above vars*/ | |
var maxY = (maxX*videoRat)+listY; | |
var fullSizeYVideo = maxX*videoRat | |
/*this container holds the kaltura video player, and will control the bleeding background from the player*/ | |
var elemi = document.getElementById('kalturaVideoContainer'); | |
/*initialize vars to get current calculated width*/ | |
var newXStr = "1"; | |
var newX = 1; | |
var newY = 1; | |
/*current calulated width*/ | |
newXStr = window.getComputedStyle(elemi,null).width; | |
/*this is not an integer, and needs to be converted or you will get NaN error*/ | |
newX = parseInt(newXStr); | |
/*check the bounds of the calculated values are within are maximum values*/ | |
if (newX > maxX){newX = maxX;} | |
newY = (newX * videoRat) + listY; | |
if (newY > maxY){newY = maxY} | |
/*set the containers style*/ | |
elemi.setAttribute('style', 'height:' + newY + 'px !important; max-height: ' + maxY + 'px !important; max-width:' + maxX +'px !important;'); | |
} | |
window.onresize = function(event) { | |
SizeVideo(); | |
} | |
SizeVideo(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment