慕九州1311592
2016-07-06 19:20
如题,测试了video,embed,object视频好像都没有效果出来!
var context = canvas.getContext('2d'); var video = document.createElement('video'); video.src = '吔屎吧梁非凡_x264压制.mp4'; video.preload = 'preload'; video.autoplay = 'autoplay'; video.height = context.canvas.height; video.width = context.canvas.width; setInterval(function () { var pattern = context.createPattern(video, 'no-repeat'); context.fillStyle = pattern; context.fillRect(0, 0, context.canvas.width, context.canvas.height); pattern = null; //drowStar...这里执行其他绘画步骤 }, 100);
测试可用,setInterval的时间间隔尽量调大,不然电脑风扇会狂飙...
楼上的方法应该更高效吧 XD
var can = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var video = document.getElementById('video');
video.addEventListener('play', function(){
can.width = video.clientWidth;
can.height = video.clientHeight;
var ths = $(this);
(function loop(){
if(!ths.paused && !ths.ended){
ctx.drawImage(ths, 0, 0);
setTimeout(loop, 1000/30);
}
})();
}, false)
Canvas绘图详解
72881 学习 · 422 问题
相似问题
回答 2
回答 2