本文介绍了HTML5视频尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将我正在覆盖的视频的尺寸放到带有JavaScript的页面上,但它会返回海报图像的尺寸而不是实际的视频,因为它似乎是在视频之前计算的已加载。
I'm trying to get the dimensions of a video of which I'm overlaying onto a page with JavaScript, however it is returning the dimensions of the poster image instead of the actual video as it seems it's being calculated before the video is loaded.
推荐答案
<video id="foo" src="foo.mp4"></video>
var vid = document.getElementById("foo");
vid.videoHeight; // returns the intrinsic height of the video
vid.videoWidth; // returns the intrinsic width of the video
规格:
这篇关于HTML5视频尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!