如何在poster
元素中获取<video poster="…">
图像的图像尺寸(宽度和高度)? jQuery是可以接受的。
mimanzhou 回答:如何获得视频海报的图像尺寸?
如果您的<video>
元素被引用为yourVideo
(例如const yourVideo = document.querySelector("video");
),则可以通过poster
属性获得其poster
的URL。这只是一个图片网址,因此获取其尺寸就像使用任何图片网址一样:
const poster = Object.assign(new Image(),{
src: yourVideo.poster
});
poster.addEventListener("load",() => console.log(poster.width,poster.height));