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

如何在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));
本文链接:https://www.f2er.com/3086993.html

大家都在问