<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<script type="text/javascript">
window.addEventListener("load", function(){
var fps = 1000/50;
var videoObj = document.getElementById("myVideo");
var canvasObj = document.getElementById("myCanvas");
setInterval(function(){
canvasObj.getContext("2d").drawImage(videoObj, 0, 0,canvasObj.width, canvasObj.height);
}, fps);
canvasObj.width = window.innerWidth;
canvasObj.height = window.innerWidth*(视频高/视频宽);
canvasObj.addEventListener('click', function(e){
if (myVideo.paused)
myVideo.play();
else
myVideo.pause()
}, false);
}, true);
</script>
</head>
<body style="margin: 0px; padding: 0px;">
<div style="width:100%;display:none;">
<video id="myVideo" width="100%" src="source" controls="controls" loop="loop" preload="preload">
Your browser does not support the video tag.
</video>
</div>
<br/>
<canvas id="myCanvas" ></canvas>
</body>
</html>
已经实现canvas宽度自适应
注意:js中的fps这个数值各位自己找中间点。