UNPKG

webcamjs-extended

Version:

HTML5 Webcam Image Capture Library with Flash Fallback

1 lines 21.7 kB
(function(e){var t;function i(){var e=Error.apply(this,arguments);e.name=this.name="FlashError";this.stack=e.stack;this.message=e.message}function a(){var e=Error.apply(this,arguments);e.name=this.name="WebcamError";this.stack=e.stack;this.message=e.message}IntermediateInheritor=function(){};IntermediateInheritor.prototype=Error.prototype;i.prototype=new IntermediateInheritor;a.prototype=new IntermediateInheritor;var s={version:"1.0.26",protocol:location.protocol.match(/https/i)?"https":"http",loaded:false,live:false,userMedia:true,iOS:/iPad|iPhone|iPod/.test(navigator.userAgent)&&!e.MSStream,params:{width:0,height:0,visible_width:0,visible_height:0,display_aspect_ratio:0,dest_width:0,dest_height:0,image_format:"jpeg",jpeg_quality:90,enable_flash:true,force_flash:false,flip_horiz:false,fps:30,upload_name:"webcam",constraints:null,swfURL:"",flashNotDetectedText:"ERROR: No Adobe Flash Player detected. Webcam.js relies on Flash for browsers that do not support getUserMedia (like yours).",noInterfaceFoundText:"No supported webcam interface found.",unfreeze_snap:true,iosPlaceholderText:"Click here to open camera.",user_callback:null,user_canvas:null},errors:{FlashError:i,WebcamError:a},hooks:{},init:function(){var t=this;this.mediaDevices=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?navigator.mediaDevices:navigator.mozGetUserMedia||navigator.webkitGetUserMedia?{getUserMedia:function(e){return new Promise(function(t,i){(navigator.mozGetUserMedia||navigator.webkitGetUserMedia).call(navigator,e,t,i)})}}:null;this.videoDevices=[];e.URL=e.URL||e.webkitURL||e.mozURL||e.msURL;this.userMedia=this.userMedia&&!!this.mediaDevices&&!!e.URL;if(this.iOS){this.userMedia=null}if(navigator.userAgent.match(/Firefox\D+(\d+)/)){if(parseInt(RegExp.$1,10)<21)this.userMedia=null}if(this.userMedia){e.addEventListener("beforeunload",function(e){t.reset()})}this.currentDevice=null;if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices){navigator.mediaDevices.enumerateDevices().then(function(e){e.forEach(function(e){if(e.kind==="videoinput"){t.videoDevices.push(e)}});if(t.videoDevices.length>0){t.currentDevice=t.videoDevices[0]}})}},exifOrientation:function(e){var t=new DataView(e);if(t.getUint8(0)!=255||t.getUint8(1)!=216){console.log("Not a valid JPEG file");return 0}var i=2;var a=null;while(i<e.byteLength){if(t.getUint8(i)!=255){console.log("Not a valid marker at offset "+i+", found: "+t.getUint8(i));return 0}a=t.getUint8(i+1);if(a==225){i+=4;var s="";for(n=0;n<4;n++){s+=String.fromCharCode(t.getUint8(i+n))}if(s!="Exif"){console.log("Not valid EXIF data found");return 0}i+=6;var r=null;if(t.getUint16(i)==18761){r=false}else if(t.getUint16(i)==19789){r=true}else{console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)");return 0}if(t.getUint16(i+2,!r)!=42){console.log("Not valid TIFF data! (no 0x002A)");return 0}var o=t.getUint32(i+4,!r);if(o<8){console.log("Not valid TIFF data! (First offset less than 8)",t.getUint32(i+4,!r));return 0}var h=i+o;var l=t.getUint16(h,!r);for(var d=0;d<l;d++){var c=h+d*12+2;if(t.getUint16(c,!r)==274){var p=t.getUint16(c+2,!r);var m=t.getUint32(c+4,!r);if(p!=3&&m!=1){console.log("Invalid EXIF orientation value type ("+p+") or count ("+m+")");return 0}var f=t.getUint16(c+8,!r);if(f<1||f>8){console.log("Invalid EXIF orientation value ("+f+")");return 0}return f}}}else{i+=2+t.getUint16(i+2)}}return 0},fixOrientation:function(e,t,i){var a=new Image;var s=this;a.addEventListener("load",function(e){var s=document.createElement("canvas");var r=s.getContext("2d");if(t<5){s.width=a.width;s.height=a.height}else{s.width=a.height;s.height=a.width}switch(t){case 2:r.transform(-1,0,0,1,a.width,0);break;case 3:r.transform(-1,0,0,-1,a.width,a.height);break;case 4:r.transform(1,0,0,-1,0,a.height);break;case 5:r.transform(0,1,1,0,0,0);break;case 6:r.transform(0,1,-1,0,a.height,0);break;case 7:r.transform(0,-1,-1,0,a.height,a.width);break;case 8:r.transform(0,-1,1,0,0,a.width);break}r.drawImage(a,0,0);i.src=s.toDataURL()},false);a.src=e},attach:function(i){if(typeof i=="string"){i=document.getElementById(i)||document.querySelector(i)}if(!i){return this.dispatch("error",new a("Could not locate DOM element to attach to."))}this.container=i;i.innerHTML="";var r=document.createElement("div");i.appendChild(r);this.peg=r;if(!(this.params.width||this.params.height)){return this.dispatch("error",new a("No width and/or height for webcam. Please call set() first, or attach to a visible element."))}if(!this.params.dest_width&&this.params.width)this.params.dest_width=this.params.width;if(!this.params.dest_height&&this.params.height)this.params.dest_height=this.params.height;this.userMedia=t===undefined?this.userMedia:t;if(this.params.force_flash){t=this.userMedia;this.userMedia=null}if(typeof this.params.fps!=="number")this.params.fps=30;var o=this.params.width?this.params.width/this.params.dest_width:1;var n=this.params.height?this.params.height/this.params.dest_height:1;o=this.params.width?o:n;n=this.params.height?n:o;if(this.userMedia){var h=document.createElement("video");h.setAttribute("autoplay","autoplay");if(o!=1||n!=1){i.style.overflow="hidden";h.style.webkitTransformOrigin="0px 0px";h.style.mozTransformOrigin="0px 0px";h.style.msTransformOrigin="0px 0px";h.style.oTransformOrigin="0px 0px";h.style.transformOrigin="0px 0px";h.style.webkitTransform="scaleX("+o+") scaleY("+n+")";h.style.mozTransform="scaleX("+o+") scaleY("+n+")";h.style.msTransform="scaleX("+o+") scaleY("+n+")";h.style.oTransform="scaleX("+o+") scaleY("+n+")";h.style.transform="scaleX("+o+") scaleY("+n+")"}i.appendChild(h);this.video=h;var l=this;var d={};if(this.params.dest_width){d.minWidth=this.params.dest_width}if(this.params.dest_height){d.minHeight=this.params.dest_height}if(!d.minWidth&&this.params.display_aspect_ratio){d.minWidth=d.minHeight*this.params.display_aspect_ratio}if(!d.minHeight&&this.params.display_aspect_ratio){d.minHeight=d.minWidth/this.params.display_aspect_ratio}this.getPossibleMediaDevice(d).then(function(t){h.onloadedmetadata=function(e){l.stream=t;l.loaded=true;l.live=true;h.style.width=""+h.videoWidth+"px";h.style.height=""+h.videoHeight+"px";i.style.width=""+h.videoWidth*o+"px";i.style.height=""+h.videoHeight*n+"px";l.dispatch("load");l.dispatch("live");l.flip()};if(t instanceof MediaStream){h.srcObject=t}else{h.src=e.URL.createObjectURL(t)||t}}).catch(function(e){if(l.params.enable_flash&&l.detectFlash()){setTimeout(function(){l.params.force_flash=1;l.attach(i)},1)}else{l.dispatch("error",e)}})}else if(this.iOS){var c=document.createElement("div");c.id=this.container.id+"-ios_div";c.className="webcamjs-ios-placeholder";if(this.params.width){c.style.width=""+this.params.width+"px"}if(this.params.height){c.style.height=""+this.params.height+"px"}if(!this.params.width&&this.params.display_aspect_ratio){c.style.width=""+this.params.height*this.params.display_aspect_ratio+"px"}if(!this.params.height&&this.params.display_aspect_ratio){c.style.height=""+this.params.width/this.params.display_aspect_ratio+"px"}c.style.textAlign="center";c.style.display="table-cell";c.style.verticalAlign="middle";c.style.backgroundRepeat="no-repeat";c.style.backgroundSize="contain";c.style.backgroundPosition="center";var p=document.createElement("span");p.className="webcamjs-ios-text";p.innerHTML=this.params.iosPlaceholderText;c.appendChild(p);var m=document.createElement("img");m.id=this.container.id+"-ios_img";if(this.params.dest_width){m.style.width=""+this.params.dest_width+"px"}if(this.params.dest_height){m.style.height=""+this.params.dest_height+"px"}if(!this.params.dest_width){m.style.width=""+this.params.dest_height*this.params.display_aspect_ratio+"px"}if(!this.params.dest_height){m.style.height=""+this.params.dest_width/this.params.display_aspect_ratio+"px"}m.style.display="none";c.appendChild(m);var f=document.createElement("input");f.id=this.container.id+"-ios_input";f.setAttribute("type","file");f.setAttribute("accept","image/*");f.setAttribute("capture","camera");var l=this;var v=this.params;f.addEventListener("change",function(e){if(e.target.files.length>0&&e.target.files[0].type.indexOf("image/")==0){var t=URL.createObjectURL(e.target.files[0]);var i=new Image;i.addEventListener("load",function(e){var t=document.createElement("canvas");var a=1;if(v.dest_width){var s=i.width/v.dest_width;a=s}if(v.dest_height){var r=i.height/v.dest_height;a=r}if(v.dest_width&&v.dest_height){a=Math.min(s,r);t.width=v.dest_width;t.height=v.dest_height}else{t.width=i.width/a;t.height=i.height/a}var o=t.getContext("2d");var n=i.width;var h=i.height;var l=(i.width-n)/2;var d=(i.height-h)/2;o.drawImage(i,l,d,n,h,0,0,t.width,t.height);var p=t.toDataURL();m.src=p;c.style.backgroundImage="url('"+p+"')"},false);var a=new FileReader;a.addEventListener("load",function(e){var a=l.exifOrientation(e.target.result);l.fixOrientation(t,a,i)},false);var s=new XMLHttpRequest;s.open("GET",t,true);s.responseType="blob";s.onload=function(e){if(this.status==200||this.status===0){a.readAsArrayBuffer(this.response)}};s.send()}},false);f.style.display="none";i.appendChild(f);c.addEventListener("click",function(e){if(v.user_callback){l.snap(v.user_callback,v.user_canvas)}else{f.style.display="block";f.focus();f.click();f.style.display="none"}},false);i.appendChild(c);this.loaded=true;this.live=true}else if(this.params.enable_flash&&this.detectFlash()){e.Webcam=s;var c=document.createElement("div");c.innerHTML=this.getSWFHTML();i.appendChild(c)}else{this.dispatch("error",new a(this.params.noInterfaceFoundText))}if(this.params.crop_width&&this.params.crop_height){var u=Math.floor(this.params.crop_width*o);var g=Math.floor(this.params.crop_height*n);i.style.width=""+u+"px";i.style.height=""+g+"px";i.style.overflow="hidden";i.scrollLeft=Math.floor(this.params.width/2-u/2);i.scrollTop=Math.floor(this.params.height/2-g/2)}else{}},getVideoDevices:function(){return this.videoDevices},getPossibleMediaDevice:function(e){var t=this;var i=Object.assign({},this.params.constraints||{mandatory:e});if(this.currentDevice){i.deviceId={exact:this.currentDevice.deviceId}}return this.mediaDevices.getUserMedia({audio:false,video:i}).catch(function(i){if(t.currentDevice){var a=0;t.videoDevices=t.videoDevices.filter(function(e,i){if(e===t.currentDevice){a=i}return e!==t.currentDevice});t.removedDevice(t.currentDevice);if(t.videoDevices){a=a%t.videoDevices.length;t.currentDevice=t.videoDevices[a]}else{console.log("webcamjs: delete currentDevice. last try: run without deviceId",t.currentDevice.deviceId);t.currentDevice=null}return t.getPossibleMediaDevice(e)}else{throw i}})},removedDevice:function(e){console.log("webcamjs removed device ",e);if(this.params.devices_updated_callback){this.params.devices_updated_callback({type:"remove",target:e})}},switchCamera:function(){var e=this;var t=e.videoDevices.findIndex(function(t){return e.currentDevice===t});if(t===-1){throw new Error("can't find current device with id:"+this.currentDevice.deviceId)}t=(t+1)%e.videoDevices.length;this.currentDevice=e.videoDevices[t];var i=this.container;this.reset();this.attach(i)},reset:function(){if(this.preview_active)this.unfreeze();this.unflip();if(this.userMedia){if(this.stream){if(this.stream.getVideoTracks){var e=this.stream.getVideoTracks();if(e&&e[0]&&e[0].stop)e[0].stop()}else if(this.stream.stop){this.stream.stop()}}delete this.stream;delete this.video}if(this.userMedia!==true&&this.loaded&&!this.iOS){var t=this.getMovie();if(t&&t._releaseCamera)t._releaseCamera()}if(this.container){this.container.innerHTML="";delete this.container}this.loaded=false;this.live=false},set:function(){if(arguments.length==1){for(var e in arguments[0]){this.params[e]=arguments[0][e]}}else{this.params[arguments[0]]=arguments[1]}},on:function(e,t){e=e.replace(/^on/i,"").toLowerCase();if(!this.hooks[e])this.hooks[e]=[];this.hooks[e].push(t)},off:function(e,t){e=e.replace(/^on/i,"").toLowerCase();if(this.hooks[e]){if(t){var i=this.hooks[e].indexOf(t);if(i>-1)this.hooks[e].splice(i,1)}else{this.hooks[e]=[]}}},dispatch:function(){var t=arguments[0].replace(/^on/i,"").toLowerCase();var s=Array.prototype.slice.call(arguments,1);if(this.hooks[t]&&this.hooks[t].length){for(var r=0,o=this.hooks[t].length;r<o;r++){var n=this.hooks[t][r];if(typeof n=="function"){n.apply(this,s)}else if(typeof n=="object"&&n.length==2){n[0][n[1]].apply(n[0],s)}else if(e[n]){e[n].apply(e,s)}}return true}else if(t=="error"){if(s[0]instanceof i||s[0]instanceof a){message=s[0].message}else{message="Could not access webcam: "+s[0].name+": "+s[0].message+" "+s[0].toString()}alert("Webcam.js Error: "+message)}return false},setSWFLocation:function(e){this.set("swfURL",e)},detectFlash:function(){var t="Shockwave Flash",i="ShockwaveFlash.ShockwaveFlash",a="application/x-shockwave-flash",s=e,r=navigator,o=false;if(typeof r.plugins!=="undefined"&&typeof r.plugins[t]==="object"){var n=r.plugins[t].description;if(n&&(typeof r.mimeTypes!=="undefined"&&r.mimeTypes[a]&&r.mimeTypes[a].enabledPlugin)){o=true}}else if(typeof s.ActiveXObject!=="undefined"){try{var h=new ActiveXObject(i);if(h){var l=h.GetVariable("$version");if(l)o=true}}catch(e){}}return o},getSWFHTML:function(){var t="",a=this.params.swfURL;if(location.protocol.match(/file/)){this.dispatch("error",new i("Flash does not work from local disk. Please run from a web server."));return'<h3 style="color:red">ERROR: the Webcam.js Flash fallback does not work from local disk. Please run it from a web server.</h3>'}if(!this.detectFlash()){this.dispatch("error",new i("Adobe Flash Player not found. Please install from get.adobe.com/flashplayer and try again."));return'<h3 style="color:red">'+this.params.flashNotDetectedText+"</h3>"}if(!a){var s="";var r=document.getElementsByTagName("script");for(var o=0,n=r.length;o<n;o++){var h=r[o].getAttribute("src");if(h&&h.match(/\/webcam(\.min)?\.js/)){s=h.replace(/\/webcam(\.min)?\.js.*$/,"");o=n}}if(s)a=s+"/webcam.swf";else a="webcam.swf"}if(e.localStorage&&!localStorage.getItem("visited")){this.params.new_user=1;localStorage.setItem("visited",1)}var l="";for(var d in this.params){if(l)l+="&";l+=d+"="+escape(this.params[d])}t+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" type="application/x-shockwave-flash" codebase="'+this.protocol+'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+this.params.width+'" height="'+this.params.height+'" id="webcam_movie_obj" align="middle"><param name="wmode" value="opaque" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+a+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+l+'"/><embed id="webcam_movie_embed" src="'+a+'" wmode="opaque" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+this.params.width+'" height="'+this.params.height+'" name="webcam_movie_embed" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+l+'"></embed></object>';return t},getMovie:function(){if(!this.loaded)return this.dispatch("error",new i("Flash Movie is not loaded yet"));var e=document.getElementById("webcam_movie_obj");if(!e||!e._snap)e=document.getElementById("webcam_movie_embed");if(!e)this.dispatch("error",new i("Cannot locate Flash movie in DOM"));return e},freeze:function(){var e=this;var t=this.params;if(this.preview_active)this.unfreeze();var i=this.params.width/this.params.dest_width;var a=this.params.height/this.params.dest_height;this.unflip();var s=t.crop_width||t.dest_width;var r=t.crop_height||t.dest_height;var o=document.createElement("canvas");o.width=s;o.height=r;var n=o.getContext("2d");this.preview_canvas=o;this.preview_context=n;if(i!=1||a!=1){o.style.webkitTransformOrigin="0px 0px";o.style.mozTransformOrigin="0px 0px";o.style.msTransformOrigin="0px 0px";o.style.oTransformOrigin="0px 0px";o.style.transformOrigin="0px 0px";o.style.webkitTransform="scaleX("+i+") scaleY("+a+")";o.style.mozTransform="scaleX("+i+") scaleY("+a+")";o.style.msTransform="scaleX("+i+") scaleY("+a+")";o.style.oTransform="scaleX("+i+") scaleY("+a+")";o.style.transform="scaleX("+i+") scaleY("+a+")"}this.snap(function(){o.style.position="relative";o.style.left=""+e.container.scrollLeft+"px";o.style.top=""+e.container.scrollTop+"px";e.container.insertBefore(o,e.peg);e.container.style.overflow="hidden";e.preview_active=true},o)},unfreeze:function(){if(this.preview_active){this.container.removeChild(this.preview_canvas);delete this.preview_context;delete this.preview_canvas;this.preview_active=false;this.flip()}},flip:function(){if(this.params.flip_horiz){var e=this.container.style;e.webkitTransform="scaleX(-1)";e.mozTransform="scaleX(-1)";e.msTransform="scaleX(-1)";e.oTransform="scaleX(-1)";e.transform="scaleX(-1)";e.filter="FlipH";e.msFilter="FlipH"}},unflip:function(){if(this.params.flip_horiz){var e=this.container.style;e.webkitTransform="scaleX(1)";e.mozTransform="scaleX(1)";e.msTransform="scaleX(1)";e.oTransform="scaleX(1)";e.transform="scaleX(1)";e.filter="";e.msFilter=""}},savePreview:function(e,t){var i=this.params;var a=this.preview_canvas;var s=this.preview_context;if(t){var r=t.getContext("2d");r.drawImage(a,0,0)}e(t?null:a.toDataURL("image/"+i.image_format,i.jpeg_quality/100),a,s);if(this.params.unfreeze_snap)this.unfreeze()},snap:function(e,t){if(!e)e=this.params.user_callback;if(!t)t=this.params.user_canvas;var i=this;var s=this.params;if(!this.loaded)return this.dispatch("error",new a("Webcam is not loaded yet"));if(!e)return this.dispatch("error",new a("Please provide a callback function or canvas to snap()"));if(this.preview_active){this.savePreview(e,t);return null}if(this.video){if(this.params.dest_width){var r=this.params.dest_width;var o=this.video.videoWidth/this.params.dest_width}if(this.params.dest_height){var n=this.params.dest_height;var h=this.video.videoHeight/this.params.dest_height}if(!this.params.dest_width){var r=this.video.videoWidth/h}if(!this.params.dest_height){var n=this.video.videoHeight/o}}else{if(this.params.dest_width){var r=this.params.dest_width}if(this.params.dest_height){var n=this.params.dest_height}if(!this.params.dest_width&&this.params.display_aspect_ratio){var r=n*this.params.display_aspect_ratio}if(!this.params.dest_height){var n=r/this.params.display_aspect_ratio}}var l=document.createElement("canvas");l.width=r;l.height=n;var d=l.getContext("2d");var c=function(){if(this.src&&this.width&&this.height){l.width=this.width;l.height=this.height;var i=l.getContext("2d");i.drawImage(this,0,0,this.width,this.height)}if(s.crop_width&&s.crop_height){var a=document.createElement("canvas");a.width=s.crop_width;a.height=s.crop_height;var o=a.getContext("2d");o.drawImage(l,Math.floor(r/2-s.crop_width/2),Math.floor(n/2-s.crop_height/2),s.crop_width,s.crop_height,0,0,s.crop_width,s.crop_height);i=o;l=a}if(t){var h=t.getContext("2d");h.drawImage(l,0,0)}e(t?null:l.toDataURL("image/"+s.image_format,s.jpeg_quality/100),l,i)};if(this.userMedia){var p=document.createElement("canvas");p.width=this.video.videoWidth;p.height=this.video.videoHeight;var m=p.getContext("2d");var f=this.video.videoHeight/this.video.videoWidth;m.drawImage(this.video,0,0,this.video.videoWidth,this.video.videoHeight);d.drawImage(p,0,0,r,n);c()}else if(this.iOS){var v=document.getElementById(this.container.id+"-ios_div");var u=document.getElementById(this.container.id+"-ios_img");var g=document.getElementById(this.container.id+"-ios_input");iFunc=function(e){c.call(u);u.removeEventListener("load",iFunc);v.style.backgroundImage="none";u.removeAttribute("src");g.value=null};if(!g.value){u.addEventListener("load",iFunc);g.style.display="block";g.focus();g.click();g.style.display="none"}else{iFunc(null)}}else{var w=this.getMovie()._snap();var u=new Image;u.onload=c;u.src="data:image/"+this.params.image_format+";base64,"+w}return null},configure:function(e){if(!e)e="camera";this.getMovie()._configure(e)},flashNotify:function(e,t){switch(e){case"flashLoadComplete":this.loaded=true;this.dispatch("load");break;case"cameraLive":this.live=true;this.dispatch("live");break;case"error":this.dispatch("error",new i(t));break;default:break}},b64ToUint6:function(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:e===43?62:e===47?63:0},base64DecToArr:function(e,t){var i=e.replace(/[^A-Za-z0-9\+\/]/g,""),a=i.length,s=t?Math.ceil((a*3+1>>2)/t)*t:a*3+1>>2,r=new Uint8Array(s);for(var o,n,h=0,l=0,d=0;d<a;d++){n=d&3;h|=this.b64ToUint6(i.charCodeAt(d))<<18-6*n;if(n===3||a-d===1){for(o=0;o<3&&l<s;o++,l++){r[l]=h>>>(16>>>o&24)&255}h=0}}return r},upload:function(e,t,i){var a=this.params.upload_name||"webcam";var r="";if(e.match(/^data\:image\/(\w+)/))r=RegExp.$1;else throw"Cannot locate image format in Data URI";var o=e.replace(/^data\:image\/\w+\;base64\,/,"");var n=new XMLHttpRequest;n.open("POST",t,true);if(n.upload&&n.upload.addEventListener){n.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=e.loaded/e.total;s.dispatch("uploadProgress",t,e)}},false)}var h=this;n.onload=function(){if(i)i.apply(h,[n.status,n.responseText,n.statusText]);s.dispatch("uploadComplete",n.status,n.responseText,n.statusText)};var l=new Blob([this.base64DecToArr(o)],{type:"image/"+r});var d=new FormData;d.append(a,l,a+"."+r.replace(/e/,""));n.send(d)}};s.init();if(typeof define==="function"&&define.amd){define(function(){return s})}else if(typeof module==="object"&&module.exports){module.exports=s}else{e.Webcam=s}})(window);