Wednesday, May 13, 2015

Setting up VideoJS with Intrinsic Ratios

I use VideoJS for  It's been a proven HTML5 player that is used by Google,, and many other well known websites.

I realized for some reason that VideoJS was not being responsive on lately.  What I mean is if you make your browser larger or smaller, the video player should re-sample its size to fit that new browser size and still maintain an aspect ratio that fits into the container in which the video player sits.

I'm almost finished doing a re-code of the views using bootstrap.  Originally which was started in 2008 was designed via rigid table driven layout.  I'm finally getting rid of this after taking over DimeCasts last year.

However even when I have the viewsre-coded and using Bootstrap, I found that VideoJS still wasn't re-sizing on browser size changes.  

A quick search brought me to this post.  

So all I did to get it intrinsic is to then just add that padding to the containing dive around the video component and the video player is now responsive (changes dimensions to fit the container) when you enlarge or decrease your browser window.

I also changed the width and height of VideoJS to 100%, and surrounded everything with a paragraph tag.

For example:

        padding-bottom: 20%;
height: 0px;
                <div class="media-body makeVideoIntrinsic">
                        <video id="<%=ViewData.Model.EpisodeName%>" class="video-js vjs-default-skin"
                            controls preload="auto" width="100%" height="100%"
                            data-setup='{"autoplay": false, "preload": "auto"}'>
                            <source src=<% = ViewData.Model.FileName %> type='video/mp4' />

I'm happy to say that the new Bootstrapped update will be out soon.

No comments:

Post a Comment