Getting Intrinsic HTML5 Video Dimensions
Posted by: K. Scott Allen,
on 29 Nov 2011 |
View original | Bookmarked: 0 time(s)
The HTML 5 DOM interface for a video element allows you to get the underlying video's width and height in pixels, but, be careful not to ask for the dimensions too early. If you ask as soon as the DOM is ready, like in the following code, you'll probably see width and height as 0. $(function () {
var video = $("#video").get(0);
var width = video.videoWidth;
var height = video.videoHeight;
// ...
});
You'll want to wait for the video element to raise the loadedmetadata event before...