网上有相关介绍,使用videoHeight
&videoWidth
但是 我测试总是获取不到
然后在stackoverflow上搜索到类似问题http://stackoverflow.com/questions/4129102/html5-video-dimensions
其中有个大牛说
It should be noted that this solution doesn't actually work in modern browsers since the videoWidth and videoHeight properties aren't set until after the "loadedmetadata" event has fired.
If you happen to query for those properties far enough after the VIDEO element is rendered it may sometimes work, but in most cases this will return values of 0 for both properties.
都开始渲染了再获取到尺寸是不是有点晚?还有什么其他办法吗?
js获取?用h5播放视频吗?
获取video标签的clientWidth和clientHeight不就是视频的大小吗
你把获取videoHeight放在window.onload函数里面就可以了,等视频加载完全之后就能获取到了
@凌晨肆丶的洛杉矶: 加载好就播放了,难道让他延迟几秒播放?那么体验就不好,你会感觉到那么几秒,唉