var V=null; // the video element
var C=null; // the canvas element
var VW; //Video width
var VH; //Video height
var context;
function doIt(){
// adjust canvas to match video
VH=V.videoHeight;
VW=V.videoWidth;
C.style.width=""+VW+"px";
C.style.height=""+VH+"px";
if (C.getContext)
{
context = C.getContext('2d');
setInterval("refresh()", 33);
}
else {alert('cannot do canvas');
}
V.muted=true;
}
// turn sound on/off
function toggleSound(){
V.muted=!V.muted;
}
// this is where we copy from video to canvas
function refresh(){
// startclipX, startclipY,clipWidth,clipHeigth,placeX,placeY,W,H
context.drawImage(V,0,0,VW,VH,0,0,C.width,C.height);
}
// freeze an image from the canvas
function Freeze(){
imElt=document.getElementById("imageID");
imElt.src=C.toDataURL();
imElt.width=VW;
imElt.height=VH;
}
// toggle view of an element
function toggleView(eltId){
var elt=document.getElementById(eltId);
if(elt.style.display=="block")
elt.style.display="none";
else
elt.style.display="block";
}