hh5*_*188 14 video height html5 width
我有一个简单的html5视频标签:
<video autobuffer="true" id="video" controls="true">
<source src="some_url"></scource>
</video>
Run Code Online (Sandbox Code Playgroud)
我没有在视频标签或css中定义明显的宽度和高度,视频包装器会根据源视频大小进行调整,问题是,如何获得视频当前宽度和高度?我试过jquery
$('video').css('width');
Run Code Online (Sandbox Code Playgroud)
但它返回原始大小:300px
我在页面中看到的是800px!
我怎么解决这个问题?
Nei*_*eil 28
$(function () {
$("#video").bind("loadedmetadata", function () {
var width = this.videoWidth;
var height = this.videoHeight;
// ...
});
});
Run Code Online (Sandbox Code Playgroud)