var videoElement = $("video")[0];
videoElement.addEventListener("canplay", function (_event) {
var canvas = document.createElement("canvas");
canvas.width = videoElement.videoWidth;
canvas.height = videoElement.videoHeight;
canvas.getContext('2d').drawImage(videoElement, 0, 0, canvas.width, canvas.height);
img.src = canvas.toDataURL("image/png");
$("video").attr('poster',img.src);
URL.revokeObjectURL(this.src); // 释放createObjectURL创建的对象
网友评论