NOTICE: FORUMS MOVING
Thank you for visiting and participating in the Video.js forums. We are currently moving the forums to Stack Overflow and GitHub Issues. If you have a question or need help with Video.js, please post your question on Stack Overflow and add the tag 'video.js'. If you've found a specific bug in Video.js, please submit it in the issues tracker.
Dynamic resizing of videos using video-js
Hi
I would like to dynamically re-size Video for use in a fluid website as in the following example.
http://www.alistapart.com/d/creating-intrinsic-ratios-for-video/exa...
The full explanation is at.
http://www.alistapart.com/articles/creating-intrinsic-ratios-for-vi...
However, I would also like to use videojs because of its functionality across multiple platforms.
Consequentially I would like to be able to dynamically resize Video-JS.
I'm not sure whether I would need to alter the video js css file or create another separate css file?
Any pointers would be appreciated.
Bill Cullen
Support Staff 2 Posted by Steve Heffernan on 19 Nov, 2010 09:06 PM
You can try myPlayer.width("640"); etc. Version 2 will be out soon that supports resizing for the fallback player as well.
3 Posted by billcullencreative on 19 Nov, 2010 09:12 PM
Hi Steve
Thanks very much for your swift response. I will try your suggestion.
Cheers.
4 Posted by niall thompson on 30 May, 2011 05:14 PM
Bill / Steve,
Did you find a solution based on this suggestion? Any tips or pointers much appreciated.
Ideally I wish to include VideoJS in my responsive design. i.e column widths are percentages...
Here's hoping...
5 Posted by billcullencreative on 30 May, 2011 06:17 PM
Hi Nail/Steve
Yes, I did work it out and I think it looks great. It only required a
minor tweak to the code and css file. Everything resizes whilst the
video is playing and it works in all browsers including older IE.
The exercise was for our own site which is not yet live, so I can't
point you to a live site.
I will upload an example and post the URL and tweaks when I get a chance
(hopefully tomorrow).
Cheers.
Bill
6 Posted by Niall Thompson on 31 May, 2011 11:28 AM
Thanks for the quick response Bill. Looking forward to seeing the solution...
Niall
7 Posted by billcullencreative on 02 Jun, 2011 01:50 PM
Hi Niall/Steve
I've put a demo page up on the following link
http://www.radishcreative.co.uk/videoJs/jennie_jones_videojs.html
You should be able to link to the css files from the page. The videoJS
css file has also been amended.
For some reason the big button has disappeared except on fall-back (IE 7,8).
Also, for some reason the video is playing anamorphic 4:3 in Safari.
I'll have to look at that later.
I hope this helps.
Bill
8 Posted by Niall Thompson on 02 Jun, 2011 11:43 PM
Thanks Bill.
It's definitely interesting.
In your JS file you have removed:
` / Resize Tracking -------------------------------------------------------------- /
} );`
This causes the controls to disappear and it also does not load the mp4 properly.
If you keep the code block in the video will resize but only on refresh of the browser...
Something tells me there is a solution in there somewhere.
Just not sure where...
Niall
9 Posted by billcullencreative on 03 Jun, 2011 09:26 AM
Hi Niall
Ah! I didn't realise removing the resize tracking would disable the big
button.
I'm not a JavaScript expert more of a video one, hence the interest in
resizing videos.
I just hope this helps to point the experts in the right direction.
Bill
10 Posted by Barney on 09 Jun, 2011 03:15 AM
I'm very keen to implement this as well. Is there a solution? Can we have videos (including flash fallback) that resize with the browser window? It would be great to be able to use a video as a background for a page, or as a part of a page. If the current code supports this, can someone explain?
11 Posted by Niall Thompson on 09 Jun, 2011 09:11 AM
I am not that well versed in JS but I wonder if the magic of Chris Coyier can help:
http://css-tricks.com/examples/FluidWidthYouTube/iframe.php
12 Posted by Niall Thompson on 06 Jul, 2011 01:38 PM
Anyone have any luck with this yet?
Adding this to the CSS helps but only on refresh:
img,
embed,
object,
video {
max-width: 100%; }
Any thoughts, developments or examples appreciated...
Niall
13 Posted by Martin on 25 Aug, 2011 04:39 PM
Is there any news on this? Am following closely. Would love for a solution that scales the fall back too. When is version 2 out?
14 Posted by Eric Guess on 09 Nov, 2011 06:53 PM
So v2 is out, but I'm not seeing how to make this responsive? Is there a solution for this? I've been trying to use VideoJS along with FitVids.js but to no avail.
15 Posted by Ville on 22 Nov, 2011 05:29 PM
I'd love to know if there is an option for this already or there is something on the way - unmeddled HTML5 video is easily made responsive with css...
16 Posted by Sarah Hills on 24 Nov, 2011 10:19 AM
I've tried to post to this thread twice now (the last time was yesterday) but my post doesn't appear for some bizarre reason??
I think I may have a solution to this problem, but it's not letting me post it! Just trying this short post without any code to see if that appears...
17 Posted by Sarah Hills on 24 Nov, 2011 10:43 AM
Ok, so I guess my other post was either too long or contained something in it which wasn't allowed. I've just posted (what is hopefullly!) a solution on my own website instead: http://www.hexagonwebworks.com/2011/making-videos-responsive/
I hope that helps someone!
18 Posted by roger on 24 Nov, 2011 12:13 PM
Sarah, that's very good of you ... I am looking in to this problem myself at the moment, but don't quite have the CSS "chops" !
My own investigations threw up FitVids as well, though I haven't tried it with VideoJS. And FWIW, I have also been using WPTouchPro, which seems to handle all this kind of stuff automatically, all by itself, at least when I'm using VideoJS with it. But, it's nice to have a handle on the technicals that lie beneath, even if I will have to go and lie down after looking at the CSS.
Anyway, thanks again.
R.
19 Posted by billcullencreative on 24 Nov, 2011 12:58 PM
Hi Sarah
Many thanks for your solution.
I will try it out as soon as I can.
I hope all is well in sunny Oxfordshire.
Cheers.
Bill Cullen
20 Posted by wyclef_thechronic on 15 Dec, 2011 04:50 PM
what's the latest with this?
21 Posted by Sarah Hills on 16 Dec, 2011 11:46 AM
@wyclef_thechronic: I'm not aware that there is any formal stance on this from VideoJS, but as per my post above, it is possible to make a VideoJS video responsive via the addition of a containing HTML div and some CSS.
It would be interesting to hear whether anyone else gets this working successfully...
22 Posted by wyclef_thechronic on 19 Dec, 2011 07:06 PM
yea, your example looks solid. i'm struggling a bit because i'm also trying to vertically center the video in the browser window which is adding a layer of ugh to the mix.... haha.
23 Posted by billcullencreative on 19 Dec, 2011 07:17 PM
Hi @wyclef_thechronic
You could check out http://www.radishcreative.co.uk and navigate to
people/Bill Cullen or people/Jennie Jones for an example of dynamically
resizing video using VideoJS script along with Sarah Hills css.
Bill
24 Posted by DirtyWorld on 18 Aug, 2012 10:11 PM
Hi,
I found this http://daverupert.com/2012/05/making-video-js-fluid-for-rwd/
it work perfect.
Greets