微信H5页面里的video标签使用视频的第一帧作为poster,代码如下:
<video @loadeddata="setPoster" :id="item.videoId" :src="item.video_address"></video>
setPoster(e) {
let ele = e.target;
let canvas = document.createElement('canvas');
canvas.width = ele.videoWidth;
canvas.height = ele.videoHeight;
canvas.getContext('2d').drawImage(ele, 0, 0, canvas.width, canvas.height);
ele.setAttribute('poster', canvas.toDataURL('image/png'));
}
在浏览器里显示的代码如下:
<video id="video31" src="../../video/ad45e737-ca9b-468d-ba17-431e6caff50a.mp4" poster="data:image/png;base64,iVBORwS2/AakF3lxZj8EHgAAAABJRU5ErkJggg=="></video>
为了把问题发出来,我把一段很长的base64编码省略成这样了:iVBORwS2/AakF3lxZj8EHgAAAABJRU5ErkJggg==
请各位大神指教,非常感谢
你好,请问解决了么?