如何获取视频海报的图像尺寸



如何在<video poster="…">元素中获得poster图像的图像尺寸(宽度和高度(?jQuery是可以接受的。

如果您的<video>元素被引用为yourVideo(例如const yourVideo = document.querySelector("video");(,那么您可以通过poster属性获取其posterURL。这只是一个图像URL,所以像任何图像URL一样获取其尺寸:

const poster = Object.assign(new Image(), {
src: yourVideo.poster
});
poster.addEventListener("load", () => console.log(poster.width, poster.height));

最新更新