Autosizing jwplayer into a DIV 100%, then going responsive
Hi there
I am trying to setup jwplayer in a div that goes responsive using the 100% values for height and width. I've used setup from sources found elsewhere in these forums and fiddled with all sorts of css so far, no luck.
I'm not interested in the fitvids or frames solution as my site needs the player to be dynamically generated depending on the page (php pulls values for file, image, captions, playlists etc depending on what you're viewing) which is why I've now tried to go back to basics and get the basic player working with 100% values.
Trouble is that trying to set jwplayer up by itself -- any percent values for height break the player. width = "100%" works fine, and height with a specific value obviously, but breaks as soon as you try any percent value.
Any ideas?
temp link with width = "100%", and a hard coded height (otherwise the player doesnt work): http://tinyurl.com/8znpaf6
Yes, I've used example from the developer.longtail page and read through some other things from here: http://www.longtailvideo.com/support/forums/jw-player/using-playlists/22892/auto-rescale-of-playlist-player-to-adjust-to-browser-dimensions#comment-138270
As I say though, at basic starting point, height:"100%" breaks the player at http://tinyurl.com/8znpaf6 .. Did you check the source? And what browser are you using? I can't get it going in Firefox 14.0.1 or Chrome 21.0.1180.83 or Opera 12.01 or IE ..
@Ethan thanks for the example. I can get that running by itself fine, but the player breaks when put into my site at http://tinyurl.com/8znpaf6 which is the prob I'm having. Width=100% works fine, just any percentage for height breaks the player. Must be a prob with css?
I've also noticed that Ethan's example breaks when the <div id="player"> is nested inside another DIV (which is the situation on my theme, ie: player disappears when in more than 1 DIV.. maybe this is the issue to overcome?
Example DIV setup that deals with player in my theme
The 'screen' div sets the responsive size for the player and shows loading gif, then 'video-wrap' should fill the space to 100% of 'screen' and player sits in 'player' div and fills 100% ???
@jwNoob – It is possible to double nest divs when using the player. I created an example that uses CSS3 and double nested divs, and jQuery. If you want to see it please contact us – http://www.longtailvideo.com/support/contact-us, it does not use % based width/height, though.
@Ethan : not much to see, I just used iframe to make it work.. I am using the bootstrap of twitter hub in my layout. I saw that to make the player "appear" correctly, I need to put a "height:100%" into all of the nested parent containers up to the "html" tag, which destroy the layout and make the video to "stretch" in height.
The only way I found, is your iframe example, into which I could put html body and the video container into 100% height, like your example above.. BUT ..
the flag : stretching "exactfit" specified wouldn't work in IE9. Everywhere else it was fine. The behavior in IE9 with the stretching option was making the iframe "page" to not "stretch" the video to the size of it's parent iframe ...
Anyway, now, as I said with the example above + some css tweaks of mine, put into an iframe, without stretching option, makes everything works flawlessly, in IE7-8-9, Chrome and FF 14.
I am having the same issue and it seems like the most important question isn't being answered. How do we get it to work with 100% width and 100% height within nested divs without using an iframe?
In fact the example you provided only works if every element around it has 100% width and height set. Even just adding an empty div with no styles attached causes the height to default to 0. Guessing this is a bug you guys are looking into, any idea when we will see a fix?
That's where the problem comes in, its very rare you will be able to apply 100% width and height to every div that surrounds it, in my case that is definitely not an option.
Im working on a responsive design where I want a video to fill half of the screen width and adjust the height accordingly. The containing div for the video is 50% width of the viewport with the video width & height 100%.
The result is in Chrome the video fills the div width (yay!) and height (boo!) in Firefox displays no video and IE only half of the height of the video. fail!
This solution of course breaks several other CSS things though, such as subtitle display locations, etc. It would seem that a lot of positioning code in JWPlayer is reliant on a height and width being set, instead of breaking that logic out to deal with percentage based values.