I have videos playing on a new window using the video tag in HTML5. I want the size of this new window to change depending on the height and width of the video that is being played. Is there some way to do this? I am using GWT by the way.
A:
The JavaScript you want to end up calling is window.resizeTo(h, w)
You can do this in GWT using JSNI, like so:
native void resizeWindow(int height, int width) /*-{
$wnd.resizeTo(height, width);
}-*/;
Jason Hall
2010-03-10 17:30:05
But how will I get the height and width of the video that is being played? I won't know that till after the video has started playing...or will I?
Pranabesh Sinha
2010-03-10 17:32:13
The <video> element can have height and width attributes, which you can get in JavaScript using a similar JSNI approach as above. And if those aren't available, you can set them to whatever your window's h/w are.
Jason Hall
2010-03-10 20:24:26
Setting the height and width to a default value will cause the video to stretch if it's default height and width are smaller. I want to obtain that default dimension of the video and then resize the window in which the video opens accordingly.
Pranabesh Sinha
2010-03-10 21:20:48
If the <video> tag doesn't have a height and width defined, you can also get it in JavaScript. var height = document.getElementById('myVideo').style.pixelHeight; (and so on)
Jason Hall
2010-03-10 22:16:54
document.getElementById('myVideo').style.pixelHeight is returning null. Replaced pixelHeight by clientHeight, also got null.
Pranabesh Sinha
2010-03-12 20:21:38
The HTML5 spec says it should have height and videoHeight. http://www.w3.org/TR/html5/video.html
Jason Hall
2010-03-12 21:05:35