From 9dc36815cdf21287a597842d6653b3f652f5d85c Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 18 Nov 2016 16:33:07 -0500 Subject: Experimental and initial version - still has work to go - #379 --- www/external/gifshot.min.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 www/external/gifshot.min.js (limited to 'www/external') diff --git a/www/external/gifshot.min.js b/www/external/gifshot.min.js new file mode 100644 index 00000000..d20775fc --- /dev/null +++ b/www/external/gifshot.min.js @@ -0,0 +1,8 @@ +/*Copyrights for code authored by Yahoo Inc. is licensed under the following terms: +MIT License +Copyright 2015 Yahoo Inc. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +!function(e,t,r,i){var n,o,a,s,d,c,l,u,m,f,g,h,p,v,b,w,y,C,S,k,F,x;n=function(){var i={URL:e.URL||e.webkitURL||e.mozURL||e.msURL,getUserMedia:function(){var e=r.getUserMedia||r.webkitGetUserMedia||r.mozGetUserMedia||r.msGetUserMedia;return e?e.bind(r):e}(),requestAnimFrame:e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame,requestTimeout:function(e,t){function r(){var i=(new Date).getTime(),s=i-n;s>=t?e.call():o.value=a(r)}if(e=e||i.noop,t=t||0,!i.requestAnimFrame)return setTimeout(e,t);var n=(new Date).getTime(),o=new Object,a=i.requestAnimFrame;return o.value=a(r),o},Blob:e.Blob||e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,btoa:function(){var t=e.btoa||function(e){for(var t,r,i,n,o,a,s,d="",c=0,l=e.length,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";l>c;)t=e.charCodeAt(c++),r=e.charCodeAt(c++),i=e.charCodeAt(c++),n=t>>2,o=(3&t)<<4|r>>4,a=(15&r)<<2|i>>6,s=63&i,isNaN(r)?a=s=64:isNaN(i)&&(s=64),d=d+u.charAt(n)+u.charAt(o)+u.charAt(a)+u.charAt(s);return d};return t?t.bind(e):function(){}}(),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return i.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&"function"==typeof e},isElement:function(e){return e&&1===e.nodeType},isString:function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},isSupported:{canvas:function(){var e=t.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return e.Worker},blob:function(){return i.Blob},Uint8Array:function(){return e.Uint8Array},Uint32Array:function(){return e.Uint32Array},videoCodecs:function(){var e=t.createElement("video"),r={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(r.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),r.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),r.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),r.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),r.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(i){}return r}()},noop:function(){},each:function(e,t){var r,n;if(i.isArray(e))for(r=-1,n=e.length;++ri&&n>=o;)s.style.fontSize=--n+"px";return t.body.removeChild(s),n+"px"},webWorkerError:!1};return i}(),o=function(e){var t={validate:function(r){r=e.isObject(r)?r:{};var i={};return e.each(t.validators,function(e,t){var n=t.errorCode;return r[n]||t.condition?void 0:(i=t,i.error=!0,!1)}),delete i.condition,i},isValid:function(e){var r=t.validate(e),i=r.error!==!0?!0:!1;return i},validators:[{condition:e.isFunction(e.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:e.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:e.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:e.isFunction(e.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:e.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:e.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:e.isSupported.Uint32Array(),errorCode:"window.Uint32Array",errorMsg:"The window.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}};return t}(n),a={sampleInterval:10,numWorkers:2,gifWidth:200,gifHeight:200,interval:.1,numFrames:10,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:function(){},completeCallback:function(){},saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},s=function(){return o.isValid()},d=function(){return o.isValid()},c=function(){var e={getUserMedia:!0};return o.isValid(e)},l=function(e){var t=!1;if(n.isArray(e)&&e.length){if(n.each(e,function(e,r){n.isSupported.videoCodecs[r]&&(t=!0)}),!t)return!1}else if(n.isString(e)&&e.length&&!n.isSupported.videoCodecs[e])return!1;return o.isValid({getUserMedia:!0})},u=function(){function e(){function e(e,t,r){var i,n;for(u=e,m=t,f=r,g=new Array(h),i=0;h>i;i++)g[i]=new Array(4),n=g[i],n[0]=n[1]=n[2]=(i<r;r++)t[g[r][3]]=r;for(var i=0,n=0;h>n;n++){var o=t[n];e[i++]=g[o][0],e[i++]=g[o][1],e[i++]=g[o][2]}return e}function r(){var e,t,r,i,n,o,a,s;for(a=0,s=0,e=0;h>e;e++){for(n=g[e],r=e,i=n[1],t=e+1;h>t;t++)o=g[t],o[1]>1,t=a+1;i>t;t++)B[t]=e;a=i,s=e}}for(B[a]=s+C>>1,t=a+1;256>t;t++)B[t]=C}function i(){var e,t,r,i,n,o,a,g,h,C,F,x,E,W;for(y>m&&(f=1),l=30+(f-1)/3,x=u,E=0,W=m,F=m/(3*f),C=F/k|0,g=j,o=I,a=o>>R,1>=a&&(a=0),e=0;a>e;e++)q[e]=g*((a*a-e*e)*z/(a*a));for(h=y>m?3:m%p!==0?3*p:m%v!==0?3*v:m%b!==0?3*b:3*w,e=0;F>e;)if(r=(255&x[E+0])<=W&&(E-=m),e++,0===C&&(C=1),e%C===0)for(g-=g/l,o-=o/T,a=o>>R,1>=a&&(a=0),t=0;a>t;t++)q[t]=g*((a*a-t*t)*z/(a*a))}function n(e,t,r){var i,n,o,a,s,d,c;for(s=1e3,c=-1,i=B[t],n=i-1;h>i||n>=0;)h>i&&(d=g[i],o=d[1]-t,o>=s?i=h:(i++,0>o&&(o=-o),a=d[0]-e,0>a&&(a=-a),o+=a,s>o&&(a=d[2]-r,0>a&&(a=-a),o+=a,s>o&&(s=o,c=d[3])))),n>=0&&(d=g[n],o=t-d[1],o>=s?n=-1:(n--,0>o&&(o=-o),a=d[0]-e,0>a&&(a=-a),o+=a,s>o&&(a=d[2]-r,0>a&&(a=-a),o+=a,s>o&&(s=o,c=d[3]))));return c}function o(){return i(),a(),r(),t()}function a(){var e;for(e=0;h>e;e++)g[e][0]>>=S,g[e][1]>>=S,g[e][2]>>=S,g[e][3]=e}function s(e,t,r,i,n){var o,a,s,d,c,l,u;for(s=t-e,-1>s&&(s=-1),d=t+e,d>h&&(d=h),o=t+1,a=t-1,l=1;d>o||a>s;){if(c=q[l++],d>o){u=g[o++];try{u[0]-=c*(u[0]-r)/P|0,u[1]-=c*(u[1]-i)/P|0,u[2]-=c*(u[2]-n)/P|0}catch(m){}}if(a>s){u=g[a--];try{u[0]-=c*(u[0]-r)/P|0,u[1]-=c*(u[1]-i)/P|0,u[2]-=c*(u[2]-n)/P|0}catch(m){}}}}function d(e,t,r,i,n){var o=g[t],a=e/j;o[0]-=a*(o[0]-r)|0,o[1]-=a*(o[1]-i)|0,o[2]-=a*(o[2]-n)|0}function c(e,t,r){var i,n,o,a,s,d,c,l,u,m;for(l=~(1<<31),u=l,d=-1,c=d,i=0;h>i;i++)m=g[i],n=m[0]-e,0>n&&(n=-n),o=m[1]-t,0>o&&(o=-o),n+=o,o=m[2]-r,0>o&&(o=-o),n+=o,l>n&&(l=n,d=i),a=n-(G[i]>>F-S),u>a&&(u=a,c=i),s=D[i]>>W,D[i]-=s,G[i]+=s<>W,A=x<>3,R=6,M=1<i;)o.push(e[i++]),o.push(e[i++]),o.push(e[i++]),i++;return o},componentizedPaletteToArray:function(e){var t,r,i,n,o=[];for(t=0;to;o++)a=c[h++],s=c[h++],d=c[h++],g[o]=l.map(a,s,d);return{pixels:g,palette:m}},run:function(e){var t=e.width,r=e.height,i=e.data,n=(e.palette,e.sampleInterval);return this.processFrameWithQuantizer(i,t,r,n)}};return r};return t}(u),f=function(e,t,r,n){function o(e){var t=e.length;if(2>t||t>256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}function a(e,t,r,n){function o(r){for(;f>=r;)e[t++]=255&g,g>>=8,f-=8,t===s+256&&(e[s]=255,s=t++)}function a(e){g|=e<v;++v){var w=n[v]&c,y=h<<8|w,C=p[y];if(C===i){for(g|=h<=8;)e[t++]=255&g,g>>=8,f-=8,t===s+256&&(e[s]=255,s=t++);4096===u?(a(d),u=l+1,m=r+1,p={}):(u>=1<=t||0>=r||t>65535||r>65535)throw"Width/Height invalid.";e[s++]=71,e[s++]=73,e[s++]=70,e[s++]=56,e[s++]=57,e[s++]=97;var l=0,u=0;if(e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=(null!==c?128:0)|l,e[s++]=u,e[s++]=0,null!==d){if(0>d||d>65535)throw"Loop count invalid.";e[s++]=33,e[s++]=255,e[s++]=11,e[s++]=78,e[s++]=69,e[s++]=84,e[s++]=83,e[s++]=67,e[s++]=65,e[s++]=80,e[s++]=69,e[s++]=50,e[s++]=46,e[s++]=48,e[s++]=3,e[s++]=1,e[s++]=255&d,e[s++]=d>>8&255,e[s++]=0}var m=!1;this.addFrame=function(t,r,n,d,l,u){if(m===!0&&(--s,m=!1),u=u===i?{}:u,0>t||0>r||t>65535||r>65535)throw"x/y invalid.";if(0>=n||0>=d||n>65535||d>65535)throw"Width/Height invalid.";if(l.length>=1;)++p;h=1<b||b>3)throw"Disposal out of range.";var w=!1,y=0;if(u.transparent!==i&&null!==u.transparent&&(w=!0,y=u.transparent,0>y||y>=h))throw"Transparent color index.";if((0!==b||w||0!==v)&&(e[s++]=33,e[s++]=249,e[s++]=4,e[s++]=b<<2|(w===!0?1:0),e[s++]=255&v,e[s++]=v>>8&255,e[s++]=y,e[s++]=0),e[s++]=44,e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=255&n,e[s++]=n>>8&255,e[s++]=255&d,e[s++]=d>>8&255,e[s++]=f===!0?128|p-1:0,f===!0)for(var C=0,S=g.length;S>C;++C){var k=g[C];e[s++]=k>>16&255,e[s++]=k>>8&255,e[s++]=255&k}s=a(e,s,2>p?2:p,l)},this.end=function(){return m===!1&&(e[s++]=59,m=!0),s}},g=function(e,r,i,n){var o=function(t){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=e.noop,this.onRenderProgressCallback=e.noop,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=t,this.initializeWebWorkers(t)};return o.prototype={workerMethods:r(),initializeWebWorkers:function(n){var o,a,s,d,c=i.toString()+"("+r.toString()+"());",l=-1,u="";for(d=n.numWorkers;++lt;t++)e[t]=String.fromCharCode(t);return e}(),bufferToString:function(e){for(var t=e.length,r="",i=-1;++i=0&&this.processFrame(e)},generateGIF:function(t,r){var i,o,a=[],s={loop:this.repeat},d=this.options,c=d.interval,l=d.images,u=!!l.length,m=d.gifHeight,f=d.gifWidth,g=new n(a,f,m,s),h=this.onRenderProgressCallback,p=u?100*c:0;this.generatingGIF=!0,e.each(t,function(e,r){var i=r.palette;h(.75+.25*r.position*1/t.length),g.addFrame(0,0,f,m,r.pixels,{palette:i,delay:p})}),g.end(),h(1),this.frames=[],this.generatingGIF=!1,e.isFunction(r)&&(i=this.bufferToString(a),o="data:image/gif;base64,"+e.btoa(i),r(o))},setRepeat:function(e){this.repeat=e},addFrame:function(t,r){r=e.isObject(r)?r:{};var i,n=this,o=n.ctx,a=n.options,s=a.gifWidth,d=a.gifHeight,c=(r.gifHeight,r.gifWidth,r.text),l=r.fontWeight,u=e.getFontSize(r),m=r.fontFamily,f=r.fontColor,g=r.textAlign,h=r.textBaseline,p=r.textXCoordinate?r.textXCoordinate:"left"===g?1:"right"===g?s:s/2,v=r.textYCoordinate?r.textYCoordinate:"top"===h?1:"center"===h?d/2:d,b=l+" "+u+" "+m;try{o.drawImage(t,0,0,s,d),c&&(o.font=b,o.fillStyle=f,o.textAlign=g,o.textBaseline=h,o.fillText(c,p,v)),i=o.getImageData(0,0,s,d),n.addFrameImageData(i)}catch(w){return""+w}},addFrameImageData:function(e){var t=this.frames,r=e.data;this.frames.push({data:r,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:t.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(t){var r=this,i=function(i){r.destroyWorkers(),e.requestTimeout(function(){t(i)},0)};r.startRendering(i)},destroyWorkers:function(){if(!this.workerError){var t=this.workers;e.each(t,function(t,r){var i=r.worker,n=r.objectUrl;i.terminate(),e.URL.revokeObjectURL(n)})}}},o}(n,m,u,f),h=function(e,t){e.getBase64GIF(function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})})},p=function(e){function r(){n.each(p,function(e,t){t&&s.addFrame(t,u)}),h(s,l)}var a,s,d=e.images,c=e.imagesLength,l=e.callback,u=e.options,m={getUserMedia:!0,"window.URL":!0},f=o.validate(m),p=[],v=0;return f.error?l(f):(s=new g(u),n.each(d,function(e,o){n.isElement(o)?(u.crossOrigin&&(o.crossOrigin=u.crossOrigin),p[e]=o,v+=1,v===c&&r()):n.isString(o)&&(a=t.createElement("img"),u.crossOrigin&&(a.crossOrigin=u.crossOrigin),a.onerror=function(){p.length>e&&(p[e]=i)}(function(t){t.onload=function(){p[e]=t,v+=1,v===c&&r(),n.removeElement(t)}}(a)),a.src=o,n.setCSSAttr(a,{position:"fixed",opacity:"0"}),t.body.appendChild(a))}),void 0)},v={getGIF:function(e,r){r=n.isFunction(r)?r:n.noop;var i,o=t.createElement("canvas"),a=e.images,s=!!a.length,d=e.videoElement,c=e.keepCameraOn,l=e.webcamVideoElement,u=e.cameraStream,m=+e.gifWidth,f=+e.gifHeight,h=e.videoWidth,p=e.videoHeight,v=(+e.sampleInterval,+e.numWorkers,e.crop),b=+e.interval,w=s?0:1e3*b,y=e.progressCallback,C=e.savedRenderingContexts,S=e.saveRenderingContexts,k=[],F=C.length?C.length:e.numFrames,x=F,E=new g(e),W=e.text,O=e.fontWeight,A=n.getFontSize(e),U=e.fontFamily,R=e.fontColor,M=e.textAlign,I=e.textBaseline,T=e.textXCoordinate?e.textXCoordinate:"left"===M?1:"right"===M?m:m/2,V=e.textYCoordinate?e.textYCoordinate:"top"===I?1:"center"===I?f/2:f,j=O+" "+A+" "+U,H=v?Math.floor(v.scaledWidth/2):0,z=v?h-v.scaledWidth:0,L=v?Math.floor(v.scaledHeight/2):0,P=v?p-v.scaledHeight:0,B=function G(){function e(){try{z>h&&(z=h),P>p&&(P=p),0>H&&(H=0),0>L&&(L=0),i.drawImage(d,H,L,z,P,0,0,m,f),t()}catch(r){if("NS_ERROR_NOT_AVAILABLE"!==r.name)throw r;n.requestTimeout(e,100)}}function t(){x=o;var t,a,s,g,h=F-x;S&&k.push(i.getImageData(0,0,m,f)),W&&(i.font=j,i.fillStyle=R,i.textAlign=M,i.textBaseline=I,i.fillText(W,T,V)),t=i.getImageData(0,0,m,f),a=t.data,s=a[0]+a[1]+a[2]+a[3],g=0===s,g?1===h&&1===F&&e():E.addFrameImageData(t),y(h/F),o>0&&n.requestTimeout(G,w),x||E.getBase64GIF(function(e){r({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:u,videoElement:d,webcamVideoElement:l,savedRenderingContexts:k,keepCameraOn:c})})}var o=x-1;C.length?(i.putImageData(C[F-x],0,0),t()):e()};F=null!=F?F:10,b=null!=b?b:.1,o.width=m,o.height=f,i=o.getContext("2d"),function D(){return C.length||0!==d.currentTime?(B(),void 0):(n.requestTimeout(D,100),void 0)}()},getCropDimensions:function(e){var t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,n=e.gifHeight,o={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(o.width=Math.round(t*(n/r))-i,o.scaledWidth=Math.round(o.width*(r/n))):(o.height=Math.round(r*(i/t))-n,o.scaledHeight=Math.round(o.height*(t/i))),o}},b={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function E(e){E.attempts=E.attempts||0;var t=this,r=e.videoElement,i=e.cameraStream,o=e.completedCallback;r&&(r.videoWidth>0&&r.videoHeight>0?(r.removeEventListener("loadeddata",t.findVideoSize),o({videoElement:r,cameraStream:i,videoWidth:r.videoWidth,videoHeight:r.videoHeight})):E.attempts<10?(E.attempts+=1,n.requestTimeout(function(){t.findVideoSize(e)},200)):o({videoElement:r,cameraStream:i,videoWidth:t.defaultVideoDimensions.width,videoHeight:t.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){n.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){var t=this,r=n.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,i=e.videoElement,o=e.cameraStream,a=e.streamedCallback,s=e.completedCallback;n.isFunction(a)&&a(),r?n.isString(r)&&(i.src=r,i.innerHTML=''):i.mozSrcObject?i.mozSrcObject=o:n.URL&&(i.src=n.URL.createObjectURL(o)),i.play(),n.requestTimeout(function d(){d.count=d.count||0,t.loadedData===!0?(t.findVideoSize({videoElement:i,cameraStream:o,completedCallback:s}),t.loadedData=!1):(d.count+=1,d.count>10?t.findVideoSize({videoElement:i,cameraStream:o,completedCallback:s}):d())},100)},startStreaming:function(e){var r=this,i=n.isFunction(e.error)?e.error:n.noop,o=n.isFunction(e.streamed)?e.streamed:n.noop,a=n.isFunction(e.completed)?e.completed:n.noop,s=e.existingVideo,d=e.webcamVideoElement,c=n.isElement(s)?s:d?d:t.createElement("video"),l=e.lastCameraStream,u=e.crossOrigin,m=e.options;u&&(c.crossOrigin=m.crossOrigin),c.autoplay=!0,c.loop=!0,c.muted=!0,c.addEventListener("loadeddata",function(){r.loadedData=!0}),s?r.stream({videoElement:c,existingVideo:s,completedCallback:a}):l?r.stream({videoElement:c,cameraStream:l,streamedCallback:o,completedCallback:a}):n.getUserMedia({video:!0},function(e){r.stream({videoElement:c,cameraStream:e,streamedCallback:o,completedCallback:a})},i)},startVideoStreaming:function(e,t){t=t||{};var r,o=this,a=t.timeout!==i?t.timeout:0,s=t.callback,d=t.webcamVideoElement;a>0&&(r=n.requestTimeout(function(){o.onStreamingTimeout(s)},1e4)),this.startStreaming({error:function(){s({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(r)},completed:function(t){var r=t.cameraStream,i=t.videoElement,n=t.videoWidth,o=t.videoHeight;e({cameraStream:r,videoElement:i,videoWidth:n,videoHeight:o})},lastCameraStream:t.lastCameraStream,webcamVideoElement:d,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){e=n.isObject(e)?e:{};var t=e.cameraStream,r=e.videoElement,i=e.keepCameraOn,o=e.webcamVideoElement;!i&&t&&n.isFunction(t.stop)&&t.stop(),n.isElement(r)&&!o&&(r.pause(),n.isFunction(n.URL.revokeObjectURL)&&!n.webWorkerError&&r.src&&n.URL.revokeObjectURL(r.src),n.removeElement(r))}},w=function(e){e=n.isObject(e)?e:{};var t=(n.isObject(e.options)?e.options:{},e.cameraStream),r=e.videoElement,i=e.webcamVideoElement,o=e.keepCameraOn;b.stopVideoStreaming({cameraStream:t,videoElement:r,keepCameraOn:o,webcamVideoElement:i})},y=function(e,r){var i=e.options||{},o=i.images,a=i.video,s=(+i.numFrames,e.cameraStream),d=e.videoElement,c=e.videoWidth,l=e.videoHeight,u=+i.gifWidth,m=+i.gifHeight,f=v.getCropDimensions({videoWidth:c,videoHeight:l,gifHeight:m,gifWidth:u}),g=r;i.crop=f,i.videoElement=d,i.videoWidth=c,i.videoHeight=l,i.cameraStream=s,n.isElement(d)&&(d.width=u+f.width,d.height=m+f.height,i.webcamVideoElement||(n.setCSSAttr(d,{position:"fixed",opacity:"0"}),t.body.appendChild(d)),d.play(),v.getGIF(i,function(e){o&&o.length||a&&a.length||w(e),g(e)}))},C=function(e){var t,r,i=e.existingVideo,a=e.callback,s=e.options,d={getUserMedia:!0,"window.URL":!0},c=o.validate(d);if(c.error)return a(c);if(n.isElement(i)&&i.src){if(r=i.src,t=n.getExtension(r),!n.isSupported.videoCodecs[t])return a(o.messages.videoCodecs)}else n.isArray(i)&&n.each(i,function(e,r){return t=r.substr(r.lastIndexOf(".")+1,r.length),n.isSupported.videoCodecs[t]?(i=r,!1):void 0});b.startStreaming({completed:function(e){e.options=s||{},y(e,a)},existingVideo:i,crossOrigin:s.crossOrigin,options:s})},S=function(e){var t=e.lastCameraStream,r=e.callback,i=e.webcamVideoElement,n=e.options;return d()?n.savedRenderingContexts.length?(v.getWebcamGIF(n,function(e){r(e)}),void 0):(b.startVideoStreaming(function(e){e.options=n||{},y(e,r)},{lastCameraStream:t,callback:r,webcamVideoElement:i,crossOrigin:n.crossOrigin}),void 0):r(o.validate())},k=function(e,t){if(t=n.isFunction(e)?e:t,e=n.isObject(e)?e:{},n.isFunction(t)){var r=n.mergeOptions(a,e)||{},i=e.cameraStream,o=r.images,s=o?o.length:0,d=r.video,c=r.webcamVideoElement;r=n.mergeOptions(r,{gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),s?p({images:o,imagesLength:s,callback:t,options:r}):d?C({existingVideo:d,callback:t,options:r}):S({lastCameraStream:i,callback:t,webcamVideoElement:c,options:r})}},F=function(e,t){if(t=n.isFunction(e)?e:t,e=n.isObject(e)?e:{},n.isFunction(t)){var r=n.mergeOptions(a,e),i=n.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)});k(i,t)}},x=function(e,t,r,i,n,o,a,s,d,c){var l={utils:e,error:t,defaultOptions:r,createGIF:s,takeSnapShot:d,stopVideoStreaming:c,isSupported:i,isWebCamGIFSupported:n,isExistingVideoGIFSupported:a,isExistingImagesGIFSupported:o,VERSION:"0.3.2"};return l}(n,o,a,s,d,c,l,k,F,w),function(t){"function"==typeof define&&define.amd?define([],function(){return t}):"undefined"!=typeof exports?module.exports=t:e.gifshot=t}(x)}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{}); \ No newline at end of file -- cgit v1.2.3