我试图用打字稿中的视频文件创建缩略图。这是我的代码:
createThumbnail(video_url: string) {
let canvas: HTMLCanvasElement = document.createElement('canvas');
let video: HTMLVideoElement = document.createElement('video');
video.src = video_url;
video.currentTime = 8;
canvas.getContext('2d').drawImage(video, 0, 0, 200, 200);
canvas.toBlob(b => { resolve(b) }, 'image/png');
}
它可以创建图像,但是空白。它只是创建一个空白图像。我在代码中做错了什么?