1个视频url放入video组件中,页面初始化的时候是黑的
解决办法:
html文章来源:https://www.toymoban.com/news/detail-521379.html
<video :src="item.video" class="images-item" controls :id="handleVideoId(index)" />
<canvas id="mycanvas" style="display: none"></canvas>
js文章来源地址https://www.toymoban.com/news/detail-521379.html
mounted() {
this.findvideocover(url);
},
methods: {
handleVideoId(index) {
return `video${index}`
},
findvideocover(url) {
url.forEach((item, index) => {
const video = document.getElementById(`video${index}`);
video.src = item;
var canvas = document.getElementById("mycanvas");
const ctx = canvas.getContext("2d");
video.crossOrigin = "anonymous";
video.currentTime = 0.5;
video.oncanplay = () => {
canvas.width = video.clientWidth;
canvas.height = video.clientHeight;
ctx.drawImage(video, 0, 0, video.clientWidth, video.clientHeight);
};
});
},
},
到了这里,关于video中视频初始化显示第1帧的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!