getVideoImg (url) {
let _this = this
// 创建视频对象
let video = document.createElement('video')
video.src = url
video.width = 503
video.height = 295
video.setAttribute('crossOrigin', 'Anonymous')
video.autoplay = true
// video.play() // 开始播放
video.addEventListener('loadeddata', () => {
setTimeout(() => {
let canvas = document.createElement('canvas')
canvas.width = 503
canvas.height = 503
let ctx = canvas.getContext('2d')
let imgHeight = video.videoHeight
let imgWidth = video.videoWidth
// canvas.width = imgWidth
// canvas.height = imgHeight
ctx.drawImage(video, 0, 0, imgWidth, imgHeight, 0, 0, video.width, video.width)
let img = canvas.toDataURL('image/png')
// img 为图片信息
_this.$set(_this.imgList, url, img)
}, 10)
}, false)
},
版权归属:
UUICE
许可协议:
本文使用《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》协议授权
评论区