programming-examples/html/Rendering_Techniques/12-video-frames.html

42 lines
1.2 KiB
HTML
Raw Normal View History

2019-11-15 12:59:38 +01:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Video Frames</title>
<link rel="stylesheet" href="../include/style.css">
<style>
#movieclip {
display: none;
}
</style>
</head>
<body>
<header>
Example from <a href="http://amzn.com/1430236655?tag=html5anim-20"><em>Foundation HTML5 Animation with JavaScript</em></a>
</header>
<canvas id="canvas" width="600" height="360"></canvas>
<aside>Video file may take a moment to load.</aside>
<video id="movieclip" width="640" height="360" autoplay>
<source src="./assets/movieclip.mp4" type="video/mp4"/>
<source src="./assets/movieclip.webm" type="video/webm"/>
<source src="./assets/movieclip.ogv" type="video/ogg"/>
</video>
<script src="../include/utils.js"></script>
<script>
window.onload = function () {
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d'),
video = document.getElementById('movieclip');
(function drawFrame () {
window.requestAnimationFrame(drawFrame, canvas);
context.drawImage(video, 0, 0);
}());
};
</script>
</body>
</html>