HTML and CSS Reference
In-Depth Information
Here's the complete markup and script for this example:
<video id="origVideo" width="640" height="360">
<source src="video.mp4" type="video/mp4" />
<source src="video.ogv" type="video/ogg" />
Your device does not support HTML5 video.
<button title="Generate Preview" onclick="generatePreview();">Generate
<canvas id="previewMed"></canvas>
<canvas id="previewSm"></canvas>
function generatePreview(){
var video = document.getElementById('origVideo');
var canvas1 = document.getElementById('previewMed');
var context1 = canvas1.getContext('2d');
var canvas2 = document.getElementById('previewsSm');
var context2 = canvas2.getContext('2d');
canvas1.width = 320;
canvas1.height = 180;
canvas2.width = 160;
canvas2.height = 90;
video.addEventListener('play', function(){
function drawVideo(video,canvas1,canvas2) {
if(video.paused || video.ended) return false;
With native video offered through HTML5, web developers now have the ability to
dive deep into a video file and make enhancements to the user experience that were
once the domain of proprietary technologies.
See Also
HTML5 Doctor offers demos and detailed descriptions of other ways to use canvas and
video together at .
Search WWH ::

Custom Search