From 26fedfa3d100c46f982009aad79f6bbde6018c4b Mon Sep 17 00:00:00 2001
From: Harvey
Date: Wed, 27 Apr 2022 11:14:22 +0800
Subject: [PATCH] 4.3.9
---
dist/artplayer-tool-thumbnail.js | 2 +-
dist/artplayer.js | 4 ++--
.../artplayer-tool-thumbnail/dist/artplayer-tool-thumbnail.js | 2 +-
packages/artplayer/dist/artplayer.js | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dist/artplayer-tool-thumbnail.js b/dist/artplayer-tool-thumbnail.js
index be30a0569..f5e0aa5a8 100644
--- a/dist/artplayer-tool-thumbnail.js
+++ b/dist/artplayer-tool-thumbnail.js
@@ -5,4 +5,4 @@
* Released under the MIT License.
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("tiny-emitter")):"function"==typeof define&&define.amd?define(["tiny-emitter"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).ArtplayerToolThumbnail=e(t.Emitter)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};return n(this,h),(t=s.call(this)).processing=!1,t.option={},t.setup(Object.assign({},h.DEFAULTS,e)),t.video=h.creatVideo(),t.duration=0,t.inputChange=t.inputChange.bind(o(t)),t.ondrop=t.ondrop.bind(o(t)),t.option.fileInput.addEventListener("change",t.inputChange),t.option.fileInput.addEventListener("dragover",h.ondragover),t.option.fileInput.addEventListener("drop",h.ondrop),t}return e=h,a=[{key:"ondrop",value:function(t){t.preventDefault();var e=t.dataTransfer.files[0];this.loadVideo(e)}},{key:"setup",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.option=Object.assign({},this.option,e);var n=this.option,i=n.fileInput,o=n.number,r=n.width,a=n.column;if(this.errorHandle(i instanceof Element,"The 'fileInput' is not a Element"),"INPUT"!==i.tagName||"file"!==i.type){i.style.position="relative";var u=document.createElement("input");u.type="file",u.style.position="absolute",u.style.width="100%",u.style.height="100%",u.style.left="0",u.style.top="0",u.style.right="0",u.style.bottom="0",u.style.opacity="0",i.appendChild(u),this.option.fileInput=u}return["number","width","column","begin","end"].forEach((function(e){t.errorHandle("number"==typeof t.option[e],"The '".concat(e,"' is not a number"))})),this.option.number=l(o,10,1e3),this.option.width=l(r,10,1e3),this.option.column=l(a,1,1e3),this}},{key:"inputChange",value:function(t){var e=this.option.fileInput.files[0];this.loadVideo(e),t.target.value=""}},{key:"loadVideo",value:function(t){if(t){var e=this.video.canPlayType(t.type);this.errorHandle("maybe"===e||"probably"===e,"Playback of this file format is not supported: ".concat(t.type));var n=URL.createObjectURL(t);this.videoUrl=n,this.file=t,this.emit("file",this.file),this.video.src=n,this.emit("video",this.video)}}},{key:"start",value:function(){var t,e=this;if(!this.video.duration)return(t=1e3,new Promise((function(e){return setTimeout(e,t)}))).then((function(){return e.start()}));var n=this.option,i=n.width,o=n.number,r=n.begin,a=n.end,u=this.video.videoHeight/this.video.videoWidth*i;this.option.height=u,this.option.begin=l(r,0,this.video.duration),this.option.end=l(a||this.video.duration,r,this.video.duration),this.errorHandle(this.option.end>this.option.begin,"End time must be greater than the start time"),this.duration=this.option.end-this.option.begin,this.density=o/this.duration,this.errorHandle(this.file&&this.video,"Please select the video file first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment..."),this.errorHandle(this.density<=1,"The preview density cannot be greater than 1, but got ".concat(this.density));var s=this.creatScreenshotDate(),c=this.creatCanvas(),h=c.getContext("2d");this.emit("canvas",c);var d,f=s.map((function(t,n){return function(){return new Promise((function(r){e.video.oncanplay=function(){h.drawImage(e.video,t.x,t.y,i,u),c.toBlob((function(t){e.thumbnailUrl&&URL.revokeObjectURL(e.thumbnailUrl),e.thumbnailUrl=URL.createObjectURL(t),e.emit("update",e.thumbnailUrl,(n+1)/o),e.video.oncanplay=null,r()}))},e.video.currentTime=t.time}))}}));return this.processing=!0,(d=f,d.reduce((function(t,e){return t.then(e)}),Promise.resolve())).then((function(){e.processing=!1,e.emit("done")})).catch((function(t){throw e.processing=!1,e.emit("error",t.message),t}))}},{key:"creatScreenshotDate",value:function(){for(var t=this.option,e=t.number,n=t.width,i=t.height,o=t.column,r=t.begin,a=this.duration/e,u=[r+a];u.length0&&void 0!==arguments[0]?arguments[0]:{};return t(this,h),(e=u.call(this)).processing=!1,e.option={},e.setup(Object.assign({},h.DEFAULTS,i)),e.video=h.creatVideo(),e.duration=0,e.inputChange=e.inputChange.bind(n(e)),e.ondrop=e.ondrop.bind(n(e)),e.option.fileInput.addEventListener("change",e.inputChange),e.option.fileInput.addEventListener("dragover",h.ondragover),e.option.fileInput.addEventListener("drop",h.ondrop),e}return r=h,a=[{key:"ondrop",value:function(t){t.preventDefault();var e=t.dataTransfer.files[0];this.loadVideo(e)}},{key:"setup",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.option=Object.assign({},this.option,e);var n=this.option,i=n.fileInput,o=n.number,r=n.width,a=n.column;if(this.errorHandle(i instanceof Element,"The 'fileInput' is not a Element"),"INPUT"!==i.tagName||"file"!==i.type){i.style.position="relative";var s=document.createElement("input");s.type="file",s.style.position="absolute",s.style.width="100%",s.style.height="100%",s.style.left="0",s.style.top="0",s.style.right="0",s.style.bottom="0",s.style.opacity="0",i.appendChild(s),this.option.fileInput=s}return["number","width","column","begin","end"].forEach((function(e){t.errorHandle("number"==typeof t.option[e],"The '".concat(e,"' is not a number"))})),this.option.number=l(o,10,1e3),this.option.width=l(r,10,1e3),this.option.column=l(a,1,1e3),this}},{key:"inputChange",value:function(t){var e=this.option.fileInput.files[0];this.loadVideo(e),t.target.value=""}},{key:"loadVideo",value:function(t){if(t){var e=this.video.canPlayType(t.type);this.errorHandle("maybe"===e||"probably"===e,"Playback of this file format is not supported: ".concat(t.type));var n=URL.createObjectURL(t);this.videoUrl=n,this.file=t,this.emit("file",this.file),this.video.src=n,this.emit("video",this.video)}}},{key:"start",value:function(){var t,e=this;if(!this.video.duration)return(t=1e3,new Promise((function(e){return setTimeout(e,t)}))).then((function(){return e.start()}));var n=this.option,i=n.width,o=n.number,r=n.begin,a=n.end,s=this.video.videoHeight/this.video.videoWidth*i;this.option.height=s,this.option.begin=l(r,0,this.video.duration),this.option.end=l(a||this.video.duration,r,this.video.duration),this.errorHandle(this.option.end>this.option.begin,"End time must be greater than the start time"),this.duration=this.option.end-this.option.begin,this.density=o/this.duration,this.errorHandle(this.file&&this.video,"Please select the video file first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment..."),this.errorHandle(this.density<=1,"The preview density cannot be greater than 1, but got ".concat(this.density));var u=this.creatScreenshotDate(),c=this.creatCanvas(),h=c.getContext("2d");this.emit("canvas",c);var f,p=u.map((function(t,n){return function(){return new Promise((function(r){e.video.oncanplay=function(){h.drawImage(e.video,t.x,t.y,i,s),c.toBlob((function(t){e.thumbnailUrl&&URL.revokeObjectURL(e.thumbnailUrl),e.thumbnailUrl=URL.createObjectURL(t),e.emit("update",e.thumbnailUrl,(n+1)/o),e.video.oncanplay=null,r()}))},e.video.currentTime=t.time}))}}));return this.processing=!0,(f=p,f.reduce((function(t,e){return t.then(e)}),Promise.resolve())).then((function(){e.processing=!1,e.emit("done")})).catch((function(t){throw e.processing=!1,e.emit("error",t.message),t}))}},{key:"creatScreenshotDate",value:function(){for(var t=this.option,e=t.number,n=t.width,i=t.height,o=t.column,r=t.begin,a=this.duration/e,s=[r+a];s.length1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:document;return e.querySelector(t)}function g(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(e.querySelectorAll(t))}function b(t,e){return t.classList.add(e)}function w(t,e){return t.classList.remove(e)}function x(t,e){return t.classList.contains(e)}function O(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function k(t,e,n){return t.style[e]=n,t}function j(t,e){return Object.keys(e).forEach((function(n){k(t,n,e[n])})),t}function P(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=window.getComputedStyle(t,null).getPropertyValue(e);return n?parseFloat(r):r}function S(t){return Array.from(t.parentElement.children).filter((function(e){return e!==t}))}function R(t,e){S(t).forEach((function(t){return w(t,e)})),b(t,e)}function E(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"up";d||(t.setAttribute("aria-label",e),t.setAttribute("data-balloon-pos",n))}function C(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,o=window.innerWidth||document.documentElement.clientWidth,i=n.top-e<=r&&n.top+n.height+e>=0,a=n.left-e<=o+e&&n.left+n.width+e>=0;return i&&a}function $(t,e){return t.composedPath&&t.composedPath().indexOf(e)>-1}function z(t,e){return e.parentNode.replaceChild(t,e),t}function T(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function D(t,e,n){return D=T()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&o(i,n.prototype),i},D.apply(null,arguments)}function A(t){var e="function"==typeof Map?new Map:void 0;return A=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return D(t,arguments,l(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)},A(t)}function M(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=l(t);if(e){var o=l(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return c(this,n)}}var L=function(e){i(a,e);var o=M(a);function a(e,n){var i;return t(this,a),i=o.call(this,e),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r(i),n||i.constructor),i.name="ArtPlayerError",i}return n(a)}(A(Error));function F(t,e){if(!t)throw new L(e);return t}function I(t){return"WEBVTT \r\n\r\n".concat(t.replace(/{[\s\S]*?}/g,"").replace(/\{\\([ibu])\}/g,"$1>").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"$1>").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").concat("\r\n\r\n"))}function B(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function q(t){var e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return t.split(/[:.]/).map((function(t,e,n){if(e===n.length-1){if(1===t.length)return".".concat(t,"00");if(2===t.length)return".".concat(t,"0")}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===n.length-1?".".concat(t):":".concat(t)})).join("")}return"WEBVTT\n\n".concat(t.split(/\r?\n/).map((function(t){var r=t.match(e);return r?{start:n(r[1].trim()),end:n(r[2].trim()),text:r[5].replace(/{[\s\S]*?}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map((function(t){return t.trim()})).join("\n")}:null})).filter((function(t){return t})).map((function(t,e){return t?"".concat(e+1,"\n").concat(t.start," --\x3e ").concat(t.end,"\n").concat(t.text):""})).filter((function(t){return t.trim()})).join("\n\n"))}function V(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#000",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return[[e,0],[0,e],[-e,0],[0,-e],[e,e],[-e,-e],[e,-e],[-e,e]].map((function(e){return"".concat(t," ").concat(e[0],"px ").concat(e[1],"px ").concat(n,"px")})).join(",")}function H(t){return t.includes("?")?H(t.split("?")[0]):t.includes("#")?H(t.split("#")[0]):t.trim().toLowerCase().split(".").pop()}function W(t,e){var n=document.createElement("a");n.style.display="none",n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function N(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(e){return setTimeout(e,t)}))}function J(t,e){var n,r,o=!1;return function i(){for(var a=arguments.length,c=new Array(a),l=0;l0?[e,n,r]:[n,r]).map((function(t){return t<10?"0".concat(t):String(t)})).join(":")}function et(t){return t.replace(/[&<>'"]/g,(function(t){return{"&":"&","<":"<",">":">","'":"'",'"':"""}[t]||t}))}var nt=Object.freeze({__proto__:null,query:y,queryAll:g,addClass:b,removeClass:w,hasClass:x,append:O,remove:function(t){return t.parentNode.removeChild(t)},setStyle:k,setStyles:j,getStyle:P,sublings:S,inverseClass:R,tooltip:E,isInViewport:C,includeFromEvent:$,replaceElement:z,ArtPlayerError:L,errorHandle:F,srtToVtt:I,vttToBlob:B,assToVtt:q,outline:V,getExt:H,download:W,def:U,has:Y,get:G,mergeDeep:Q,sleep:Z,debounce:function(t,e,n){var r;function o(){for(var o=arguments.length,i=new Array(o),a=0;a-1;case"function":return t(f);case"regexp":return t.test(f);default:return!1}}))}}]),e}(),mt=function(){function e(n){var r=this;t(this,e),this.art=n;var o=n.option,i=n.constructor,a=n.whitelist;o.container instanceof Element?this.$container=o.container:(this.$container=y(o.container),F(this.$container,"No container element found by ".concat(o.container)));var c=this.$container.tagName.toLowerCase();F("div"===c,"Unsupported container element type, only support 'div' but got '".concat(c,"'")),F(i.instances.every((function(t){return t.template.$container!==r.$container})),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),this.$container.dataset.artId=n.id,this.$original=this.$container.cloneNode(!0),a.state?this.desktop():this.mobile()}return n(e,[{key:"query",value:function(t){return y(t,this.$container)}},{key:"desktop",value:function(){var t=this.art.option;t.useSSR||(this.$container.innerHTML=e.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$miniHeader=this.query(".art-mini-header"),this.$miniTitle=this.query(".art-mini-title"),this.$miniClose=this.query(".art-mini-close"),this.$contextmenu=this.query(".art-contextmenus"),t.backdrop&&(b(this.$setting,"art-backdrop-filter"),b(this.$contextmenu,"art-backdrop-filter"),b(this.$info,"art-backdrop-filter")),d&&b(this.$player,"art-mobile")}},{key:"mobile",value:function(){this.$container.innerHTML='',this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video")}},{key:"destroy",value:function(t){t?z(this.$original,this.$container):b(this.$player,"art-destroy")}}],[{key:"html",get:function(){return'