Jon*_*sch 4 video html5 aspect-ratio html5-video
是否可以检测HTML5视频元素的宽高比?
我知道视频会缩小以适应<video>元素的尺寸,但我想检测源视频的宽高比.
这样你可以删除任何黑条.
对不起,我没有在其他地方看到这个答案.
Seb*_*sen 14
粘贴来自另一个StackOverflow答案:https://stackoverflow.com/a/4129189/1353189
<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
Run Code Online (Sandbox Code Playgroud)
来源(HTML5规范):http://www.w3.org/TR/html5/video.html#video
然后,您可以通过将宽度除以高度来计算纵横比.
| 归档时间: |
|
| 查看次数: |
8216 次 |
| 最近记录: |