From 1d153e9a8dcfee5501e086454c998f4535105b24 Mon Sep 17 00:00:00 2001 From: Harvey Date: Wed, 27 Nov 2019 16:17:05 +0800 Subject: [PATCH] build all packages --- .size-snapshot.json | 12 ++++++------ dist/artplayer-plugin-gif.js | 2 +- dist/artplayer-plugin-playlist.js | 2 +- dist/artplayer-react.css | 19 +++++++++++++++++++ .../dist/artplayer-plugin-gif.js | 2 +- .../dist/artplayer-plugin-playlist.js | 2 +- 6 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 dist/artplayer-react.css diff --git a/.size-snapshot.json b/.size-snapshot.json index daa3f51f0..01652fbac 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -15,14 +15,14 @@ "gzipped": 4310 }, "packages/artplayer-plugin-gif/dist/artplayer-plugin-gif.js": { - "bundled": 98459, - "minified": 28832, - "gzipped": 10437 + "bundled": 98490, + "minified": 28855, + "gzipped": 10441 }, "packages/artplayer-plugin-playlist/dist/artplayer-plugin-playlist.js": { - "bundled": 4227, - "minified": 1927, - "gzipped": 843 + "bundled": 4347, + "minified": 1954, + "gzipped": 856 }, "packages/artplayer-tool-thumbnail/dist/artplayer-tool-thumbnail.js": { "bundled": 16311, diff --git a/dist/artplayer-plugin-gif.js b/dist/artplayer-plugin-gif.js index 2ca13b953..b99b3a634 100644 --- a/dist/artplayer-plugin-gif.js +++ b/dist/artplayer-plugin-gif.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).artplayerPluginGif=t()}(this,(function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t((function(e,t){!function(t,r,i,n){var o,a,s={URL:t.URL||t.webkitURL||t.mozURL||t.msURL,getUserMedia:(a=i.getUserMedia||i.webkitGetUserMedia||i.mozGetUserMedia||i.msGetUserMedia,a?a.bind(i):a),requestAnimFrame:t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame,requestTimeout:function(e,t){if(e=e||s.noop,t=t||0,!s.requestAnimFrame)return setTimeout(e,t);var r=(new Date).getTime(),i=new Object,n=s.requestAnimFrame;return i.value=n((function o(){(new Date).getTime()-r>=t?e.call():i.value=n(o)})),i},Blob:t.Blob||t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,btoa:(o=t.btoa||function(e){for(var t="",r=0,i=e.length,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=void 0,a=void 0,s=void 0,c=void 0,d=void 0,l=void 0,u=void 0;r>2,d=(3&o)<<4|(a=e.charCodeAt(r++))>>4,l=(15&a)<<2|(s=e.charCodeAt(r++))>>6,u=63&s,isNaN(a)?l=u=64:isNaN(s)&&(u=64),t=t+n.charAt(c)+n.charAt(d)+n.charAt(l)+n.charAt(u);return t},o?o.bind(t):s.noop),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return s.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=r.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return t.Worker},blob:function(){return s.Blob},Uint8Array:function(){return t.Uint8Array},Uint32Array:function(){return t.Uint32Array},videoCodecs:function(){var e=r.createElement("video"),t={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(t.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),t.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),t.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),t.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),t.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(e){}return t}()},noop:function(){},each:function(e,t){var r=void 0,i=void 0;if(s.isArray(e))for(r=-1,i=e.length;++r0&&arguments[0]!==n?arguments[0]:{};if(!r.body||!1===e.resizeFont)return e.fontSize;var t=e.text,i=e.gifWidth,o=parseInt(e.fontSize,10),a=parseInt(e.minFontSize,10),s=r.createElement("div"),c=r.createElement("span");for(s.setAttribute("width",i),s.appendChild(c),c.innerHTML=t,c.style.fontSize=o+"px",c.style.textIndent="-9999px",c.style.visibility="hidden",r.body.appendChild(c);c.offsetWidth>i&&o>=a;)c.style.fontSize=--o+"px";return r.body.removeChild(c),o+"px"},webWorkerError:!1},c=Object.freeze({default:s}),d={validate:function(e){e=s.isObject(e)?e:{};var t={};return s.each(d.validators,(function(r,i){var n=i.errorCode;if(!e[n]&&!i.condition)return(t=i).error=!0,!1})),delete t.condition,t},isValid:function(e){var t=!0!==d.validate(e).error;return t},validators:[{condition:s.isFunction(s.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:s.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:s.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:s.isFunction(s.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:s.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:s.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:s.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"}}},l=Object.freeze({default:d}),u=function(){},f={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,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:u,completeCallback:u,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},g=Object.freeze({default:f});function m(){return d.isValid()}function h(){var e,t,r,i,n,o=256,a=499,s=491,c=487,d=503,l=3*d,u=o-1,f=4,g=100,m=16,h=1<>v,w=h<>3)*(1<o&&(l=o),s=t+1,c=t-1,f=1;sd;){if(u=A[f++],sd){g=n[c--];try{g[0]-=u*(g[0]-r)/k|0,g[1]-=u*(g[1]-i)/k|0,g[2]-=u*(g[2]-a)/k|0}catch(e){}}}}function T(e,t,r,i,o){var a=n[t],s=e/x;a[0]-=s*(a[0]-r)|0,a[1]-=s*(a[1]-i)|0,a[2]-=s*(a[2]-o)|0}function U(e,t,r){var i,a,s,c,d,l,u,g,h,y;for(h=g=~(1<<31),u=l=-1,i=0;i>m-f))>v,E[i]-=d,W[i]+=d<=0;)i=d?i=o:(i++,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)=0&&((s=t-(l=n[a])[1])>=d?a=-1:(a--,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)>y)<=1&&(v=0),n=0;n=j&&(E-=r),0===k&&(k=1),++n%k==0)for(b-=b/e,(v=(p-=p/S)>>y)<=1&&(v=0),o=0;o>=f,n[e][1]>>=f,n[e][2]>>=f,n[e][3]=e}(),function(){var e,t,r,i,a,s,c,d;for(c=0,d=0,e=0;e>1,t=c+1;t>1,t=c+1;t<256;t++)F[t]=u}(),function(){for(var e=[],t=new Array(o),r=0;r65535||r>65535)throw"Width/Height invalid.";e[o++]=71,e[o++]=73,e[o++]=70,e[o++]=56,e[o++]=57,e[o++]=97;if(e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=0|(null!==s?128:0),e[o++]=0,e[o++]=0,null!==a){if(a<0||a>65535)throw"Loop count invalid.";e[o++]=33,e[o++]=255,e[o++]=11,e[o++]=78,e[o++]=69,e[o++]=84,e[o++]=83,e[o++]=67,e[o++]=65,e[o++]=80,e[o++]=69,e[o++]=50,e[o++]=46,e[o++]=48,e[o++]=3,e[o++]=1,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=0}var c=!1;this.addFrame=function(t,r,i,a,d,l){if(!0===c&&(--o,c=!1),l=l===n?{}:l,t<0||r<0||t>65535||r>65535)throw"x/y invalid.";if(i<=0||a<=0||i>65535||a>65535)throw"Width/Height invalid.";if(d.length256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}(f),m=0;g>>=1;)++m;g=1<3)throw"Disposal out of range.";var v=!1,b=0;if(l.transparent!==n&&null!==l.transparent&&(v=!0,(b=l.transparent)<0||b>=g))throw"Transparent color index.";if((0!==p||v||0!==h)&&(e[o++]=33,e[o++]=249,e[o++]=4,e[o++]=p<<2|(!0===v?1:0),e[o++]=255&h,e[o++]=h>>8&255,e[o++]=b,e[o++]=0),e[o++]=44,e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=255&i,e[o++]=i>>8&255,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=!0===u?128|m-1:0,!0===u)for(var w=0,y=f.length;w>16&255,e[o++]=C>>8&255,e[o++]=255&C}o=function(e,t,r,i){e[t++]=r;var o=t++,a=1<=r;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++)}function m(e){f|=e<=8;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++);4096===d?(m(a),d=c+1,l=r+1,p={}):(d>=1<0&&arguments[0]!==n?arguments[0]:{},r=e.data;delete s.data,s.pixels=Array.prototype.slice.call(r.pixels),s.palette=Array.prototype.slice.call(r.palette),s.done=!0,s.beingProcessed=!1,t.freeWorker(c),t.onFrameFinished(i)};(s=a[e]).beingProcessed||s.done?this.onFrameFinished():(s.sampleInterval=o,s.beingProcessed=!0,s.gifshot=!0,(c=this.getWorker())?(c.onmessage=d,c.postMessage(s)):d({data:t.workerMethods.run(s)}))},startRendering:function(e){this.onRenderCompleteCallback=e;for(var t=0;t=0&&this.processFrame(e)},generateGIF:function(e,t){var r=[],i={loop:this.repeat},n=this.options,o=n.interval,a=n.frameDuration,c=!!n.images.length,d=n.gifHeight,l=n.gifWidth,u=new v(r,l,d,i),f=this.onRenderProgressCallback,g=c?100*o:0,m=void 0;this.generatingGIF=!0,s.each(e,(function(t,r){var i=r.palette;f(.75+.25*r.position*1/e.length);for(var n=0;n0&&arguments[0]!==n?arguments[0]:{},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(e){var t=this;t.startRendering((function(r){t.destroyWorkers(),s.requestTimeout((function(){e(r)}),0)}))},destroyWorkers:function(){if(!this.workerError){var e=this.workers;s.each(e,(function(e,t){var r=t.worker,i=t.objectUrl;r.terminate(),s.URL.revokeObjectURL(i)}))}}};var y=function(){},C={getGIF:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=arguments[1];t=s.isFunction(t)?t:y;var i=r.createElement("canvas"),o=void 0,a=e.images,c=!!a.length,d=e.cameraStream,l=e.crop,u=e.filter,f=e.fontColor,g=e.fontFamily,m=e.fontWeight,h=e.keepCameraOn,p=(e.numWorkers,e.progressCallback),v=e.saveRenderingContexts,b=e.savedRenderingContexts,C=e.text,S=e.textAlign,x=e.textBaseline,O=e.videoElement,k=e.videoHeight,F=e.videoWidth,W=e.webcamVideoElement,E=Number(e.gifWidth),A=Number(e.gifHeight),R=Number(e.interval),T=(Number(e.sampleInterval),c?0:1e3*R),U=[],j=b.length?b.length:e.numFrames,M=j,I=new w(e),P=s.getFontSize(e),V=e.textXCoordinate?e.textXCoordinate:"left"===S?1:"right"===S?E:E/2,L=e.textYCoordinate?e.textYCoordinate:"top"===x?1:"center"===x?A/2:A,H=m+" "+P+" "+g,z=l?Math.floor(l.scaledWidth/2):0,G=l?F-l.scaledWidth:0,B=l?Math.floor(l.scaledHeight/2):0,D=l?k-l.scaledHeight:0,N=function e(){var r=M-1;function i(){var i;v&&U.push(o.getImageData(0,0,E,A)),C&&(o.font=H,o.fillStyle=f,o.textAlign=S,o.textBaseline=x,o.fillText(C,V,L)),i=o.getImageData(0,0,E,A),I.addFrameImageData(i),p((j-(M=r))/j),r>0&&s.requestTimeout(e,T),M||I.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:d,videoElement:O,webcamVideoElement:W,savedRenderingContexts:U,keepCameraOn:h})}))}b.length?(o.putImageData(b[j-M],0,0),i()):function e(){try{G>F&&(G=F),D>k&&(D=k),z<0&&(z=0),B<0&&(B=0),o.filter=u,o.drawImage(O,z,B,G,D,0,0,E,A),i()}catch(t){if("NS_ERROR_NOT_AVAILABLE"!==t.name)throw t;s.requestTimeout(e,100)}}()};j=j!==n?j:10,R=R!==n?R:.1,i.width=E,i.height=A,o=i.getContext("2d"),function e(){b.length||0!==O.currentTime?N():s.requestTimeout(e,100)}()},getCropDimensions:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,o=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(a.width=Math.round(t*(o/r))-i,a.scaledWidth=Math.round(a.width*(r/o))):(a.height=Math.round(r*(i/t))-o,a.scaledHeight=Math.round(a.height*(t/i))),a}},S={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function e(t){e.attempts=e.attempts||0;var r=t.cameraStream,i=t.completedCallback,n=t.videoElement;n&&(n.videoWidth>0&&n.videoHeight>0?(n.removeEventListener("loadeddata",S.findVideoSize),i({videoElement:n,cameraStream:r,videoWidth:n.videoWidth,videoHeight:n.videoHeight})):e.attempts<10?(e.attempts+=1,s.requestTimeout((function(){S.findVideoSize(t)}),400)):i({videoElement:n,cameraStream:r,videoWidth:S.defaultVideoDimensions.width,videoHeight:S.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){s.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=s.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,r=e.cameraStream,i=e.completedCallback,n=e.streamedCallback,o=e.videoElement;if(s.isFunction(n)&&n(),t){if(s.isString(t))o.src=t,o.innerHTML='';else if(t instanceof Blob){try{o.src=s.URL.createObjectURL(t)}catch(e){}o.innerHTML=''}}else if(o.mozSrcObject)o.mozSrcObject=r;else if(s.URL)try{o.srcObject=r,o.src=s.URL.createObjectURL(r)}catch(e){o.srcObject=r}o.play(),s.requestTimeout((function e(){e.count=e.count||0,!0===S.loadedData?(S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}),S.loadedData=!1):(e.count+=1)>10?S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}):e()}),0)},startStreaming:function(e){var t=s.isFunction(e.error)?e.error:s.noop,i=s.isFunction(e.streamed)?e.streamed:s.noop,n=s.isFunction(e.completed)?e.completed:s.noop,o=e.crossOrigin,a=e.existingVideo,c=e.lastCameraStream,d=e.options,l=e.webcamVideoElement,u=s.isElement(a)?a:l||r.createElement("video");o&&(u.crossOrigin=d.crossOrigin),u.autoplay=!0,u.loop=!0,u.muted=!0,u.addEventListener("loadeddata",(function(e){S.loadedData=!0,d.offset&&(u.currentTime=d.offset)})),a?S.stream({videoElement:u,existingVideo:a,completedCallback:n}):c?S.stream({videoElement:u,cameraStream:c,streamedCallback:i,completedCallback:n}):s.getUserMedia({video:!0},(function(e){S.stream({videoElement:u,cameraStream:e,streamedCallback:i,completedCallback:n})}),t)},startVideoStreaming:function(e){var t=arguments.length>1&&arguments[1]!==n?arguments[1]:{},r=t.timeout!==n?t.timeout:0,i=t.callback,o=t.webcamVideoElement,a=void 0;r>0&&(a=s.requestTimeout((function(){S.onStreamingTimeout(i)}),1e4)),S.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){var t=arguments.length>0&&arguments[0]!==n?arguments[0]:{},r=t.cameraStream,i=t.videoElement,o=t.videoHeight,a=t.videoWidth;e({cameraStream:r,videoElement:i,videoHeight:o,videoWidth:a})},lastCameraStream:t.lastCameraStream,webcamVideoElement:o,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){var t=e=s.isObject(e)?e:{},r=t.keepCameraOn,i=t.videoElement,n=t.webcamVideoElement,o=e.cameraStream||{},a=o.getTracks&&o.getTracks()||[],c=!!a.length,d=a[0];!r&&c&&s.isFunction(d.stop)&&d.stop(),s.isElement(i)&&!n&&(i.pause(),s.isFunction(s.URL.revokeObjectURL)&&!s.webWorkerError&&i.src&&s.URL.revokeObjectURL(i.src),s.removeElement(i))}};function x(e){e=s.isObject(e)?e:{},S.stopVideoStreaming(e)}function O(e,t){var i=e.options||{},n=i.images,o=i.video,a=Number(i.gifWidth),c=Number(i.gifHeight),d=(Number(i.numFrames),e.cameraStream),l=e.videoElement,u=e.videoWidth,f=e.videoHeight,g=C.getCropDimensions({videoWidth:u,videoHeight:f,gifHeight:c,gifWidth:a}),m=t;i.crop=g,i.videoElement=l,i.videoWidth=u,i.videoHeight=f,i.cameraStream=d,s.isElement(l)&&(l.width=a+g.width,l.height=c+g.height,i.webcamVideoElement||(s.setCSSAttr(l,{position:"fixed",opacity:"0"}),r.body.appendChild(l)),l.play(),C.getGIF(i,(function(e){n&&n.length||o&&o.length||x(e),m(e)})))}function k(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var i=s.mergeOptions(f,e)||{},o=e.cameraStream,a=i.images,c=a?a.length:0,l=i.video,u=i.webcamVideoElement;i=s.mergeOptions(i,{gifWidth:Math.floor(i.gifWidth),gifHeight:Math.floor(i.gifHeight)}),c?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,i=e.images,o=e.options,a=e.imagesLength,c=d.validate({getUserMedia:!0,"window.URL":!0}),l=[],u=0,f=void 0,g=void 0;if(c.error)return t(c);function m(){s.each(l,(function(e,t){t&&(t.text?g.addFrame(t.img,o,t.text):g.addFrame(t,o))})),function(e,t){e.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})}))}(g,t)}g=new w(o),s.each(i,(function(e,i){var n=i;i.src&&(n=n.src),s.isElement(n)?(o.crossOrigin&&(n.crossOrigin=o.crossOrigin),l[e]=n,(u+=1)===a&&m()):s.isString(n)&&(f=new Image,o.crossOrigin&&(f.crossOrigin=o.crossOrigin),function(r){i.text&&(r.text=i.text),r.onerror=function(e){var r=void 0;if(0===--a)return(r={}).error="None of the requested images was capable of being retrieved",t(r)},r.onload=function(t){i.text?l[e]={img:r,text:r.text}:l[e]=r,(u+=1)===a&&m(),s.removeElement(r)},r.src=n}(f),s.setCSSAttr(f,{position:"fixed",opacity:"0"}),r.body.appendChild(f))}))}({images:a,imagesLength:c,callback:t,options:i}):l?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.existingVideo,i=e.options,o=d.validate({getUserMedia:!0,"window.URL":!0}),a=void 0,c=void 0;if(o.error)return t(o);if(s.isElement(r)&&r.src){if(c=r.src,a=s.getExtension(c),!s.isSupported.videoCodecs[a])return t(d.messages.videoCodecs)}else s.isArray(r)&&s.each(r,(function(e,t){if(a=t instanceof Blob?t.type.substr(t.type.lastIndexOf("/")+1,t.length):t.substr(t.lastIndexOf(".")+1,t.length),s.isSupported.videoCodecs[a])return r=t,!1}));S.startStreaming({completed:function(e){e.options=i||{},O(e,t)},existingVideo:r,crossOrigin:i.crossOrigin,options:i})}({existingVideo:l,callback:t,options:i}):function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.lastCameraStream,i=e.options,o=e.webcamVideoElement;if(!m())return t(d.validate());i.savedRenderingContexts.length?C.getGIF(i,(function(e){t(e)})):S.startVideoStreaming((function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{};e.options=i||{},O(e,t)}),{lastCameraStream:r,callback:t,webcamVideoElement:o,crossOrigin:i.crossOrigin})}({lastCameraStream:o,callback:t,webcamVideoElement:u,options:i})}}var F={utils:c,error:l,defaultOptions:g,createGIF:k,takeSnapShot:function(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var r=s.mergeOptions(f,e);k(s.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),t)}},stopVideoStreaming:x,isSupported:function(){return d.isValid()},isWebCamGIFSupported:m,isExistingVideoGIFSupported:function(e){var t=!1;if(s.isArray(e)&&e.length){if(s.each(e,(function(e,r){s.isSupported.videoCodecs[r]&&(t=!0)})),!t)return!1}else if(s.isString(e)&&e.length&&!s.isSupported.videoCodecs[e])return!1;return d.isValid({getUserMedia:!0})},isExistingImagesGIFSupported:function(){return d.isValid({getUserMedia:!0})},VERSION:"0.4.5"};"function"==typeof n&&n.amd?n([],(function(){return F})):e.exports=F}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{})})),i=t((function(e){var t;t=function(){return function(e,t,r){t=t||"",r=r||512;for(var i=atob(e),n=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;y=!0,f.show=!0,e.emit("artplayerPluginGif:start"),d.show=c.get("Start creating gif..."),r.createGIF(o({},t,{video:[v.src],crossOrigin:"anonymous"}),(function(t){if(t.error)d.show=t.errorMsg,n(!1,t.errorMsg);else if("function"==typeof a){var r=t.image.split(",")[1],o=i(r,"image/gif"),s=URL.createObjectURL(o);d.show=c.get("Create gif successfully"),e.emit("artplayerPluginGif",s),a(s)}y=!1,f.show=!1,e.emit("artplayerPluginGif:end")}))}}}})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).artplayerPluginGif=t()}(this,(function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t((function(e,t){!function(t,r,i,n){var o,a,s={URL:t.URL||t.webkitURL||t.mozURL||t.msURL,getUserMedia:(a=i.getUserMedia||i.webkitGetUserMedia||i.mozGetUserMedia||i.msGetUserMedia,a?a.bind(i):a),requestAnimFrame:t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame,requestTimeout:function(e,t){if(e=e||s.noop,t=t||0,!s.requestAnimFrame)return setTimeout(e,t);var r=(new Date).getTime(),i=new Object,n=s.requestAnimFrame;return i.value=n((function o(){(new Date).getTime()-r>=t?e.call():i.value=n(o)})),i},Blob:t.Blob||t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,btoa:(o=t.btoa||function(e){for(var t="",r=0,i=e.length,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=void 0,a=void 0,s=void 0,c=void 0,d=void 0,l=void 0,u=void 0;r>2,d=(3&o)<<4|(a=e.charCodeAt(r++))>>4,l=(15&a)<<2|(s=e.charCodeAt(r++))>>6,u=63&s,isNaN(a)?l=u=64:isNaN(s)&&(u=64),t=t+n.charAt(c)+n.charAt(d)+n.charAt(l)+n.charAt(u);return t},o?o.bind(t):s.noop),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return s.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=r.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return t.Worker},blob:function(){return s.Blob},Uint8Array:function(){return t.Uint8Array},Uint32Array:function(){return t.Uint32Array},videoCodecs:function(){var e=r.createElement("video"),t={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(t.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),t.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),t.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),t.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),t.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(e){}return t}()},noop:function(){},each:function(e,t){var r=void 0,i=void 0;if(s.isArray(e))for(r=-1,i=e.length;++r0&&arguments[0]!==n?arguments[0]:{};if(!r.body||!1===e.resizeFont)return e.fontSize;var t=e.text,i=e.gifWidth,o=parseInt(e.fontSize,10),a=parseInt(e.minFontSize,10),s=r.createElement("div"),c=r.createElement("span");for(s.setAttribute("width",i),s.appendChild(c),c.innerHTML=t,c.style.fontSize=o+"px",c.style.textIndent="-9999px",c.style.visibility="hidden",r.body.appendChild(c);c.offsetWidth>i&&o>=a;)c.style.fontSize=--o+"px";return r.body.removeChild(c),o+"px"},webWorkerError:!1},c=Object.freeze({default:s}),d={validate:function(e){e=s.isObject(e)?e:{};var t={};return s.each(d.validators,(function(r,i){var n=i.errorCode;if(!e[n]&&!i.condition)return(t=i).error=!0,!1})),delete t.condition,t},isValid:function(e){var t=!0!==d.validate(e).error;return t},validators:[{condition:s.isFunction(s.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:s.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:s.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:s.isFunction(s.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:s.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:s.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:s.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"}}},l=Object.freeze({default:d}),u=function(){},f={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,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:u,completeCallback:u,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},g=Object.freeze({default:f});function m(){return d.isValid()}function h(){var e,t,r,i,n,o=256,a=499,s=491,c=487,d=503,l=3*d,u=o-1,f=4,g=100,m=16,h=1<>v,w=h<>3)*(1<o&&(l=o),s=t+1,c=t-1,f=1;sd;){if(u=A[f++],sd){g=n[c--];try{g[0]-=u*(g[0]-r)/k|0,g[1]-=u*(g[1]-i)/k|0,g[2]-=u*(g[2]-a)/k|0}catch(e){}}}}function T(e,t,r,i,o){var a=n[t],s=e/x;a[0]-=s*(a[0]-r)|0,a[1]-=s*(a[1]-i)|0,a[2]-=s*(a[2]-o)|0}function U(e,t,r){var i,a,s,c,d,l,u,g,h,y;for(h=g=~(1<<31),u=l=-1,i=0;i>m-f))>v,E[i]-=d,W[i]+=d<=0;)i=d?i=o:(i++,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)=0&&((s=t-(l=n[a])[1])>=d?a=-1:(a--,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)>y)<=1&&(v=0),n=0;n=j&&(E-=r),0===k&&(k=1),++n%k==0)for(b-=b/e,(v=(p-=p/S)>>y)<=1&&(v=0),o=0;o>=f,n[e][1]>>=f,n[e][2]>>=f,n[e][3]=e}(),function(){var e,t,r,i,a,s,c,d;for(c=0,d=0,e=0;e>1,t=c+1;t>1,t=c+1;t<256;t++)F[t]=u}(),function(){for(var e=[],t=new Array(o),r=0;r65535||r>65535)throw"Width/Height invalid.";e[o++]=71,e[o++]=73,e[o++]=70,e[o++]=56,e[o++]=57,e[o++]=97;if(e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=0|(null!==s?128:0),e[o++]=0,e[o++]=0,null!==a){if(a<0||a>65535)throw"Loop count invalid.";e[o++]=33,e[o++]=255,e[o++]=11,e[o++]=78,e[o++]=69,e[o++]=84,e[o++]=83,e[o++]=67,e[o++]=65,e[o++]=80,e[o++]=69,e[o++]=50,e[o++]=46,e[o++]=48,e[o++]=3,e[o++]=1,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=0}var c=!1;this.addFrame=function(t,r,i,a,d,l){if(!0===c&&(--o,c=!1),l=l===n?{}:l,t<0||r<0||t>65535||r>65535)throw"x/y invalid.";if(i<=0||a<=0||i>65535||a>65535)throw"Width/Height invalid.";if(d.length256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}(f),m=0;g>>=1;)++m;g=1<3)throw"Disposal out of range.";var v=!1,b=0;if(l.transparent!==n&&null!==l.transparent&&(v=!0,(b=l.transparent)<0||b>=g))throw"Transparent color index.";if((0!==p||v||0!==h)&&(e[o++]=33,e[o++]=249,e[o++]=4,e[o++]=p<<2|(!0===v?1:0),e[o++]=255&h,e[o++]=h>>8&255,e[o++]=b,e[o++]=0),e[o++]=44,e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=255&i,e[o++]=i>>8&255,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=!0===u?128|m-1:0,!0===u)for(var w=0,y=f.length;w>16&255,e[o++]=C>>8&255,e[o++]=255&C}o=function(e,t,r,i){e[t++]=r;var o=t++,a=1<=r;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++)}function m(e){f|=e<=8;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++);4096===d?(m(a),d=c+1,l=r+1,p={}):(d>=1<0&&arguments[0]!==n?arguments[0]:{},r=e.data;delete s.data,s.pixels=Array.prototype.slice.call(r.pixels),s.palette=Array.prototype.slice.call(r.palette),s.done=!0,s.beingProcessed=!1,t.freeWorker(c),t.onFrameFinished(i)};(s=a[e]).beingProcessed||s.done?this.onFrameFinished():(s.sampleInterval=o,s.beingProcessed=!0,s.gifshot=!0,(c=this.getWorker())?(c.onmessage=d,c.postMessage(s)):d({data:t.workerMethods.run(s)}))},startRendering:function(e){this.onRenderCompleteCallback=e;for(var t=0;t=0&&this.processFrame(e)},generateGIF:function(e,t){var r=[],i={loop:this.repeat},n=this.options,o=n.interval,a=n.frameDuration,c=!!n.images.length,d=n.gifHeight,l=n.gifWidth,u=new v(r,l,d,i),f=this.onRenderProgressCallback,g=c?100*o:0,m=void 0;this.generatingGIF=!0,s.each(e,(function(t,r){var i=r.palette;f(.75+.25*r.position*1/e.length);for(var n=0;n0&&arguments[0]!==n?arguments[0]:{},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(e){var t=this;t.startRendering((function(r){t.destroyWorkers(),s.requestTimeout((function(){e(r)}),0)}))},destroyWorkers:function(){if(!this.workerError){var e=this.workers;s.each(e,(function(e,t){var r=t.worker,i=t.objectUrl;r.terminate(),s.URL.revokeObjectURL(i)}))}}};var y=function(){},C={getGIF:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=arguments[1];t=s.isFunction(t)?t:y;var i=r.createElement("canvas"),o=void 0,a=e.images,c=!!a.length,d=e.cameraStream,l=e.crop,u=e.filter,f=e.fontColor,g=e.fontFamily,m=e.fontWeight,h=e.keepCameraOn,p=(e.numWorkers,e.progressCallback),v=e.saveRenderingContexts,b=e.savedRenderingContexts,C=e.text,S=e.textAlign,x=e.textBaseline,O=e.videoElement,k=e.videoHeight,F=e.videoWidth,W=e.webcamVideoElement,E=Number(e.gifWidth),A=Number(e.gifHeight),R=Number(e.interval),T=(Number(e.sampleInterval),c?0:1e3*R),U=[],j=b.length?b.length:e.numFrames,M=j,I=new w(e),P=s.getFontSize(e),V=e.textXCoordinate?e.textXCoordinate:"left"===S?1:"right"===S?E:E/2,L=e.textYCoordinate?e.textYCoordinate:"top"===x?1:"center"===x?A/2:A,H=m+" "+P+" "+g,z=l?Math.floor(l.scaledWidth/2):0,G=l?F-l.scaledWidth:0,B=l?Math.floor(l.scaledHeight/2):0,D=l?k-l.scaledHeight:0,N=function e(){var r=M-1;function i(){var i;v&&U.push(o.getImageData(0,0,E,A)),C&&(o.font=H,o.fillStyle=f,o.textAlign=S,o.textBaseline=x,o.fillText(C,V,L)),i=o.getImageData(0,0,E,A),I.addFrameImageData(i),p((j-(M=r))/j),r>0&&s.requestTimeout(e,T),M||I.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:d,videoElement:O,webcamVideoElement:W,savedRenderingContexts:U,keepCameraOn:h})}))}b.length?(o.putImageData(b[j-M],0,0),i()):function e(){try{G>F&&(G=F),D>k&&(D=k),z<0&&(z=0),B<0&&(B=0),o.filter=u,o.drawImage(O,z,B,G,D,0,0,E,A),i()}catch(t){if("NS_ERROR_NOT_AVAILABLE"!==t.name)throw t;s.requestTimeout(e,100)}}()};j=j!==n?j:10,R=R!==n?R:.1,i.width=E,i.height=A,o=i.getContext("2d"),function e(){b.length||0!==O.currentTime?N():s.requestTimeout(e,100)}()},getCropDimensions:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,o=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(a.width=Math.round(t*(o/r))-i,a.scaledWidth=Math.round(a.width*(r/o))):(a.height=Math.round(r*(i/t))-o,a.scaledHeight=Math.round(a.height*(t/i))),a}},S={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function e(t){e.attempts=e.attempts||0;var r=t.cameraStream,i=t.completedCallback,n=t.videoElement;n&&(n.videoWidth>0&&n.videoHeight>0?(n.removeEventListener("loadeddata",S.findVideoSize),i({videoElement:n,cameraStream:r,videoWidth:n.videoWidth,videoHeight:n.videoHeight})):e.attempts<10?(e.attempts+=1,s.requestTimeout((function(){S.findVideoSize(t)}),400)):i({videoElement:n,cameraStream:r,videoWidth:S.defaultVideoDimensions.width,videoHeight:S.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){s.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=s.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,r=e.cameraStream,i=e.completedCallback,n=e.streamedCallback,o=e.videoElement;if(s.isFunction(n)&&n(),t){if(s.isString(t))o.src=t,o.innerHTML='';else if(t instanceof Blob){try{o.src=s.URL.createObjectURL(t)}catch(e){}o.innerHTML=''}}else if(o.mozSrcObject)o.mozSrcObject=r;else if(s.URL)try{o.srcObject=r,o.src=s.URL.createObjectURL(r)}catch(e){o.srcObject=r}o.play(),s.requestTimeout((function e(){e.count=e.count||0,!0===S.loadedData?(S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}),S.loadedData=!1):(e.count+=1)>10?S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}):e()}),0)},startStreaming:function(e){var t=s.isFunction(e.error)?e.error:s.noop,i=s.isFunction(e.streamed)?e.streamed:s.noop,n=s.isFunction(e.completed)?e.completed:s.noop,o=e.crossOrigin,a=e.existingVideo,c=e.lastCameraStream,d=e.options,l=e.webcamVideoElement,u=s.isElement(a)?a:l||r.createElement("video");o&&(u.crossOrigin=d.crossOrigin),u.autoplay=!0,u.loop=!0,u.muted=!0,u.addEventListener("loadeddata",(function(e){S.loadedData=!0,d.offset&&(u.currentTime=d.offset)})),a?S.stream({videoElement:u,existingVideo:a,completedCallback:n}):c?S.stream({videoElement:u,cameraStream:c,streamedCallback:i,completedCallback:n}):s.getUserMedia({video:!0},(function(e){S.stream({videoElement:u,cameraStream:e,streamedCallback:i,completedCallback:n})}),t)},startVideoStreaming:function(e){var t=arguments.length>1&&arguments[1]!==n?arguments[1]:{},r=t.timeout!==n?t.timeout:0,i=t.callback,o=t.webcamVideoElement,a=void 0;r>0&&(a=s.requestTimeout((function(){S.onStreamingTimeout(i)}),1e4)),S.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){var t=arguments.length>0&&arguments[0]!==n?arguments[0]:{},r=t.cameraStream,i=t.videoElement,o=t.videoHeight,a=t.videoWidth;e({cameraStream:r,videoElement:i,videoHeight:o,videoWidth:a})},lastCameraStream:t.lastCameraStream,webcamVideoElement:o,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){var t=e=s.isObject(e)?e:{},r=t.keepCameraOn,i=t.videoElement,n=t.webcamVideoElement,o=e.cameraStream||{},a=o.getTracks&&o.getTracks()||[],c=!!a.length,d=a[0];!r&&c&&s.isFunction(d.stop)&&d.stop(),s.isElement(i)&&!n&&(i.pause(),s.isFunction(s.URL.revokeObjectURL)&&!s.webWorkerError&&i.src&&s.URL.revokeObjectURL(i.src),s.removeElement(i))}};function x(e){e=s.isObject(e)?e:{},S.stopVideoStreaming(e)}function O(e,t){var i=e.options||{},n=i.images,o=i.video,a=Number(i.gifWidth),c=Number(i.gifHeight),d=(Number(i.numFrames),e.cameraStream),l=e.videoElement,u=e.videoWidth,f=e.videoHeight,g=C.getCropDimensions({videoWidth:u,videoHeight:f,gifHeight:c,gifWidth:a}),m=t;i.crop=g,i.videoElement=l,i.videoWidth=u,i.videoHeight=f,i.cameraStream=d,s.isElement(l)&&(l.width=a+g.width,l.height=c+g.height,i.webcamVideoElement||(s.setCSSAttr(l,{position:"fixed",opacity:"0"}),r.body.appendChild(l)),l.play(),C.getGIF(i,(function(e){n&&n.length||o&&o.length||x(e),m(e)})))}function k(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var i=s.mergeOptions(f,e)||{},o=e.cameraStream,a=i.images,c=a?a.length:0,l=i.video,u=i.webcamVideoElement;i=s.mergeOptions(i,{gifWidth:Math.floor(i.gifWidth),gifHeight:Math.floor(i.gifHeight)}),c?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,i=e.images,o=e.options,a=e.imagesLength,c=d.validate({getUserMedia:!0,"window.URL":!0}),l=[],u=0,f=void 0,g=void 0;if(c.error)return t(c);function m(){s.each(l,(function(e,t){t&&(t.text?g.addFrame(t.img,o,t.text):g.addFrame(t,o))})),function(e,t){e.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})}))}(g,t)}g=new w(o),s.each(i,(function(e,i){var n=i;i.src&&(n=n.src),s.isElement(n)?(o.crossOrigin&&(n.crossOrigin=o.crossOrigin),l[e]=n,(u+=1)===a&&m()):s.isString(n)&&(f=new Image,o.crossOrigin&&(f.crossOrigin=o.crossOrigin),function(r){i.text&&(r.text=i.text),r.onerror=function(e){var r=void 0;if(0===--a)return(r={}).error="None of the requested images was capable of being retrieved",t(r)},r.onload=function(t){i.text?l[e]={img:r,text:r.text}:l[e]=r,(u+=1)===a&&m(),s.removeElement(r)},r.src=n}(f),s.setCSSAttr(f,{position:"fixed",opacity:"0"}),r.body.appendChild(f))}))}({images:a,imagesLength:c,callback:t,options:i}):l?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.existingVideo,i=e.options,o=d.validate({getUserMedia:!0,"window.URL":!0}),a=void 0,c=void 0;if(o.error)return t(o);if(s.isElement(r)&&r.src){if(c=r.src,a=s.getExtension(c),!s.isSupported.videoCodecs[a])return t(d.messages.videoCodecs)}else s.isArray(r)&&s.each(r,(function(e,t){if(a=t instanceof Blob?t.type.substr(t.type.lastIndexOf("/")+1,t.length):t.substr(t.lastIndexOf(".")+1,t.length),s.isSupported.videoCodecs[a])return r=t,!1}));S.startStreaming({completed:function(e){e.options=i||{},O(e,t)},existingVideo:r,crossOrigin:i.crossOrigin,options:i})}({existingVideo:l,callback:t,options:i}):function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.lastCameraStream,i=e.options,o=e.webcamVideoElement;if(!m())return t(d.validate());i.savedRenderingContexts.length?C.getGIF(i,(function(e){t(e)})):S.startVideoStreaming((function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{};e.options=i||{},O(e,t)}),{lastCameraStream:r,callback:t,webcamVideoElement:o,crossOrigin:i.crossOrigin})}({lastCameraStream:o,callback:t,webcamVideoElement:u,options:i})}}var F={utils:c,error:l,defaultOptions:g,createGIF:k,takeSnapShot:function(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var r=s.mergeOptions(f,e);k(s.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),t)}},stopVideoStreaming:x,isSupported:function(){return d.isValid()},isWebCamGIFSupported:m,isExistingVideoGIFSupported:function(e){var t=!1;if(s.isArray(e)&&e.length){if(s.each(e,(function(e,r){s.isSupported.videoCodecs[r]&&(t=!0)})),!t)return!1}else if(s.isString(e)&&e.length&&!s.isSupported.videoCodecs[e])return!1;return d.isValid({getUserMedia:!0})},isExistingImagesGIFSupported:function(){return d.isValid({getUserMedia:!0})},VERSION:"0.4.5"};"function"==typeof n&&n.amd?n([],(function(){return F})):e.exports=F}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{})})),i=t((function(e){var t;t=function(){return function(e,t,r){t=t||"",r=r||512;for(var i=atob(e),n=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;y=!0,f.show=!0,e.emit("artplayerPluginGif:start"),d.show=c.get("Start creating gif..."),r.createGIF(o({},t,{video:[v.src],crossOrigin:"anonymous"}),(function(t){if(t.error)d.show=t.errorMsg,n(!1,t.errorMsg);else if("function"==typeof a){var r=t.image.split(",")[1],o=i(r,"image/gif"),s=URL.createObjectURL(o);d.show=c.get("Create gif successfully"),e.emit("artplayerPluginGif",s),a(s)}y=!1,f.show=!1,e.emit("artplayerPluginGif:end")}))}}}})); diff --git a/dist/artplayer-plugin-playlist.js b/dist/artplayer-plugin-playlist.js index 1ce43b5f7..1ca694d37 100644 --- a/dist/artplayer-plugin-playlist.js +++ b/dist/artplayer-plugin-playlist.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).artplayerPluginPlaylist=n()}(this,(function(){"use strict";return function(t){return function(n){var e=n.constructor.utils,i=e.append,r=e.errorHandle,a=e.sleep,l=e.inverseClass,o=n.player,s=n.events.proxy,u=n.template,c=u.$player,f=u.$video,d=i(c,'
');r(Array.isArray(t),"Playlist is not an array type"),r(t.length>0,"Playlist cannot be empty");var y=t.map((function(t){return r(t.url,"Playlist items require url attribute"),r(t.title,"Playlist items require title attribute"),t})),p=d.querySelector(".art-playlist-inner");function v(t){var e=y[t];return o.switchUrl(e.url,e.title).then((function(){n.emit("artplayerPluginPlaylist:change",e)}))}function h(){var t=y.findIndex((function(t){return t.url===f.src}));return r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t+1===y.length?0:t+1)}return p.innerHTML=y.map((function(t,n){return'
').concat(t.title,"
")})).join(""),s(p,"click",(function(t){var n=t.target.dataset.optionIndex;n&&Number(n)<=y.length-1&&v(n)})),s(d,"click",(function(t){t.target===d&&c.classList.remove("art-playlist-show")})),n.on("video:ended",(function(){h().then((function(){a(1e3).then((function(){o.play=!0}))}))})),n.on("afterAttachUrl",(function(){var t=y.findIndex((function(t){return t.url===f.src})),n=Array.from(p.children)[t];-1!==t&&n&&l(n,"active")})),{name:"artplayerPluginPlaylist",show:function(){c.classList.add("art-playlist-show")},hide:function(){c.classList.remove("art-playlist-show")},next:function(){h()},prev:function(){var t;t=y.findIndex((function(t){return t.url===f.src})),r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t-1==-1?y.length-1:t-1)}}}}})); +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).artplayerPluginPlaylist=n()}(this,(function(){"use strict";return function(t){return function(n){var e=n.constructor.utils,i=e.append,r=e.errorHandle,a=e.sleep,l=e.inverseClass,o=n.player,s=n.events.proxy,u=n.template,c=u.$player,f=u.$video,d=i(c,'
');r(Array.isArray(t),"Playlist is not an array type"),r(t.length>0,"Playlist cannot be empty");var y=t.map((function(t){return r(t.url,"Playlist items require url attribute"),r(t.title,"Playlist items require title attribute"),t})),p=d.querySelector(".art-playlist-inner");function v(t){var e=y[t],i=o.playing;return o.switchUrl(e.url,e.title).then((function(){i&&(o.play=!0),n.emit("artplayerPluginPlaylist:change",e)}))}function h(){var t=y.findIndex((function(t){return t.url===f.src}));return r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t+1===y.length?0:t+1)}return p.innerHTML=y.map((function(t,n){return'
').concat(t.title,"
")})).join(""),s(p,"click",(function(t){var n=t.target.dataset.optionIndex;n&&Number(n)<=y.length-1&&v(n)})),s(d,"click",(function(t){t.target===d&&c.classList.remove("art-playlist-show")})),n.on("video:ended",(function(){h().then((function(){a(1e3).then((function(){o.play=!0}))}))})),n.on("afterAttachUrl",(function(){var t=y.findIndex((function(t){return t.url===f.src})),n=Array.from(p.children)[t];-1!==t&&n&&l(n,"active")})),{name:"artplayerPluginPlaylist",show:function(){c.classList.add("art-playlist-show")},hide:function(){c.classList.remove("art-playlist-show")},next:function(){h()},prev:function(){var t;t=y.findIndex((function(t){return t.url===f.src})),r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t-1==-1?y.length-1:t-1)}}}}})); diff --git a/dist/artplayer-react.css b/dist/artplayer-react.css new file mode 100644 index 000000000..b21abf5ef --- /dev/null +++ b/dist/artplayer-react.css @@ -0,0 +1,19 @@ +.art-video-player{display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;margin:0 auto;z-index:10;width:100%;height:100%;outline:0;zoom:1;font-family:Roboto,Arial,Helvetica,sans-serif;color:#eee;text-align:left;direction:ltr;font-size:14px;line-height:1.3;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-ms-touch-action:manipulation;touch-action:manipulation;-ms-high-contrast-adjust:none}.art-video-player *{margin:0;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}.art-video-player ::-webkit-scrollbar{width:5px}.art-video-player ::-webkit-scrollbar-thumb{background-color:#666}.art-video-player ::-webkit-scrollbar-thumb:hover{background-color:#ccc}.art-video-player .art-icon{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:1.5}.art-video-player .art-icon svg{fill:#fff}.art-video-player img{max-width:100%;vertical-align:top}.art-video-player>object{display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1}@supports ((-webkit-backdrop-filter:initial) or (backdrop-filter:initial)){.art-video-player .art-backdrop-filter{-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);background-color:rgba(0,0,0,.7)!important}} +.art-video-player .art-video{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;width:100%;height:100%;background-color:#000;cursor:pointer} +.art-video-player .art-subtitle{display:none;position:absolute;z-index:20;bottom:40px;width:100%;padding:0 20px;text-align:center;color:#fff;font-size:20px;pointer-events:none;text-shadow:.5px .5px .5px rgba(0,0,0,.5)}.art-video-player .art-subtitle p{margin:5px 0}.art-video-player.art-subtitle-show .art-subtitle{display:block} +.art-video-player .art-danmuku{position:absolute;z-index:30;left:0;top:0;right:0;bottom:0;width:100%;height:100%;overflow:hidden;pointer-events:none} +.art-video-player .art-layers{display:none;position:absolute;z-index:40;left:0;top:0;right:0;bottom:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.art-video-player .art-layers .art-layer{pointer-events:auto}.art-video-player.art-layer-show .art-layers{display:block} +.art-video-player .art-mask{display:none;z-index:50;left:0;top:0;right:0;bottom:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.art-video-player .art-mask,.art-video-player .art-mask .art-state{-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;position:absolute}.art-video-player .art-mask .art-state{right:30px;bottom:55px;width:60px;height:60px;opacity:.6}.art-video-player.art-mask-show .art-mask,.art-video-player .art-mask .art-state{display:-webkit-box;display:-ms-flexbox;display:flex} +.art-video-player .art-loading{display:none;position:absolute;z-index:70;left:0;top:0;right:0;bottom:0;width:100%;height:100%;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;pointer-events:none}.art-video-player.art-loading-show .art-loading{display:-webkit-box;display:-ms-flexbox;display:flex} +.art-video-player .art-bottom{position:absolute;z-index:60;left:0;right:0;bottom:0;height:100px;padding:55px 10px 0;opacity:0;visibility:hidden;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out;pointer-events:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==) repeat-x bottom}.art-video-player .art-bottom .art-progress{position:relative;pointer-events:auto}.art-video-player .art-bottom .art-progress .art-control-progress{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:4px;cursor:pointer}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner{position:relative;height:50%;width:100%;background:hsla(0,0%,100%,.2)}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-loaded{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;height:100%;width:0;background:hsla(0,0%,100%,.4)}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-played{position:absolute;z-index:20;left:0;top:0;right:0;bottom:0;height:100%;width:0}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-highlight{position:absolute;z-index:30;left:0;top:0;right:0;bottom:0;height:100%;pointer-events:none}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-highlight span{display:inline-block;position:absolute;left:0;top:0;width:7px;height:100%;background:#fff;pointer-events:auto}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-indicator{display:none;position:absolute;z-index:40;top:-5px;left:-6.5px;width:13px;height:13px;border-radius:50%}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-indicator.art-show-indicator{display:block}.art-video-player .art-bottom .art-progress .art-control-progress .art-control-progress-inner .art-progress-tip{display:none;position:absolute;z-index:50;top:-25px;left:0;height:20px;padding:0 5px;line-height:20px;color:#fff;font-size:12px;text-align:center;background:rgba(0,0,0,.7);border-radius:3px;font-weight:700;white-space:nowrap}.art-video-player .art-bottom .art-progress .art-control-progress:hover .art-control-progress-inner{height:100%}.art-video-player .art-bottom .art-progress .art-control-progress:hover .art-control-progress-inner .art-progress-indicator,.art-video-player .art-bottom .art-progress .art-control-progress:hover .art-control-progress-inner .art-progress-tip{display:block}.art-video-player .art-bottom .art-progress .art-control-thumbnails{display:none;position:absolute;bottom:8px;left:0;pointer-events:none;background-color:rgba(0,0,0,.7)}.art-video-player .art-bottom .art-controls{position:relative;pointer-events:auto;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;height:40px;padding:5px 0}.art-video-player .art-bottom .art-controls,.art-video-player .art-bottom .art-controls .art-controls-left,.art-video-player .art-bottom .art-controls .art-controls-right{display:-webkit-box;display:-ms-flexbox;display:flex}.art-video-player .art-bottom .art-controls .art-control{opacity:.9;font-size:12px;height:36px;min-width:36px;line-height:36px;text-align:center;cursor:pointer}.art-video-player .art-bottom .art-controls .art-control .art-icon{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;float:left;height:36px;width:36px}.art-video-player .art-bottom .art-controls .art-control:hover{opacity:1}.art-video-player .art-bottom .art-controls .art-control-onlyText{padding:0 10px}.art-video-player .art-bottom .art-controls .art-control-volume .art-volume-panel{position:relative;float:left;width:0;height:100%;-webkit-transition:margin .2s cubic-bezier(.4,0,1,1),width .2s cubic-bezier(.4,0,1,1);transition:margin .2s cubic-bezier(.4,0,1,1),width .2s cubic-bezier(.4,0,1,1);overflow:hidden}.art-video-player .art-bottom .art-controls .art-control-volume .art-volume-panel .art-volume-slider-handle{position:absolute;top:50%;left:0;width:12px;height:12px;border-radius:12px;margin-top:-6px;background:#fff}.art-video-player .art-bottom .art-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:before{left:-54px;background:#fff}.art-video-player .art-bottom .art-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:after{left:6px;background:hsla(0,0%,100%,.2)}.art-video-player .art-bottom .art-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:after,.art-video-player .art-bottom .art-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:before{content:"";position:absolute;display:block;top:50%;height:3px;margin-top:-2px;width:60px}.art-video-player .art-bottom .art-controls .art-control-volume:hover .art-volume-panel{width:60px}.art-video-player .art-bottom .art-controls .art-control-quality{position:relative;z-index:30}.art-video-player .art-bottom .art-controls .art-control-quality .art-qualitys{display:none;position:absolute;bottom:35px;width:100px;padding:5px 0;text-align:center;color:#fff;background:rgba(0,0,0,.8);border-radius:3px}.art-video-player .art-bottom .art-controls .art-control-quality .art-qualitys .art-quality-item{height:30px;line-height:30px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 0 2px rgba(0,0,0,.5)}.art-video-player .art-bottom .art-controls .art-control-quality .art-qualitys .art-quality-item:hover{background-color:hsla(0,0%,100%,.1)}.art-video-player .art-bottom .art-controls .art-control-quality:hover .art-qualitys{display:block}.art-video-player.art-control-show .art-bottom,.art-video-player.art-hover .art-bottom{opacity:1;visibility:visible}.art-video-player.art-destroy .art-progress-indicator,.art-video-player.art-destroy .art-progress-tip,.art-video-player.art-error .art-progress-indicator,.art-video-player.art-error .art-progress-tip{display:none!important} +.art-video-player .art-notice{display:none;font-size:14px;position:absolute;z-index:80;left:0;top:0;padding:10px;width:100%;pointer-events:none}.art-video-player .art-notice .art-notice-inner{display:inline-block;padding:5px 10px;color:#fff;background:rgba(0,0,0,.6);border-radius:3px}.art-video-player.art-notice-show .art-notice{display:-webkit-box;display:-ms-flexbox;display:flex} +.art-video-player .art-contextmenus{display:none;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;position:absolute;z-index:120;left:0;top:0;min-width:200px;padding:5px 0;background:rgba(0,0,0,.8);border-radius:3px}.art-video-player .art-contextmenus .art-contextmenu{cursor:pointer;font-size:13px;display:block;color:#fff;padding:7px 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 0 2px rgba(0,0,0,.5);border-bottom:1px solid hsla(0,0%,100%,.1)}.art-video-player .art-contextmenus .art-contextmenu a{color:#fff;text-decoration:none}.art-video-player .art-contextmenus .art-contextmenu span{display:inline-block;padding:0 7px}.art-video-player .art-contextmenus .art-contextmenu span.art-current,.art-video-player .art-contextmenus .art-contextmenu span:hover{color:#00c9ff}.art-video-player .art-contextmenus .art-contextmenu:hover{background-color:hsla(0,0%,100%,.1)}.art-video-player .art-contextmenus .art-contextmenu:last-child{border-bottom:none}.art-video-player.art-contextmenu-show .art-contextmenus{display:-webkit-box;display:-ms-flexbox;display:flex} +.art-video-player .art-settings{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;position:absolute;z-index:90;left:0;top:0;height:100%;width:100%;opacity:0;visibility:hidden;pointer-events:none;overflow:hidden}.art-video-player .art-settings .art-setting-inner{position:absolute;top:0;right:-300px;bottom:0;width:300px;height:100%;font-size:12px;background:rgba(0,0,0,.8);-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out;overflow:auto}.art-video-player .art-settings .art-setting-inner .art-setting-body{overflow-y:auto;width:100%;height:100%}.art-video-player .art-settings .art-setting-inner .art-setting-body .art-setting{border-bottom:1px solid hsla(0,0%,100%,.1);padding:10px 15px}.art-video-player .art-settings .art-setting-inner .art-setting-body .art-setting .art-setting-header{margin-bottom:5px}.art-video-player .art-settings .art-setting-radio{display:-webkit-box;display:-ms-flexbox;display:flex}.art-video-player .art-settings .art-setting-radio .art-radio-item{-webkit-box-flex:1;-ms-flex:1;flex:1;padding:0 2px}.art-video-player .art-settings .art-setting-radio .art-radio-item button{height:22px;width:100%;border:none;outline:none;color:#fff;background:hsla(0,0%,100%,.2);border-radius:2px}.art-video-player .art-settings .art-setting-radio .art-radio-item.current button{background-color:#00a1d6}.art-video-player .art-settings .art-setting-range input{width:100%;height:3px;outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:hsla(0,0%,100%,.5)}.art-video-player .art-settings .art-setting-checkbox input{height:14px;width:14px;margin-right:5px}.art-video-player .art-settings .art-setting-upload{display:-webkit-box;display:-ms-flexbox;display:flex}.art-video-player .art-settings .art-setting-upload .art-upload-btn{width:80px;height:22px;line-height:22px;border:none;outline:none;color:#fff;background:hsla(0,0%,100%,.2);border-radius:2px;text-align:center}.art-video-player .art-settings .art-setting-upload .art-upload-value{-webkit-box-flex:1;-ms-flex:1;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;height:22px;line-height:22px;padding-left:10px}.art-video-player.art-setting-show .art-settings{opacity:1;visibility:visible;pointer-events:auto}.art-video-player.art-setting-show .art-settings .art-setting-inner{right:0} +.art-video-player .art-info{display:none;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;position:absolute;left:10px;top:10px;z-index:100;width:350px;min-height:150px;padding:10px;color:#fff;font-size:12px;font-family:Noto Sans CJK SC DemiLight,Roboto,Segoe UI,Tahoma,Arial,Helvetica,sans-serif;-webkit-font-smoothing:antialiased;background:rgba(0,0,0,.7)}.art-video-player .art-info .art-info-item{display:-webkit-box;display:-ms-flexbox;display:flex;margin-bottom:5px}.art-video-player .art-info .art-info-item .art-info-title{width:100px;text-align:right}.art-video-player .art-info .art-info-item .art-info-content{-webkit-box-flex:1;-ms-flex:1;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:5px}.art-video-player .art-info .art-info-close{position:absolute;top:5px;right:5px;cursor:pointer}.art-video-player.art-info-show .art-info{display:-webkit-box;display:-ms-flexbox;display:flex} +.art-video-player.art-hide-cursor *{cursor:none!important} +.art-video-player[data-aspect-ratio] video{-webkit-box-sizing:content-box;box-sizing:content-box;-o-object-fit:fill;object-fit:fill} +.art-video-player.art-web-fullscreen{position:fixed;z-index:9999;width:100%;height:100%;left:0;top:0;right:0;bottom:0} +.art-video-player .art-pip-header{display:none;position:absolute;z-index:110;left:0;top:0;right:0;height:35px;line-height:35px;color:#fff;background:rgba(0,0,0,.5);-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;opacity:0;visibility:hidden;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.art-video-player .art-pip-header .art-pip-title{-webkit-box-flex:1;-ms-flex:1;flex:1;padding:0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:move}.art-video-player .art-pip-header .art-pip-close{width:35px;text-align:center;font-size:22px;cursor:pointer}.art-video-player.art-is-dragging{opacity:.7}.art-video-player.art-pip{position:fixed;z-index:9999;width:400px;height:225px;-webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,.16),0 3px 6px 0 rgba(0,0,0,.2);box-shadow:0 2px 5px 0 rgba(0,0,0,.16),0 3px 6px 0 rgba(0,0,0,.2)}.art-video-player.art-pip .art-pip-header{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.art-video-player.art-pip.art-hover .art-pip-header{opacity:1;visibility:visible}.art-video-player.art-pip .art-mask .art-state{position:static}.art-video-player.art-pip .art-bottom,.art-video-player.art-pip .art-contextmenu,.art-video-player.art-pip .art-danmu,.art-video-player.art-pip .art-info,.art-video-player.art-pip .art-layers,.art-video-player.art-pip .art-notice,.art-video-player.art-pip .art-setting,.art-video-player.art-pip .art-subtitle{display:none!important} +.art-auto-size{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center} +.art-video-player[data-flip=horizontal] .art-video{-webkit-transform:scaleX(-1);transform:scaleX(-1)}.art-video-player[data-flip=vertical] .art-video{-webkit-transform:scaleY(-1);transform:scaleY(-1)} +:root{--balloon-color:rgba(16,16,16,0.95);--balloon-font-size:12px;--balloon-move:4px}button[aria-label][data-balloon-pos]{overflow:visible}[aria-label][data-balloon-pos]{position:relative;cursor:pointer}[aria-label][data-balloon-pos]:after{text-indent:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;font-weight:400;font-style:normal;text-shadow:none;font-size:var(--balloon-font-size);background:var(--balloon-color);border-radius:2px;color:#fff;content:attr(aria-label);padding:.5em 1em;white-space:nowrap;line-height:1.2}[aria-label][data-balloon-pos]:after,[aria-label][data-balloon-pos]:before{opacity:0;pointer-events:none;-webkit-transition:all .18s ease-out .18s;transition:all .18s ease-out .18s;position:absolute;z-index:10}[aria-label][data-balloon-pos]:before{width:0;height:0;border:5px solid transparent;border-top:5px solid var(--balloon-color);content:""}[aria-label][data-balloon-pos]:hover:after,[aria-label][data-balloon-pos]:hover:before{opacity:1;pointer-events:none}[aria-label][data-balloon-pos][data-balloon-pos=up]:after{margin-bottom:10px}[aria-label][data-balloon-pos][data-balloon-pos=up]:after,[aria-label][data-balloon-pos][data-balloon-pos=up]:before{bottom:100%;left:50%;-webkit-transform:translate(-50%,var(--balloon-move));transform:translate(-50%,var(--balloon-move));-webkit-transform-origin:top;transform-origin:top}[aria-label][data-balloon-pos][data-balloon-pos=up]:hover:after,[aria-label][data-balloon-pos][data-balloon-pos=up]:hover:before{-webkit-transform:translate(-50%);transform:translate(-50%)} \ No newline at end of file diff --git a/packages/artplayer-plugin-gif/dist/artplayer-plugin-gif.js b/packages/artplayer-plugin-gif/dist/artplayer-plugin-gif.js index 2ca13b953..b99b3a634 100644 --- a/packages/artplayer-plugin-gif/dist/artplayer-plugin-gif.js +++ b/packages/artplayer-plugin-gif/dist/artplayer-plugin-gif.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).artplayerPluginGif=t()}(this,(function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t((function(e,t){!function(t,r,i,n){var o,a,s={URL:t.URL||t.webkitURL||t.mozURL||t.msURL,getUserMedia:(a=i.getUserMedia||i.webkitGetUserMedia||i.mozGetUserMedia||i.msGetUserMedia,a?a.bind(i):a),requestAnimFrame:t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame,requestTimeout:function(e,t){if(e=e||s.noop,t=t||0,!s.requestAnimFrame)return setTimeout(e,t);var r=(new Date).getTime(),i=new Object,n=s.requestAnimFrame;return i.value=n((function o(){(new Date).getTime()-r>=t?e.call():i.value=n(o)})),i},Blob:t.Blob||t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,btoa:(o=t.btoa||function(e){for(var t="",r=0,i=e.length,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=void 0,a=void 0,s=void 0,c=void 0,d=void 0,l=void 0,u=void 0;r>2,d=(3&o)<<4|(a=e.charCodeAt(r++))>>4,l=(15&a)<<2|(s=e.charCodeAt(r++))>>6,u=63&s,isNaN(a)?l=u=64:isNaN(s)&&(u=64),t=t+n.charAt(c)+n.charAt(d)+n.charAt(l)+n.charAt(u);return t},o?o.bind(t):s.noop),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return s.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=r.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return t.Worker},blob:function(){return s.Blob},Uint8Array:function(){return t.Uint8Array},Uint32Array:function(){return t.Uint32Array},videoCodecs:function(){var e=r.createElement("video"),t={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(t.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),t.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),t.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),t.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),t.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(e){}return t}()},noop:function(){},each:function(e,t){var r=void 0,i=void 0;if(s.isArray(e))for(r=-1,i=e.length;++r0&&arguments[0]!==n?arguments[0]:{};if(!r.body||!1===e.resizeFont)return e.fontSize;var t=e.text,i=e.gifWidth,o=parseInt(e.fontSize,10),a=parseInt(e.minFontSize,10),s=r.createElement("div"),c=r.createElement("span");for(s.setAttribute("width",i),s.appendChild(c),c.innerHTML=t,c.style.fontSize=o+"px",c.style.textIndent="-9999px",c.style.visibility="hidden",r.body.appendChild(c);c.offsetWidth>i&&o>=a;)c.style.fontSize=--o+"px";return r.body.removeChild(c),o+"px"},webWorkerError:!1},c=Object.freeze({default:s}),d={validate:function(e){e=s.isObject(e)?e:{};var t={};return s.each(d.validators,(function(r,i){var n=i.errorCode;if(!e[n]&&!i.condition)return(t=i).error=!0,!1})),delete t.condition,t},isValid:function(e){var t=!0!==d.validate(e).error;return t},validators:[{condition:s.isFunction(s.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:s.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:s.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:s.isFunction(s.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:s.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:s.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:s.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"}}},l=Object.freeze({default:d}),u=function(){},f={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,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:u,completeCallback:u,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},g=Object.freeze({default:f});function m(){return d.isValid()}function h(){var e,t,r,i,n,o=256,a=499,s=491,c=487,d=503,l=3*d,u=o-1,f=4,g=100,m=16,h=1<>v,w=h<>3)*(1<o&&(l=o),s=t+1,c=t-1,f=1;sd;){if(u=A[f++],sd){g=n[c--];try{g[0]-=u*(g[0]-r)/k|0,g[1]-=u*(g[1]-i)/k|0,g[2]-=u*(g[2]-a)/k|0}catch(e){}}}}function T(e,t,r,i,o){var a=n[t],s=e/x;a[0]-=s*(a[0]-r)|0,a[1]-=s*(a[1]-i)|0,a[2]-=s*(a[2]-o)|0}function U(e,t,r){var i,a,s,c,d,l,u,g,h,y;for(h=g=~(1<<31),u=l=-1,i=0;i>m-f))>v,E[i]-=d,W[i]+=d<=0;)i=d?i=o:(i++,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)=0&&((s=t-(l=n[a])[1])>=d?a=-1:(a--,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)>y)<=1&&(v=0),n=0;n=j&&(E-=r),0===k&&(k=1),++n%k==0)for(b-=b/e,(v=(p-=p/S)>>y)<=1&&(v=0),o=0;o>=f,n[e][1]>>=f,n[e][2]>>=f,n[e][3]=e}(),function(){var e,t,r,i,a,s,c,d;for(c=0,d=0,e=0;e>1,t=c+1;t>1,t=c+1;t<256;t++)F[t]=u}(),function(){for(var e=[],t=new Array(o),r=0;r65535||r>65535)throw"Width/Height invalid.";e[o++]=71,e[o++]=73,e[o++]=70,e[o++]=56,e[o++]=57,e[o++]=97;if(e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=0|(null!==s?128:0),e[o++]=0,e[o++]=0,null!==a){if(a<0||a>65535)throw"Loop count invalid.";e[o++]=33,e[o++]=255,e[o++]=11,e[o++]=78,e[o++]=69,e[o++]=84,e[o++]=83,e[o++]=67,e[o++]=65,e[o++]=80,e[o++]=69,e[o++]=50,e[o++]=46,e[o++]=48,e[o++]=3,e[o++]=1,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=0}var c=!1;this.addFrame=function(t,r,i,a,d,l){if(!0===c&&(--o,c=!1),l=l===n?{}:l,t<0||r<0||t>65535||r>65535)throw"x/y invalid.";if(i<=0||a<=0||i>65535||a>65535)throw"Width/Height invalid.";if(d.length256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}(f),m=0;g>>=1;)++m;g=1<3)throw"Disposal out of range.";var v=!1,b=0;if(l.transparent!==n&&null!==l.transparent&&(v=!0,(b=l.transparent)<0||b>=g))throw"Transparent color index.";if((0!==p||v||0!==h)&&(e[o++]=33,e[o++]=249,e[o++]=4,e[o++]=p<<2|(!0===v?1:0),e[o++]=255&h,e[o++]=h>>8&255,e[o++]=b,e[o++]=0),e[o++]=44,e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=255&i,e[o++]=i>>8&255,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=!0===u?128|m-1:0,!0===u)for(var w=0,y=f.length;w>16&255,e[o++]=C>>8&255,e[o++]=255&C}o=function(e,t,r,i){e[t++]=r;var o=t++,a=1<=r;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++)}function m(e){f|=e<=8;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++);4096===d?(m(a),d=c+1,l=r+1,p={}):(d>=1<0&&arguments[0]!==n?arguments[0]:{},r=e.data;delete s.data,s.pixels=Array.prototype.slice.call(r.pixels),s.palette=Array.prototype.slice.call(r.palette),s.done=!0,s.beingProcessed=!1,t.freeWorker(c),t.onFrameFinished(i)};(s=a[e]).beingProcessed||s.done?this.onFrameFinished():(s.sampleInterval=o,s.beingProcessed=!0,s.gifshot=!0,(c=this.getWorker())?(c.onmessage=d,c.postMessage(s)):d({data:t.workerMethods.run(s)}))},startRendering:function(e){this.onRenderCompleteCallback=e;for(var t=0;t=0&&this.processFrame(e)},generateGIF:function(e,t){var r=[],i={loop:this.repeat},n=this.options,o=n.interval,a=n.frameDuration,c=!!n.images.length,d=n.gifHeight,l=n.gifWidth,u=new v(r,l,d,i),f=this.onRenderProgressCallback,g=c?100*o:0,m=void 0;this.generatingGIF=!0,s.each(e,(function(t,r){var i=r.palette;f(.75+.25*r.position*1/e.length);for(var n=0;n0&&arguments[0]!==n?arguments[0]:{},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(e){var t=this;t.startRendering((function(r){t.destroyWorkers(),s.requestTimeout((function(){e(r)}),0)}))},destroyWorkers:function(){if(!this.workerError){var e=this.workers;s.each(e,(function(e,t){var r=t.worker,i=t.objectUrl;r.terminate(),s.URL.revokeObjectURL(i)}))}}};var y=function(){},C={getGIF:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=arguments[1];t=s.isFunction(t)?t:y;var i=r.createElement("canvas"),o=void 0,a=e.images,c=!!a.length,d=e.cameraStream,l=e.crop,u=e.filter,f=e.fontColor,g=e.fontFamily,m=e.fontWeight,h=e.keepCameraOn,p=(e.numWorkers,e.progressCallback),v=e.saveRenderingContexts,b=e.savedRenderingContexts,C=e.text,S=e.textAlign,x=e.textBaseline,O=e.videoElement,k=e.videoHeight,F=e.videoWidth,W=e.webcamVideoElement,E=Number(e.gifWidth),A=Number(e.gifHeight),R=Number(e.interval),T=(Number(e.sampleInterval),c?0:1e3*R),U=[],j=b.length?b.length:e.numFrames,M=j,I=new w(e),P=s.getFontSize(e),V=e.textXCoordinate?e.textXCoordinate:"left"===S?1:"right"===S?E:E/2,L=e.textYCoordinate?e.textYCoordinate:"top"===x?1:"center"===x?A/2:A,H=m+" "+P+" "+g,z=l?Math.floor(l.scaledWidth/2):0,G=l?F-l.scaledWidth:0,B=l?Math.floor(l.scaledHeight/2):0,D=l?k-l.scaledHeight:0,N=function e(){var r=M-1;function i(){var i;v&&U.push(o.getImageData(0,0,E,A)),C&&(o.font=H,o.fillStyle=f,o.textAlign=S,o.textBaseline=x,o.fillText(C,V,L)),i=o.getImageData(0,0,E,A),I.addFrameImageData(i),p((j-(M=r))/j),r>0&&s.requestTimeout(e,T),M||I.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:d,videoElement:O,webcamVideoElement:W,savedRenderingContexts:U,keepCameraOn:h})}))}b.length?(o.putImageData(b[j-M],0,0),i()):function e(){try{G>F&&(G=F),D>k&&(D=k),z<0&&(z=0),B<0&&(B=0),o.filter=u,o.drawImage(O,z,B,G,D,0,0,E,A),i()}catch(t){if("NS_ERROR_NOT_AVAILABLE"!==t.name)throw t;s.requestTimeout(e,100)}}()};j=j!==n?j:10,R=R!==n?R:.1,i.width=E,i.height=A,o=i.getContext("2d"),function e(){b.length||0!==O.currentTime?N():s.requestTimeout(e,100)}()},getCropDimensions:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,o=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(a.width=Math.round(t*(o/r))-i,a.scaledWidth=Math.round(a.width*(r/o))):(a.height=Math.round(r*(i/t))-o,a.scaledHeight=Math.round(a.height*(t/i))),a}},S={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function e(t){e.attempts=e.attempts||0;var r=t.cameraStream,i=t.completedCallback,n=t.videoElement;n&&(n.videoWidth>0&&n.videoHeight>0?(n.removeEventListener("loadeddata",S.findVideoSize),i({videoElement:n,cameraStream:r,videoWidth:n.videoWidth,videoHeight:n.videoHeight})):e.attempts<10?(e.attempts+=1,s.requestTimeout((function(){S.findVideoSize(t)}),400)):i({videoElement:n,cameraStream:r,videoWidth:S.defaultVideoDimensions.width,videoHeight:S.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){s.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=s.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,r=e.cameraStream,i=e.completedCallback,n=e.streamedCallback,o=e.videoElement;if(s.isFunction(n)&&n(),t){if(s.isString(t))o.src=t,o.innerHTML='';else if(t instanceof Blob){try{o.src=s.URL.createObjectURL(t)}catch(e){}o.innerHTML=''}}else if(o.mozSrcObject)o.mozSrcObject=r;else if(s.URL)try{o.srcObject=r,o.src=s.URL.createObjectURL(r)}catch(e){o.srcObject=r}o.play(),s.requestTimeout((function e(){e.count=e.count||0,!0===S.loadedData?(S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}),S.loadedData=!1):(e.count+=1)>10?S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}):e()}),0)},startStreaming:function(e){var t=s.isFunction(e.error)?e.error:s.noop,i=s.isFunction(e.streamed)?e.streamed:s.noop,n=s.isFunction(e.completed)?e.completed:s.noop,o=e.crossOrigin,a=e.existingVideo,c=e.lastCameraStream,d=e.options,l=e.webcamVideoElement,u=s.isElement(a)?a:l||r.createElement("video");o&&(u.crossOrigin=d.crossOrigin),u.autoplay=!0,u.loop=!0,u.muted=!0,u.addEventListener("loadeddata",(function(e){S.loadedData=!0,d.offset&&(u.currentTime=d.offset)})),a?S.stream({videoElement:u,existingVideo:a,completedCallback:n}):c?S.stream({videoElement:u,cameraStream:c,streamedCallback:i,completedCallback:n}):s.getUserMedia({video:!0},(function(e){S.stream({videoElement:u,cameraStream:e,streamedCallback:i,completedCallback:n})}),t)},startVideoStreaming:function(e){var t=arguments.length>1&&arguments[1]!==n?arguments[1]:{},r=t.timeout!==n?t.timeout:0,i=t.callback,o=t.webcamVideoElement,a=void 0;r>0&&(a=s.requestTimeout((function(){S.onStreamingTimeout(i)}),1e4)),S.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){var t=arguments.length>0&&arguments[0]!==n?arguments[0]:{},r=t.cameraStream,i=t.videoElement,o=t.videoHeight,a=t.videoWidth;e({cameraStream:r,videoElement:i,videoHeight:o,videoWidth:a})},lastCameraStream:t.lastCameraStream,webcamVideoElement:o,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){var t=e=s.isObject(e)?e:{},r=t.keepCameraOn,i=t.videoElement,n=t.webcamVideoElement,o=e.cameraStream||{},a=o.getTracks&&o.getTracks()||[],c=!!a.length,d=a[0];!r&&c&&s.isFunction(d.stop)&&d.stop(),s.isElement(i)&&!n&&(i.pause(),s.isFunction(s.URL.revokeObjectURL)&&!s.webWorkerError&&i.src&&s.URL.revokeObjectURL(i.src),s.removeElement(i))}};function x(e){e=s.isObject(e)?e:{},S.stopVideoStreaming(e)}function O(e,t){var i=e.options||{},n=i.images,o=i.video,a=Number(i.gifWidth),c=Number(i.gifHeight),d=(Number(i.numFrames),e.cameraStream),l=e.videoElement,u=e.videoWidth,f=e.videoHeight,g=C.getCropDimensions({videoWidth:u,videoHeight:f,gifHeight:c,gifWidth:a}),m=t;i.crop=g,i.videoElement=l,i.videoWidth=u,i.videoHeight=f,i.cameraStream=d,s.isElement(l)&&(l.width=a+g.width,l.height=c+g.height,i.webcamVideoElement||(s.setCSSAttr(l,{position:"fixed",opacity:"0"}),r.body.appendChild(l)),l.play(),C.getGIF(i,(function(e){n&&n.length||o&&o.length||x(e),m(e)})))}function k(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var i=s.mergeOptions(f,e)||{},o=e.cameraStream,a=i.images,c=a?a.length:0,l=i.video,u=i.webcamVideoElement;i=s.mergeOptions(i,{gifWidth:Math.floor(i.gifWidth),gifHeight:Math.floor(i.gifHeight)}),c?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,i=e.images,o=e.options,a=e.imagesLength,c=d.validate({getUserMedia:!0,"window.URL":!0}),l=[],u=0,f=void 0,g=void 0;if(c.error)return t(c);function m(){s.each(l,(function(e,t){t&&(t.text?g.addFrame(t.img,o,t.text):g.addFrame(t,o))})),function(e,t){e.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})}))}(g,t)}g=new w(o),s.each(i,(function(e,i){var n=i;i.src&&(n=n.src),s.isElement(n)?(o.crossOrigin&&(n.crossOrigin=o.crossOrigin),l[e]=n,(u+=1)===a&&m()):s.isString(n)&&(f=new Image,o.crossOrigin&&(f.crossOrigin=o.crossOrigin),function(r){i.text&&(r.text=i.text),r.onerror=function(e){var r=void 0;if(0===--a)return(r={}).error="None of the requested images was capable of being retrieved",t(r)},r.onload=function(t){i.text?l[e]={img:r,text:r.text}:l[e]=r,(u+=1)===a&&m(),s.removeElement(r)},r.src=n}(f),s.setCSSAttr(f,{position:"fixed",opacity:"0"}),r.body.appendChild(f))}))}({images:a,imagesLength:c,callback:t,options:i}):l?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.existingVideo,i=e.options,o=d.validate({getUserMedia:!0,"window.URL":!0}),a=void 0,c=void 0;if(o.error)return t(o);if(s.isElement(r)&&r.src){if(c=r.src,a=s.getExtension(c),!s.isSupported.videoCodecs[a])return t(d.messages.videoCodecs)}else s.isArray(r)&&s.each(r,(function(e,t){if(a=t instanceof Blob?t.type.substr(t.type.lastIndexOf("/")+1,t.length):t.substr(t.lastIndexOf(".")+1,t.length),s.isSupported.videoCodecs[a])return r=t,!1}));S.startStreaming({completed:function(e){e.options=i||{},O(e,t)},existingVideo:r,crossOrigin:i.crossOrigin,options:i})}({existingVideo:l,callback:t,options:i}):function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.lastCameraStream,i=e.options,o=e.webcamVideoElement;if(!m())return t(d.validate());i.savedRenderingContexts.length?C.getGIF(i,(function(e){t(e)})):S.startVideoStreaming((function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{};e.options=i||{},O(e,t)}),{lastCameraStream:r,callback:t,webcamVideoElement:o,crossOrigin:i.crossOrigin})}({lastCameraStream:o,callback:t,webcamVideoElement:u,options:i})}}var F={utils:c,error:l,defaultOptions:g,createGIF:k,takeSnapShot:function(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var r=s.mergeOptions(f,e);k(s.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),t)}},stopVideoStreaming:x,isSupported:function(){return d.isValid()},isWebCamGIFSupported:m,isExistingVideoGIFSupported:function(e){var t=!1;if(s.isArray(e)&&e.length){if(s.each(e,(function(e,r){s.isSupported.videoCodecs[r]&&(t=!0)})),!t)return!1}else if(s.isString(e)&&e.length&&!s.isSupported.videoCodecs[e])return!1;return d.isValid({getUserMedia:!0})},isExistingImagesGIFSupported:function(){return d.isValid({getUserMedia:!0})},VERSION:"0.4.5"};"function"==typeof n&&n.amd?n([],(function(){return F})):e.exports=F}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{})})),i=t((function(e){var t;t=function(){return function(e,t,r){t=t||"",r=r||512;for(var i=atob(e),n=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;y=!0,f.show=!0,e.emit("artplayerPluginGif:start"),d.show=c.get("Start creating gif..."),r.createGIF(o({},t,{video:[v.src],crossOrigin:"anonymous"}),(function(t){if(t.error)d.show=t.errorMsg,n(!1,t.errorMsg);else if("function"==typeof a){var r=t.image.split(",")[1],o=i(r,"image/gif"),s=URL.createObjectURL(o);d.show=c.get("Create gif successfully"),e.emit("artplayerPluginGif",s),a(s)}y=!1,f.show=!1,e.emit("artplayerPluginGif:end")}))}}}})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).artplayerPluginGif=t()}(this,(function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t((function(e,t){!function(t,r,i,n){var o,a,s={URL:t.URL||t.webkitURL||t.mozURL||t.msURL,getUserMedia:(a=i.getUserMedia||i.webkitGetUserMedia||i.mozGetUserMedia||i.msGetUserMedia,a?a.bind(i):a),requestAnimFrame:t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame,requestTimeout:function(e,t){if(e=e||s.noop,t=t||0,!s.requestAnimFrame)return setTimeout(e,t);var r=(new Date).getTime(),i=new Object,n=s.requestAnimFrame;return i.value=n((function o(){(new Date).getTime()-r>=t?e.call():i.value=n(o)})),i},Blob:t.Blob||t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,btoa:(o=t.btoa||function(e){for(var t="",r=0,i=e.length,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=void 0,a=void 0,s=void 0,c=void 0,d=void 0,l=void 0,u=void 0;r>2,d=(3&o)<<4|(a=e.charCodeAt(r++))>>4,l=(15&a)<<2|(s=e.charCodeAt(r++))>>6,u=63&s,isNaN(a)?l=u=64:isNaN(s)&&(u=64),t=t+n.charAt(c)+n.charAt(d)+n.charAt(l)+n.charAt(u);return t},o?o.bind(t):s.noop),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return s.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=r.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return t.Worker},blob:function(){return s.Blob},Uint8Array:function(){return t.Uint8Array},Uint32Array:function(){return t.Uint32Array},videoCodecs:function(){var e=r.createElement("video"),t={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(t.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),t.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),t.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),t.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),t.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(e){}return t}()},noop:function(){},each:function(e,t){var r=void 0,i=void 0;if(s.isArray(e))for(r=-1,i=e.length;++r0&&arguments[0]!==n?arguments[0]:{};if(!r.body||!1===e.resizeFont)return e.fontSize;var t=e.text,i=e.gifWidth,o=parseInt(e.fontSize,10),a=parseInt(e.minFontSize,10),s=r.createElement("div"),c=r.createElement("span");for(s.setAttribute("width",i),s.appendChild(c),c.innerHTML=t,c.style.fontSize=o+"px",c.style.textIndent="-9999px",c.style.visibility="hidden",r.body.appendChild(c);c.offsetWidth>i&&o>=a;)c.style.fontSize=--o+"px";return r.body.removeChild(c),o+"px"},webWorkerError:!1},c=Object.freeze({default:s}),d={validate:function(e){e=s.isObject(e)?e:{};var t={};return s.each(d.validators,(function(r,i){var n=i.errorCode;if(!e[n]&&!i.condition)return(t=i).error=!0,!1})),delete t.condition,t},isValid:function(e){var t=!0!==d.validate(e).error;return t},validators:[{condition:s.isFunction(s.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:s.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:s.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:s.isFunction(s.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:s.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:s.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:s.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"}}},l=Object.freeze({default:d}),u=function(){},f={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,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:u,completeCallback:u,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},g=Object.freeze({default:f});function m(){return d.isValid()}function h(){var e,t,r,i,n,o=256,a=499,s=491,c=487,d=503,l=3*d,u=o-1,f=4,g=100,m=16,h=1<>v,w=h<>3)*(1<o&&(l=o),s=t+1,c=t-1,f=1;sd;){if(u=A[f++],sd){g=n[c--];try{g[0]-=u*(g[0]-r)/k|0,g[1]-=u*(g[1]-i)/k|0,g[2]-=u*(g[2]-a)/k|0}catch(e){}}}}function T(e,t,r,i,o){var a=n[t],s=e/x;a[0]-=s*(a[0]-r)|0,a[1]-=s*(a[1]-i)|0,a[2]-=s*(a[2]-o)|0}function U(e,t,r){var i,a,s,c,d,l,u,g,h,y;for(h=g=~(1<<31),u=l=-1,i=0;i>m-f))>v,E[i]-=d,W[i]+=d<=0;)i=d?i=o:(i++,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)=0&&((s=t-(l=n[a])[1])>=d?a=-1:(a--,s<0&&(s=-s),(c=l[0]-e)<0&&(c=-c),(s+=c)>y)<=1&&(v=0),n=0;n=j&&(E-=r),0===k&&(k=1),++n%k==0)for(b-=b/e,(v=(p-=p/S)>>y)<=1&&(v=0),o=0;o>=f,n[e][1]>>=f,n[e][2]>>=f,n[e][3]=e}(),function(){var e,t,r,i,a,s,c,d;for(c=0,d=0,e=0;e>1,t=c+1;t>1,t=c+1;t<256;t++)F[t]=u}(),function(){for(var e=[],t=new Array(o),r=0;r65535||r>65535)throw"Width/Height invalid.";e[o++]=71,e[o++]=73,e[o++]=70,e[o++]=56,e[o++]=57,e[o++]=97;if(e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=0|(null!==s?128:0),e[o++]=0,e[o++]=0,null!==a){if(a<0||a>65535)throw"Loop count invalid.";e[o++]=33,e[o++]=255,e[o++]=11,e[o++]=78,e[o++]=69,e[o++]=84,e[o++]=83,e[o++]=67,e[o++]=65,e[o++]=80,e[o++]=69,e[o++]=50,e[o++]=46,e[o++]=48,e[o++]=3,e[o++]=1,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=0}var c=!1;this.addFrame=function(t,r,i,a,d,l){if(!0===c&&(--o,c=!1),l=l===n?{}:l,t<0||r<0||t>65535||r>65535)throw"x/y invalid.";if(i<=0||a<=0||i>65535||a>65535)throw"Width/Height invalid.";if(d.length256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}(f),m=0;g>>=1;)++m;g=1<3)throw"Disposal out of range.";var v=!1,b=0;if(l.transparent!==n&&null!==l.transparent&&(v=!0,(b=l.transparent)<0||b>=g))throw"Transparent color index.";if((0!==p||v||0!==h)&&(e[o++]=33,e[o++]=249,e[o++]=4,e[o++]=p<<2|(!0===v?1:0),e[o++]=255&h,e[o++]=h>>8&255,e[o++]=b,e[o++]=0),e[o++]=44,e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=255&i,e[o++]=i>>8&255,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=!0===u?128|m-1:0,!0===u)for(var w=0,y=f.length;w>16&255,e[o++]=C>>8&255,e[o++]=255&C}o=function(e,t,r,i){e[t++]=r;var o=t++,a=1<=r;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++)}function m(e){f|=e<=8;)e[t++]=255&f,f>>=8,u-=8,t===o+256&&(e[o]=255,o=t++);4096===d?(m(a),d=c+1,l=r+1,p={}):(d>=1<0&&arguments[0]!==n?arguments[0]:{},r=e.data;delete s.data,s.pixels=Array.prototype.slice.call(r.pixels),s.palette=Array.prototype.slice.call(r.palette),s.done=!0,s.beingProcessed=!1,t.freeWorker(c),t.onFrameFinished(i)};(s=a[e]).beingProcessed||s.done?this.onFrameFinished():(s.sampleInterval=o,s.beingProcessed=!0,s.gifshot=!0,(c=this.getWorker())?(c.onmessage=d,c.postMessage(s)):d({data:t.workerMethods.run(s)}))},startRendering:function(e){this.onRenderCompleteCallback=e;for(var t=0;t=0&&this.processFrame(e)},generateGIF:function(e,t){var r=[],i={loop:this.repeat},n=this.options,o=n.interval,a=n.frameDuration,c=!!n.images.length,d=n.gifHeight,l=n.gifWidth,u=new v(r,l,d,i),f=this.onRenderProgressCallback,g=c?100*o:0,m=void 0;this.generatingGIF=!0,s.each(e,(function(t,r){var i=r.palette;f(.75+.25*r.position*1/e.length);for(var n=0;n0&&arguments[0]!==n?arguments[0]:{},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(e){var t=this;t.startRendering((function(r){t.destroyWorkers(),s.requestTimeout((function(){e(r)}),0)}))},destroyWorkers:function(){if(!this.workerError){var e=this.workers;s.each(e,(function(e,t){var r=t.worker,i=t.objectUrl;r.terminate(),s.URL.revokeObjectURL(i)}))}}};var y=function(){},C={getGIF:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=arguments[1];t=s.isFunction(t)?t:y;var i=r.createElement("canvas"),o=void 0,a=e.images,c=!!a.length,d=e.cameraStream,l=e.crop,u=e.filter,f=e.fontColor,g=e.fontFamily,m=e.fontWeight,h=e.keepCameraOn,p=(e.numWorkers,e.progressCallback),v=e.saveRenderingContexts,b=e.savedRenderingContexts,C=e.text,S=e.textAlign,x=e.textBaseline,O=e.videoElement,k=e.videoHeight,F=e.videoWidth,W=e.webcamVideoElement,E=Number(e.gifWidth),A=Number(e.gifHeight),R=Number(e.interval),T=(Number(e.sampleInterval),c?0:1e3*R),U=[],j=b.length?b.length:e.numFrames,M=j,I=new w(e),P=s.getFontSize(e),V=e.textXCoordinate?e.textXCoordinate:"left"===S?1:"right"===S?E:E/2,L=e.textYCoordinate?e.textYCoordinate:"top"===x?1:"center"===x?A/2:A,H=m+" "+P+" "+g,z=l?Math.floor(l.scaledWidth/2):0,G=l?F-l.scaledWidth:0,B=l?Math.floor(l.scaledHeight/2):0,D=l?k-l.scaledHeight:0,N=function e(){var r=M-1;function i(){var i;v&&U.push(o.getImageData(0,0,E,A)),C&&(o.font=H,o.fillStyle=f,o.textAlign=S,o.textBaseline=x,o.fillText(C,V,L)),i=o.getImageData(0,0,E,A),I.addFrameImageData(i),p((j-(M=r))/j),r>0&&s.requestTimeout(e,T),M||I.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:d,videoElement:O,webcamVideoElement:W,savedRenderingContexts:U,keepCameraOn:h})}))}b.length?(o.putImageData(b[j-M],0,0),i()):function e(){try{G>F&&(G=F),D>k&&(D=k),z<0&&(z=0),B<0&&(B=0),o.filter=u,o.drawImage(O,z,B,G,D,0,0,E,A),i()}catch(t){if("NS_ERROR_NOT_AVAILABLE"!==t.name)throw t;s.requestTimeout(e,100)}}()};j=j!==n?j:10,R=R!==n?R:.1,i.width=E,i.height=A,o=i.getContext("2d"),function e(){b.length||0!==O.currentTime?N():s.requestTimeout(e,100)}()},getCropDimensions:function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,o=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(a.width=Math.round(t*(o/r))-i,a.scaledWidth=Math.round(a.width*(r/o))):(a.height=Math.round(r*(i/t))-o,a.scaledHeight=Math.round(a.height*(t/i))),a}},S={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function e(t){e.attempts=e.attempts||0;var r=t.cameraStream,i=t.completedCallback,n=t.videoElement;n&&(n.videoWidth>0&&n.videoHeight>0?(n.removeEventListener("loadeddata",S.findVideoSize),i({videoElement:n,cameraStream:r,videoWidth:n.videoWidth,videoHeight:n.videoHeight})):e.attempts<10?(e.attempts+=1,s.requestTimeout((function(){S.findVideoSize(t)}),400)):i({videoElement:n,cameraStream:r,videoWidth:S.defaultVideoDimensions.width,videoHeight:S.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){s.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=s.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,r=e.cameraStream,i=e.completedCallback,n=e.streamedCallback,o=e.videoElement;if(s.isFunction(n)&&n(),t){if(s.isString(t))o.src=t,o.innerHTML='';else if(t instanceof Blob){try{o.src=s.URL.createObjectURL(t)}catch(e){}o.innerHTML=''}}else if(o.mozSrcObject)o.mozSrcObject=r;else if(s.URL)try{o.srcObject=r,o.src=s.URL.createObjectURL(r)}catch(e){o.srcObject=r}o.play(),s.requestTimeout((function e(){e.count=e.count||0,!0===S.loadedData?(S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}),S.loadedData=!1):(e.count+=1)>10?S.findVideoSize({videoElement:o,cameraStream:r,completedCallback:i}):e()}),0)},startStreaming:function(e){var t=s.isFunction(e.error)?e.error:s.noop,i=s.isFunction(e.streamed)?e.streamed:s.noop,n=s.isFunction(e.completed)?e.completed:s.noop,o=e.crossOrigin,a=e.existingVideo,c=e.lastCameraStream,d=e.options,l=e.webcamVideoElement,u=s.isElement(a)?a:l||r.createElement("video");o&&(u.crossOrigin=d.crossOrigin),u.autoplay=!0,u.loop=!0,u.muted=!0,u.addEventListener("loadeddata",(function(e){S.loadedData=!0,d.offset&&(u.currentTime=d.offset)})),a?S.stream({videoElement:u,existingVideo:a,completedCallback:n}):c?S.stream({videoElement:u,cameraStream:c,streamedCallback:i,completedCallback:n}):s.getUserMedia({video:!0},(function(e){S.stream({videoElement:u,cameraStream:e,streamedCallback:i,completedCallback:n})}),t)},startVideoStreaming:function(e){var t=arguments.length>1&&arguments[1]!==n?arguments[1]:{},r=t.timeout!==n?t.timeout:0,i=t.callback,o=t.webcamVideoElement,a=void 0;r>0&&(a=s.requestTimeout((function(){S.onStreamingTimeout(i)}),1e4)),S.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){var t=arguments.length>0&&arguments[0]!==n?arguments[0]:{},r=t.cameraStream,i=t.videoElement,o=t.videoHeight,a=t.videoWidth;e({cameraStream:r,videoElement:i,videoHeight:o,videoWidth:a})},lastCameraStream:t.lastCameraStream,webcamVideoElement:o,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){var t=e=s.isObject(e)?e:{},r=t.keepCameraOn,i=t.videoElement,n=t.webcamVideoElement,o=e.cameraStream||{},a=o.getTracks&&o.getTracks()||[],c=!!a.length,d=a[0];!r&&c&&s.isFunction(d.stop)&&d.stop(),s.isElement(i)&&!n&&(i.pause(),s.isFunction(s.URL.revokeObjectURL)&&!s.webWorkerError&&i.src&&s.URL.revokeObjectURL(i.src),s.removeElement(i))}};function x(e){e=s.isObject(e)?e:{},S.stopVideoStreaming(e)}function O(e,t){var i=e.options||{},n=i.images,o=i.video,a=Number(i.gifWidth),c=Number(i.gifHeight),d=(Number(i.numFrames),e.cameraStream),l=e.videoElement,u=e.videoWidth,f=e.videoHeight,g=C.getCropDimensions({videoWidth:u,videoHeight:f,gifHeight:c,gifWidth:a}),m=t;i.crop=g,i.videoElement=l,i.videoWidth=u,i.videoHeight=f,i.cameraStream=d,s.isElement(l)&&(l.width=a+g.width,l.height=c+g.height,i.webcamVideoElement||(s.setCSSAttr(l,{position:"fixed",opacity:"0"}),r.body.appendChild(l)),l.play(),C.getGIF(i,(function(e){n&&n.length||o&&o.length||x(e),m(e)})))}function k(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var i=s.mergeOptions(f,e)||{},o=e.cameraStream,a=i.images,c=a?a.length:0,l=i.video,u=i.webcamVideoElement;i=s.mergeOptions(i,{gifWidth:Math.floor(i.gifWidth),gifHeight:Math.floor(i.gifHeight)}),c?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,i=e.images,o=e.options,a=e.imagesLength,c=d.validate({getUserMedia:!0,"window.URL":!0}),l=[],u=0,f=void 0,g=void 0;if(c.error)return t(c);function m(){s.each(l,(function(e,t){t&&(t.text?g.addFrame(t.img,o,t.text):g.addFrame(t,o))})),function(e,t){e.getBase64GIF((function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})}))}(g,t)}g=new w(o),s.each(i,(function(e,i){var n=i;i.src&&(n=n.src),s.isElement(n)?(o.crossOrigin&&(n.crossOrigin=o.crossOrigin),l[e]=n,(u+=1)===a&&m()):s.isString(n)&&(f=new Image,o.crossOrigin&&(f.crossOrigin=o.crossOrigin),function(r){i.text&&(r.text=i.text),r.onerror=function(e){var r=void 0;if(0===--a)return(r={}).error="None of the requested images was capable of being retrieved",t(r)},r.onload=function(t){i.text?l[e]={img:r,text:r.text}:l[e]=r,(u+=1)===a&&m(),s.removeElement(r)},r.src=n}(f),s.setCSSAttr(f,{position:"fixed",opacity:"0"}),r.body.appendChild(f))}))}({images:a,imagesLength:c,callback:t,options:i}):l?function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.existingVideo,i=e.options,o=d.validate({getUserMedia:!0,"window.URL":!0}),a=void 0,c=void 0;if(o.error)return t(o);if(s.isElement(r)&&r.src){if(c=r.src,a=s.getExtension(c),!s.isSupported.videoCodecs[a])return t(d.messages.videoCodecs)}else s.isArray(r)&&s.each(r,(function(e,t){if(a=t instanceof Blob?t.type.substr(t.type.lastIndexOf("/")+1,t.length):t.substr(t.lastIndexOf(".")+1,t.length),s.isSupported.videoCodecs[a])return r=t,!1}));S.startStreaming({completed:function(e){e.options=i||{},O(e,t)},existingVideo:r,crossOrigin:i.crossOrigin,options:i})}({existingVideo:l,callback:t,options:i}):function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{},t=e.callback,r=e.lastCameraStream,i=e.options,o=e.webcamVideoElement;if(!m())return t(d.validate());i.savedRenderingContexts.length?C.getGIF(i,(function(e){t(e)})):S.startVideoStreaming((function(){var e=arguments.length>0&&arguments[0]!==n?arguments[0]:{};e.options=i||{},O(e,t)}),{lastCameraStream:r,callback:t,webcamVideoElement:o,crossOrigin:i.crossOrigin})}({lastCameraStream:o,callback:t,webcamVideoElement:u,options:i})}}var F={utils:c,error:l,defaultOptions:g,createGIF:k,takeSnapShot:function(e,t){if(t=s.isFunction(e)?e:t,e=s.isObject(e)?e:{},s.isFunction(t)){var r=s.mergeOptions(f,e);k(s.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),t)}},stopVideoStreaming:x,isSupported:function(){return d.isValid()},isWebCamGIFSupported:m,isExistingVideoGIFSupported:function(e){var t=!1;if(s.isArray(e)&&e.length){if(s.each(e,(function(e,r){s.isSupported.videoCodecs[r]&&(t=!0)})),!t)return!1}else if(s.isString(e)&&e.length&&!s.isSupported.videoCodecs[e])return!1;return d.isValid({getUserMedia:!0})},isExistingImagesGIFSupported:function(){return d.isValid({getUserMedia:!0})},VERSION:"0.4.5"};"function"==typeof n&&n.amd?n([],(function(){return F})):e.exports=F}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{})})),i=t((function(e){var t;t=function(){return function(e,t,r){t=t||"",r=r||512;for(var i=atob(e),n=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;y=!0,f.show=!0,e.emit("artplayerPluginGif:start"),d.show=c.get("Start creating gif..."),r.createGIF(o({},t,{video:[v.src],crossOrigin:"anonymous"}),(function(t){if(t.error)d.show=t.errorMsg,n(!1,t.errorMsg);else if("function"==typeof a){var r=t.image.split(",")[1],o=i(r,"image/gif"),s=URL.createObjectURL(o);d.show=c.get("Create gif successfully"),e.emit("artplayerPluginGif",s),a(s)}y=!1,f.show=!1,e.emit("artplayerPluginGif:end")}))}}}})); diff --git a/packages/artplayer-plugin-playlist/dist/artplayer-plugin-playlist.js b/packages/artplayer-plugin-playlist/dist/artplayer-plugin-playlist.js index 1ce43b5f7..1ca694d37 100644 --- a/packages/artplayer-plugin-playlist/dist/artplayer-plugin-playlist.js +++ b/packages/artplayer-plugin-playlist/dist/artplayer-plugin-playlist.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).artplayerPluginPlaylist=n()}(this,(function(){"use strict";return function(t){return function(n){var e=n.constructor.utils,i=e.append,r=e.errorHandle,a=e.sleep,l=e.inverseClass,o=n.player,s=n.events.proxy,u=n.template,c=u.$player,f=u.$video,d=i(c,'
');r(Array.isArray(t),"Playlist is not an array type"),r(t.length>0,"Playlist cannot be empty");var y=t.map((function(t){return r(t.url,"Playlist items require url attribute"),r(t.title,"Playlist items require title attribute"),t})),p=d.querySelector(".art-playlist-inner");function v(t){var e=y[t];return o.switchUrl(e.url,e.title).then((function(){n.emit("artplayerPluginPlaylist:change",e)}))}function h(){var t=y.findIndex((function(t){return t.url===f.src}));return r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t+1===y.length?0:t+1)}return p.innerHTML=y.map((function(t,n){return'
').concat(t.title,"
")})).join(""),s(p,"click",(function(t){var n=t.target.dataset.optionIndex;n&&Number(n)<=y.length-1&&v(n)})),s(d,"click",(function(t){t.target===d&&c.classList.remove("art-playlist-show")})),n.on("video:ended",(function(){h().then((function(){a(1e3).then((function(){o.play=!0}))}))})),n.on("afterAttachUrl",(function(){var t=y.findIndex((function(t){return t.url===f.src})),n=Array.from(p.children)[t];-1!==t&&n&&l(n,"active")})),{name:"artplayerPluginPlaylist",show:function(){c.classList.add("art-playlist-show")},hide:function(){c.classList.remove("art-playlist-show")},next:function(){h()},prev:function(){var t;t=y.findIndex((function(t){return t.url===f.src})),r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t-1==-1?y.length-1:t-1)}}}}})); +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).artplayerPluginPlaylist=n()}(this,(function(){"use strict";return function(t){return function(n){var e=n.constructor.utils,i=e.append,r=e.errorHandle,a=e.sleep,l=e.inverseClass,o=n.player,s=n.events.proxy,u=n.template,c=u.$player,f=u.$video,d=i(c,'
');r(Array.isArray(t),"Playlist is not an array type"),r(t.length>0,"Playlist cannot be empty");var y=t.map((function(t){return r(t.url,"Playlist items require url attribute"),r(t.title,"Playlist items require title attribute"),t})),p=d.querySelector(".art-playlist-inner");function v(t){var e=y[t],i=o.playing;return o.switchUrl(e.url,e.title).then((function(){i&&(o.play=!0),n.emit("artplayerPluginPlaylist:change",e)}))}function h(){var t=y.findIndex((function(t){return t.url===f.src}));return r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t+1===y.length?0:t+1)}return p.innerHTML=y.map((function(t,n){return'
').concat(t.title,"
")})).join(""),s(p,"click",(function(t){var n=t.target.dataset.optionIndex;n&&Number(n)<=y.length-1&&v(n)})),s(d,"click",(function(t){t.target===d&&c.classList.remove("art-playlist-show")})),n.on("video:ended",(function(){h().then((function(){a(1e3).then((function(){o.play=!0}))}))})),n.on("afterAttachUrl",(function(){var t=y.findIndex((function(t){return t.url===f.src})),n=Array.from(p.children)[t];-1!==t&&n&&l(n,"active")})),{name:"artplayerPluginPlaylist",show:function(){c.classList.add("art-playlist-show")},hide:function(){c.classList.remove("art-playlist-show")},next:function(){h()},prev:function(){var t;t=y.findIndex((function(t){return t.url===f.src})),r(-1!==t,"Can't find Playlist item"),1===y.length?v(0):v(t-1==-1?y.length-1:t-1)}}}}}));