From 2501c013aff42e48ebe8492c35e70aeb8b5efa06 Mon Sep 17 00:00:00 2001 From: Harvey Date: Mon, 27 Apr 2020 11:44:10 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=B7=BB=E5=8A=A0=E5=BC=B9=E5=B9=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 113ccc5415add5b673bdd2f83803625a772ae611. --- .size-snapshot.json | 6 +++--- dist/artplayer-plugin-danmuku.js | 2 +- .../dist/artplayer-plugin-danmuku.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.size-snapshot.json b/.size-snapshot.json index a81fa9cc4..4373ef023 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -25,9 +25,9 @@ "gzipped": 2786 }, "packages/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js": { - "bundled": 24092, - "minified": 12783, - "gzipped": 4151 + "bundled": 23629, + "minified": 12587, + "gzipped": 4088 }, "packages/artplayer-vue/dist/artplayer-vue.js": { "bundled": 181932, diff --git a/dist/artplayer-plugin-danmuku.js b/dist/artplayer-plugin-danmuku.js index 6fa241a79..9788e824f 100644 --- a/dist/artplayer-plugin-danmuku.js +++ b/dist/artplayer-plugin-danmuku.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).artplayerPluginDanmuku=e()}(this,(function(){"use strict";var t=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var e=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function n(t,e){for(var n=0;n'.concat(e.get("Danmu opacity"),': 100%
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=100*Number(e),t.plugins.artplayerPluginDanmuku.config({opacity:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.opacity&&(i.value=t.opacity,r.innerText=100*t.opacity)}))}}}function o(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-size",index:11,html:'
'.concat(e.get("Danmu size"),': 25px
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({fontSize:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.fontSize&&(i.value=t.fontSize,r.innerText=t.fontSize)}))}}}function u(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-speed",index:12,html:'
'.concat(e.get("Danmu speed"),': 5s
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({speed:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.speed&&(i.value=t.speed,r.innerText=t.speed)}))}}}function s(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-synchronousPlayback",index:13,html:'"),mounted:function(e){var i=e.querySelector("input[type=checkbox]");n(i,"change",(function(){t.plugins.artplayerPluginDanmuku.config({synchronousPlayback:i.checked})})),t.on("artplayerPluginDanmuku:config",(function(t){i.checked!==t.synchronousPlayback&&(i.checked=t.synchronousPlayback)}))}}}function l(t,e,n){return t.filter((function(t){return t.$state===e})).map(n)}function c(t,e){var n=t.getBoundingClientRect();return e?n[e]:n}var p=function(t){if(Array.isArray(t))return t};var f=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],i=!0,r=!1,a=void 0;try{for(var o,u=t[Symbol.iterator]();!(i=(o=u.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){r=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(r)throw a}}return n}};var m=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var h=function(t,e){return p(t)||f(t,e)||m()};function d(t){switch(t){case 1:case 2:case 3:return 0;case 4:case 5:return 1;default:return 0}}function y(t){return fetch(t).then((function(t){return t.text()})).then((function(t){return function(t){if("string"!=typeof t)return[];var e=t.match(/[\S ]*?)<\/d>/gi);return e.length?e.map((function(t){var e=t.match(/(.+)<\/d>/),n=h(e,3),i=n[1],r=n[2],a=i.split(",");return 8===a.length&&r.trim()?{text:r,time:Number(a[0]),mode:d(Number(a[1])),fontSize:Number(a[2]),color:"#".concat(Number(a[3]).toString(16)),timestamp:Number(a[4]),pool:Number(a[5]),userID:a[6],rowID:Number(a[7])}:null})):[]}(t)}))}function g(t,e){var n=h(t.option.margin,2),i=n[0],r=n[1],a=c(t.art.template.$player),o=t.queue.filter((function(t){return t.mode===e.mode&&"emit"===t.$state&&t.$ref&&t.$ref.style.fontSize===e.$ref.style.fontSize&&parseFloat(t.$ref.style.top)<=a.height-r})).map((function(t){var e=c(t.$ref),n=e.width,i=e.height,r=e.top-a.top,o=e.left-a.left;return{top:r,left:o,height:i,width:n,right:a.width-o-n}})).sort((function(t,e){return t.top-e.top}));return 0===o.length?i:(o.unshift({top:0,left:0,right:0,height:i,width:a.width}),o.push({top:a.height-r,left:0,right:0,height:r,width:a.width}),function(t){for(var e=0,n={},i=0;io&&(e=c,o=p)}if(0===e)for(var f=0,m=0;mf)f=d,e=h(g,1)[0].top}if(0===e){var x=a.filter((function(t,e){return 0!==e&&e!==a.length-1})).sort((function(t,e){return n[t].length-n[e].length}));e=h(x,1)[0]}return e}(o))}function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}var b=function(){function n(t,i){var l=this;e(this,n),t.i18n.update(r),t.setting.add(a),t.setting.add(o),t.setting.add(u),t.setting.add(s),this.art=t,this.queue=[],this.option={},this.config(i),this.isStop=!1,this.isHide=!1,this.animationFrameTimer=null,this.$danmuku=t.template.$danmuku,t.on("video:play",this.start.bind(this)),t.on("video:playing",this.start.bind(this)),t.on("video:pause",this.stop.bind(this)),t.on("video:waiting",this.stop.bind(this)),t.on("resize",this.resize.bind(this)),t.on("destroy",this.stop.bind(this)),"function"==typeof this.option.danmuku?this.option.danmuku().then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):"string"==typeof this.option.danmuku?y(this.option.danmuku).then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):(this.option.danmuku.forEach(this.emit.bind(this)),t.emit("artplayerPluginDanmuku:loaded"))}return i(n,[{key:"config",value:function(t){var e=this.art.constructor,i=e.utils.clamp,r=e.validator;this.option=Object.assign({},n.option,this.option,t),r(this.option,n.scheme),this.option.speed=i(this.option.speed,1,10),this.option.maxlength=i(this.option.maxlength,10,100),this.option.margin[0]=i(this.option.margin[0],0,100),this.option.margin[1]=i(this.option.margin[1],0,100),this.option.opacity=i(this.option.opacity,0,1),this.option.fontSize=i(this.option.fontSize,12,30),this.art.emit("artplayerPluginDanmuku:config",this.option)}},{key:"continue",value:function(){l(this.queue,"stop",(function(t){switch(t.$state="emit",t.$lastStartTime=Date.now(),t.mode){case 0:t.$ref.style.transform="translateX(".concat(-t.$restWidth,"px) translateY(0px) translateZ(0px)"),t.$ref.style.transition="transform ".concat(t.$restTime,"s linear 0s")}}))}},{key:"suspend",value:function(){var t=this.art.template.$player;l(this.queue,"emit",(function(e){switch(e.$state="stop",e.mode){case 0:var n=c(t),i=n.left,r=n.width-(c(e.$ref).left-i)+5;e.$ref.style.transform="translateX(".concat(-r,"px) translateY(0px) translateZ(0px)"),e.$ref.style.transition="transform 0s linear 0s"}}))}},{key:"resize",value:function(){var t=c(this.art.template.$player,"width");l(this.queue,"wait",(function(e){e.$ref&&(e.$ref.style.border="none",e.$ref.style.left="".concat(t,"px"),e.$ref.style.marginLeft="0px",e.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",e.$ref.style.transition="transform 0s linear 0s")}))}},{key:"update",value:function(){var t=this,e=this.art,n=e.player,i=e.template.$player;this.animationFrameTimer=window.requestAnimationFrame((function(){if(n.playing&&!t.isHide){var e=c(i,"width");l(t.queue,"emit",(function(t){t.$restTime-=(Date.now()-t.$lastStartTime)/1e3,t.$lastStartTime=Date.now(),t.$restTime<=0&&(t.$state="wait",t.$ref.style.border="none",t.$ref.style.left="".concat(e,"px"),t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",t.$ref.style.transition="transform 0s linear 0s")})),t.queue.filter((function(t){return n.currentTime+.1>=t.time&&t.time>=n.currentTime-.1&&"wait"===t.$state})).forEach((function(i){i.$ref=function(t){var e=t.find((function(t){return t.$ref&&"wait"===t.$state}));if(e){var n=e.$ref;return e.$ref=null,n}var i=document.createElement("div");return i.style.cssText='\n user-select: none;\n position: absolute;\n white-space: pre;\n pointer-events: none;\n perspective: 500px;\n display: inline-block;\n will-change: transform;\n font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;\n font-weight: normal;\n line-height: 1.125;\n text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;\n ',i}(t.queue),t.$danmuku.appendChild(i.$ref),i.$ref.style.opacity=t.option.opacity,i.$ref.style.fontSize="".concat(t.option.fontSize,"px"),i.$ref.innerText=i.text,i.$ref.style.color=i.color||"#fff",i.$ref.style.border=i.border?"1px solid ".concat(i.color||"#fff"):"none",i.$restTime=t.option.synchronousPlayback&&n.playbackRate?t.option.speed/Number(n.playbackRate):t.option.speed,i.$lastStartTime=Date.now();var r=c(i.$ref,"width"),a=g(t,i);switch(i.$state="emit",i.mode){case 0:i.$restWidth=e+r+5,i.$ref.style.left="".concat(e,"px"),i.$ref.style.top="".concat(a,"px"),i.$ref.style.transform="translateX(".concat(-i.$restWidth,"px) translateY(0px) translateZ(0px)"),i.$ref.style.transition="transform ".concat(i.$restTime,"s linear 0s");break;case 1:i.$ref.style.top="".concat(a,"px"),i.$ref.style.left="50%",i.$ref.style.marginLeft="-".concat(r/2,"px")}}))}t.isStop||t.update()}))}},{key:"stop",value:function(){this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.animationFrameTimer),this.art.emit("artplayerPluginDanmuku:stop")}},{key:"start",value:function(){this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start")}},{key:"show",value:function(){this.isHide=!1,this.$danmuku.style.display="block",this.art.emit("artplayerPluginDanmuku:show")}},{key:"hide",value:function(){this.isHide=!0,this.$danmuku.style.display="none",this.art.emit("artplayerPluginDanmuku:hide")}},{key:"emit",value:function(e){var n=this.art,i=n.notice,r=n.player,a=n.i18n,o=this.art.constructor,u=o.utils.clamp;(0,o.validator)(e,{text:"string",mode:"number|undefined",color:"string|undefined",time:"number|undefined",border:"boolean|undefined"}),e.text.trim()?e.text.length>this.option.maxlength?i.show="".concat(a.get("The length of the danmu does not exceed")," ").concat(this.option.maxlength):(e.time?e.time=u(e.time,0,1/0):e.time=r.currentTime+.5,this.queue.push(function(e){for(var n=1;n'.concat(e.get("Danmu opacity"),': 100%
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=100*Number(e),t.plugins.artplayerPluginDanmuku.config({opacity:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.opacity&&(i.value=t.opacity,r.innerText=100*t.opacity)}))}}}function o(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-size",index:11,html:'
'.concat(e.get("Danmu size"),': 25px
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({fontSize:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.fontSize&&(i.value=t.fontSize,r.innerText=t.fontSize)}))}}}function s(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-speed",index:12,html:'
'.concat(e.get("Danmu speed"),': 5s
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({speed:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.speed&&(i.value=t.speed,r.innerText=t.speed)}))}}}function u(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-synchronousPlayback",index:13,html:'"),mounted:function(e){var i=e.querySelector("input[type=checkbox]");n(i,"change",(function(){t.plugins.artplayerPluginDanmuku.config({synchronousPlayback:i.checked})})),t.on("artplayerPluginDanmuku:config",(function(t){i.checked!==t.synchronousPlayback&&(i.checked=t.synchronousPlayback)}))}}}function l(t,e,n){return t.filter((function(t){return t.$state===e})).map(n)}function c(t,e){var n=t.getBoundingClientRect();return e?n[e]:n}var p=function(t){if(Array.isArray(t))return t};var f=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],i=!0,r=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){r=!0,a=t}finally{try{i||null==s.return||s.return()}finally{if(r)throw a}}return n}};var h=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var m=function(t,e){return p(t)||f(t,e)||h()};function d(t){switch(t){case 1:case 2:case 3:return 0;case 4:case 5:return 1;default:return 0}}function y(t){return fetch(t).then((function(t){return t.text()})).then((function(t){return function(t){if("string"!=typeof t)return[];var e=t.match(/[\S ]*?)<\/d>/gi);return e.length?e.map((function(t){var e=t.match(/(.+)<\/d>/),n=m(e,3),i=n[1],r=n[2],a=i.split(",");return 8===a.length&&r.trim()?{text:r,time:Number(a[0]),mode:d(Number(a[1])),fontSize:Number(a[2]),color:"#".concat(Number(a[3]).toString(16)),timestamp:Number(a[4]),pool:Number(a[5]),userID:a[6],rowID:Number(a[7])}:null})):[]}(t)}))}function g(t,e){var n=m(t.option.margin,2),i=n[0],r=n[1],a=c(t.art.template.$player),o=t.queue.filter((function(t){return t.mode===e.mode&&"emit"===t.$state&&t.$ref&&t.$ref.style.fontSize===e.$ref.style.fontSize&&parseFloat(t.$ref.style.top)<=a.height-r})).map((function(t){var e=c(t.$ref),n=e.width,i=e.height,r=e.top-a.top,o=e.left-a.left;return{top:r,left:o,height:i,width:n,right:a.width-o-n}})).sort((function(t,e){return t.top-e.top}));return 0===o.length?i:(o.unshift({top:0,left:0,right:0,height:i,width:a.width}),o.push({top:a.height-r,left:0,right:0,height:r,width:a.width}),function(t){for(var e=0,n={},i=0;io&&(e=c,o=p)}if(0===e)for(var f=0,h=0;hf)f=d,e=m(g,1)[0].top}if(0===e){var x=a.filter((function(t,e){return 0!==e&&e!==a.length-1})).sort((function(t,e){return n[t].length-n[e].length}));e=m(x,1)[0]}return e}(o))}function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}var b=function(){function n(t,i){var l=this;e(this,n),t.i18n.update(r),t.setting.add(a),t.setting.add(o),t.setting.add(s),t.setting.add(u),this.art=t,this.queue=[],this.option={},this.config(i),this.isStop=!1,this.isHide=!1,this.animationFrameTimer=null,this.$danmuku=t.template.$danmuku,t.on("video:play",this.start.bind(this)),t.on("video:playing",this.start.bind(this)),t.on("video:pause",this.stop.bind(this)),t.on("video:waiting",this.stop.bind(this)),t.on("resize",this.resize.bind(this)),t.on("destroy",this.stop.bind(this)),"function"==typeof this.option.danmuku?this.option.danmuku().then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):"string"==typeof this.option.danmuku?y(this.option.danmuku).then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):(this.option.danmuku.forEach(this.emit.bind(this)),t.emit("artplayerPluginDanmuku:loaded"))}return i(n,[{key:"config",value:function(t){var e=this.art.constructor,i=e.utils.clamp,r=e.validator;this.option=Object.assign({},n.option,this.option,t),r(this.option,n.scheme),this.option.speed=i(this.option.speed,1,10),this.option.maxlength=i(this.option.maxlength,10,100),this.option.margin[0]=i(this.option.margin[0],0,100),this.option.margin[1]=i(this.option.margin[1],0,100),this.option.opacity=i(this.option.opacity,0,1),this.option.fontSize=i(this.option.fontSize,12,30),this.art.emit("artplayerPluginDanmuku:config",this.option)}},{key:"continue",value:function(){l(this.queue,"stop",(function(t){switch(t.$state="emit",t.$lastStartTime=Date.now(),t.mode){case 0:t.$ref.style.transform="translateX(".concat(-t.$restWidth,"px) translateY(0px) translateZ(0px)"),t.$ref.style.transition="transform ".concat(t.$restTime,"s linear 0s")}}))}},{key:"suspend",value:function(){var t=this.art.template.$player;l(this.queue,"emit",(function(e){switch(e.$state="stop",e.mode){case 0:var n=c(t),i=n.left,r=n.width-(c(e.$ref).left-i)+5;e.$ref.style.transform="translateX(".concat(-r,"px) translateY(0px) translateZ(0px)"),e.$ref.style.transition="transform 0s linear 0s"}}))}},{key:"resize",value:function(){var t=c(this.art.template.$player,"width");l(this.queue,"wait",(function(e){e.$ref&&(e.$ref.style.border="none",e.$ref.style.left="".concat(t,"px"),e.$ref.style.marginLeft="0px",e.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",e.$ref.style.transition="transform 0s linear 0s")}))}},{key:"update",value:function(){var t=this,e=this.art,n=e.player,i=e.template.$player;this.animationFrameTimer=window.requestAnimationFrame((function(){if(n.playing&&!t.isHide){var e=c(i,"width");l(t.queue,"emit",(function(t){t.$restTime-=(Date.now()-t.$lastStartTime)/1e3,t.$lastStartTime=Date.now(),t.$restTime<=0&&(t.$state="wait",t.$ref.style.border="none",t.$ref.style.left="".concat(e,"px"),t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",t.$ref.style.transition="transform 0s linear 0s")})),t.queue.filter((function(t){return n.currentTime+.1>=t.time&&t.time>=n.currentTime-.1&&"wait"===t.$state})).forEach((function(i){i.$ref=function(t){var e=t.find((function(t){return t.$ref&&"wait"===t.$state}));if(e){var n=e.$ref;return e.$ref=null,n}var i=document.createElement("div");return i.style.cssText='\n user-select: none;\n position: absolute;\n white-space: pre;\n pointer-events: none;\n perspective: 500px;\n display: inline-block;\n will-change: transform;\n font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;\n font-weight: normal;\n line-height: 1.125;\n text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;\n ',i}(t.queue),t.$danmuku.appendChild(i.$ref),i.$ref.style.opacity=t.option.opacity,i.$ref.style.fontSize="".concat(t.option.fontSize,"px"),i.$ref.innerText=i.text,i.$ref.style.color=i.color,i.$ref.style.border=i.border?"1px solid ".concat(i.color):"none",i.$restTime=t.option.synchronousPlayback&&n.playbackRate?t.option.speed/Number(n.playbackRate):t.option.speed,i.$lastStartTime=Date.now();var r=c(i.$ref,"width"),a=g(t,i);switch(i.$state="emit",i.mode){case 0:i.$restWidth=e+r+5,i.$ref.style.left="".concat(e,"px"),i.$ref.style.top="".concat(a,"px"),i.$ref.style.transform="translateX(".concat(-i.$restWidth,"px) translateY(0px) translateZ(0px)"),i.$ref.style.transition="transform ".concat(i.$restTime,"s linear 0s");break;case 1:i.$ref.style.top="".concat(a,"px"),i.$ref.style.left="50%",i.$ref.style.marginLeft="-".concat(r/2,"px")}}))}t.isStop||t.update()}))}},{key:"stop",value:function(){this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.animationFrameTimer),this.art.emit("artplayerPluginDanmuku:stop")}},{key:"start",value:function(){this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start")}},{key:"show",value:function(){this.isHide=!1,this.$danmuku.style.display="block",this.art.emit("artplayerPluginDanmuku:show")}},{key:"hide",value:function(){this.isHide=!0,this.$danmuku.style.display="none",this.art.emit("artplayerPluginDanmuku:hide")}},{key:"emit",value:function(e){var n=this.art,i=n.notice,r=n.player,a=n.i18n;e.text.trim()?e.text.length>this.option.maxlength?i.show="".concat(a.get("The length of the danmu does not exceed")," ").concat(this.option.maxlength):("number"!=typeof e.time&&(e.time=r.currentTime),this.queue.push(function(e){for(var n=1;n'.concat(e.get("Danmu opacity"),': 100%
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=100*Number(e),t.plugins.artplayerPluginDanmuku.config({opacity:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.opacity&&(i.value=t.opacity,r.innerText=100*t.opacity)}))}}}function o(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-size",index:11,html:'
'.concat(e.get("Danmu size"),': 25px
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({fontSize:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.fontSize&&(i.value=t.fontSize,r.innerText=t.fontSize)}))}}}function u(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-speed",index:12,html:'
'.concat(e.get("Danmu speed"),': 5s
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({speed:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.speed&&(i.value=t.speed,r.innerText=t.speed)}))}}}function s(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-synchronousPlayback",index:13,html:'"),mounted:function(e){var i=e.querySelector("input[type=checkbox]");n(i,"change",(function(){t.plugins.artplayerPluginDanmuku.config({synchronousPlayback:i.checked})})),t.on("artplayerPluginDanmuku:config",(function(t){i.checked!==t.synchronousPlayback&&(i.checked=t.synchronousPlayback)}))}}}function l(t,e,n){return t.filter((function(t){return t.$state===e})).map(n)}function c(t,e){var n=t.getBoundingClientRect();return e?n[e]:n}var p=function(t){if(Array.isArray(t))return t};var f=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],i=!0,r=!1,a=void 0;try{for(var o,u=t[Symbol.iterator]();!(i=(o=u.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){r=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(r)throw a}}return n}};var m=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var h=function(t,e){return p(t)||f(t,e)||m()};function d(t){switch(t){case 1:case 2:case 3:return 0;case 4:case 5:return 1;default:return 0}}function y(t){return fetch(t).then((function(t){return t.text()})).then((function(t){return function(t){if("string"!=typeof t)return[];var e=t.match(/[\S ]*?)<\/d>/gi);return e.length?e.map((function(t){var e=t.match(/(.+)<\/d>/),n=h(e,3),i=n[1],r=n[2],a=i.split(",");return 8===a.length&&r.trim()?{text:r,time:Number(a[0]),mode:d(Number(a[1])),fontSize:Number(a[2]),color:"#".concat(Number(a[3]).toString(16)),timestamp:Number(a[4]),pool:Number(a[5]),userID:a[6],rowID:Number(a[7])}:null})):[]}(t)}))}function g(t,e){var n=h(t.option.margin,2),i=n[0],r=n[1],a=c(t.art.template.$player),o=t.queue.filter((function(t){return t.mode===e.mode&&"emit"===t.$state&&t.$ref&&t.$ref.style.fontSize===e.$ref.style.fontSize&&parseFloat(t.$ref.style.top)<=a.height-r})).map((function(t){var e=c(t.$ref),n=e.width,i=e.height,r=e.top-a.top,o=e.left-a.left;return{top:r,left:o,height:i,width:n,right:a.width-o-n}})).sort((function(t,e){return t.top-e.top}));return 0===o.length?i:(o.unshift({top:0,left:0,right:0,height:i,width:a.width}),o.push({top:a.height-r,left:0,right:0,height:r,width:a.width}),function(t){for(var e=0,n={},i=0;io&&(e=c,o=p)}if(0===e)for(var f=0,m=0;mf)f=d,e=h(g,1)[0].top}if(0===e){var x=a.filter((function(t,e){return 0!==e&&e!==a.length-1})).sort((function(t,e){return n[t].length-n[e].length}));e=h(x,1)[0]}return e}(o))}function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}var b=function(){function n(t,i){var l=this;e(this,n),t.i18n.update(r),t.setting.add(a),t.setting.add(o),t.setting.add(u),t.setting.add(s),this.art=t,this.queue=[],this.option={},this.config(i),this.isStop=!1,this.isHide=!1,this.animationFrameTimer=null,this.$danmuku=t.template.$danmuku,t.on("video:play",this.start.bind(this)),t.on("video:playing",this.start.bind(this)),t.on("video:pause",this.stop.bind(this)),t.on("video:waiting",this.stop.bind(this)),t.on("resize",this.resize.bind(this)),t.on("destroy",this.stop.bind(this)),"function"==typeof this.option.danmuku?this.option.danmuku().then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):"string"==typeof this.option.danmuku?y(this.option.danmuku).then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):(this.option.danmuku.forEach(this.emit.bind(this)),t.emit("artplayerPluginDanmuku:loaded"))}return i(n,[{key:"config",value:function(t){var e=this.art.constructor,i=e.utils.clamp,r=e.validator;this.option=Object.assign({},n.option,this.option,t),r(this.option,n.scheme),this.option.speed=i(this.option.speed,1,10),this.option.maxlength=i(this.option.maxlength,10,100),this.option.margin[0]=i(this.option.margin[0],0,100),this.option.margin[1]=i(this.option.margin[1],0,100),this.option.opacity=i(this.option.opacity,0,1),this.option.fontSize=i(this.option.fontSize,12,30),this.art.emit("artplayerPluginDanmuku:config",this.option)}},{key:"continue",value:function(){l(this.queue,"stop",(function(t){switch(t.$state="emit",t.$lastStartTime=Date.now(),t.mode){case 0:t.$ref.style.transform="translateX(".concat(-t.$restWidth,"px) translateY(0px) translateZ(0px)"),t.$ref.style.transition="transform ".concat(t.$restTime,"s linear 0s")}}))}},{key:"suspend",value:function(){var t=this.art.template.$player;l(this.queue,"emit",(function(e){switch(e.$state="stop",e.mode){case 0:var n=c(t),i=n.left,r=n.width-(c(e.$ref).left-i)+5;e.$ref.style.transform="translateX(".concat(-r,"px) translateY(0px) translateZ(0px)"),e.$ref.style.transition="transform 0s linear 0s"}}))}},{key:"resize",value:function(){var t=c(this.art.template.$player,"width");l(this.queue,"wait",(function(e){e.$ref&&(e.$ref.style.border="none",e.$ref.style.left="".concat(t,"px"),e.$ref.style.marginLeft="0px",e.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",e.$ref.style.transition="transform 0s linear 0s")}))}},{key:"update",value:function(){var t=this,e=this.art,n=e.player,i=e.template.$player;this.animationFrameTimer=window.requestAnimationFrame((function(){if(n.playing&&!t.isHide){var e=c(i,"width");l(t.queue,"emit",(function(t){t.$restTime-=(Date.now()-t.$lastStartTime)/1e3,t.$lastStartTime=Date.now(),t.$restTime<=0&&(t.$state="wait",t.$ref.style.border="none",t.$ref.style.left="".concat(e,"px"),t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",t.$ref.style.transition="transform 0s linear 0s")})),t.queue.filter((function(t){return n.currentTime+.1>=t.time&&t.time>=n.currentTime-.1&&"wait"===t.$state})).forEach((function(i){i.$ref=function(t){var e=t.find((function(t){return t.$ref&&"wait"===t.$state}));if(e){var n=e.$ref;return e.$ref=null,n}var i=document.createElement("div");return i.style.cssText='\n user-select: none;\n position: absolute;\n white-space: pre;\n pointer-events: none;\n perspective: 500px;\n display: inline-block;\n will-change: transform;\n font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;\n font-weight: normal;\n line-height: 1.125;\n text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;\n ',i}(t.queue),t.$danmuku.appendChild(i.$ref),i.$ref.style.opacity=t.option.opacity,i.$ref.style.fontSize="".concat(t.option.fontSize,"px"),i.$ref.innerText=i.text,i.$ref.style.color=i.color||"#fff",i.$ref.style.border=i.border?"1px solid ".concat(i.color||"#fff"):"none",i.$restTime=t.option.synchronousPlayback&&n.playbackRate?t.option.speed/Number(n.playbackRate):t.option.speed,i.$lastStartTime=Date.now();var r=c(i.$ref,"width"),a=g(t,i);switch(i.$state="emit",i.mode){case 0:i.$restWidth=e+r+5,i.$ref.style.left="".concat(e,"px"),i.$ref.style.top="".concat(a,"px"),i.$ref.style.transform="translateX(".concat(-i.$restWidth,"px) translateY(0px) translateZ(0px)"),i.$ref.style.transition="transform ".concat(i.$restTime,"s linear 0s");break;case 1:i.$ref.style.top="".concat(a,"px"),i.$ref.style.left="50%",i.$ref.style.marginLeft="-".concat(r/2,"px")}}))}t.isStop||t.update()}))}},{key:"stop",value:function(){this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.animationFrameTimer),this.art.emit("artplayerPluginDanmuku:stop")}},{key:"start",value:function(){this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start")}},{key:"show",value:function(){this.isHide=!1,this.$danmuku.style.display="block",this.art.emit("artplayerPluginDanmuku:show")}},{key:"hide",value:function(){this.isHide=!0,this.$danmuku.style.display="none",this.art.emit("artplayerPluginDanmuku:hide")}},{key:"emit",value:function(e){var n=this.art,i=n.notice,r=n.player,a=n.i18n,o=this.art.constructor,u=o.utils.clamp;(0,o.validator)(e,{text:"string",mode:"number|undefined",color:"string|undefined",time:"number|undefined",border:"boolean|undefined"}),e.text.trim()?e.text.length>this.option.maxlength?i.show="".concat(a.get("The length of the danmu does not exceed")," ").concat(this.option.maxlength):(e.time?e.time=u(e.time,0,1/0):e.time=r.currentTime+.5,this.queue.push(function(e){for(var n=1;n'.concat(e.get("Danmu opacity"),': 100%
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=100*Number(e),t.plugins.artplayerPluginDanmuku.config({opacity:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.opacity&&(i.value=t.opacity,r.innerText=100*t.opacity)}))}}}function o(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-size",index:11,html:'
'.concat(e.get("Danmu size"),': 25px
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({fontSize:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.fontSize&&(i.value=t.fontSize,r.innerText=t.fontSize)}))}}}function s(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-speed",index:12,html:'
'.concat(e.get("Danmu speed"),': 5s
'),mounted:function(e){var i=e.querySelector("input[type=range]"),r=e.querySelector(".art-value");n(i,"change",(function(){var e=i.value;r.innerText=e,t.plugins.artplayerPluginDanmuku.config({speed:Number(e)})})),t.on("artplayerPluginDanmuku:config",(function(t){i.value!==t.speed&&(i.value=t.speed,r.innerText=t.speed)}))}}}function u(t){var e=t.i18n,n=t.events.proxy;return{name:"danmuku-synchronousPlayback",index:13,html:'"),mounted:function(e){var i=e.querySelector("input[type=checkbox]");n(i,"change",(function(){t.plugins.artplayerPluginDanmuku.config({synchronousPlayback:i.checked})})),t.on("artplayerPluginDanmuku:config",(function(t){i.checked!==t.synchronousPlayback&&(i.checked=t.synchronousPlayback)}))}}}function l(t,e,n){return t.filter((function(t){return t.$state===e})).map(n)}function c(t,e){var n=t.getBoundingClientRect();return e?n[e]:n}var p=function(t){if(Array.isArray(t))return t};var f=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],i=!0,r=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){r=!0,a=t}finally{try{i||null==s.return||s.return()}finally{if(r)throw a}}return n}};var h=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var m=function(t,e){return p(t)||f(t,e)||h()};function d(t){switch(t){case 1:case 2:case 3:return 0;case 4:case 5:return 1;default:return 0}}function y(t){return fetch(t).then((function(t){return t.text()})).then((function(t){return function(t){if("string"!=typeof t)return[];var e=t.match(/[\S ]*?)<\/d>/gi);return e.length?e.map((function(t){var e=t.match(/(.+)<\/d>/),n=m(e,3),i=n[1],r=n[2],a=i.split(",");return 8===a.length&&r.trim()?{text:r,time:Number(a[0]),mode:d(Number(a[1])),fontSize:Number(a[2]),color:"#".concat(Number(a[3]).toString(16)),timestamp:Number(a[4]),pool:Number(a[5]),userID:a[6],rowID:Number(a[7])}:null})):[]}(t)}))}function g(t,e){var n=m(t.option.margin,2),i=n[0],r=n[1],a=c(t.art.template.$player),o=t.queue.filter((function(t){return t.mode===e.mode&&"emit"===t.$state&&t.$ref&&t.$ref.style.fontSize===e.$ref.style.fontSize&&parseFloat(t.$ref.style.top)<=a.height-r})).map((function(t){var e=c(t.$ref),n=e.width,i=e.height,r=e.top-a.top,o=e.left-a.left;return{top:r,left:o,height:i,width:n,right:a.width-o-n}})).sort((function(t,e){return t.top-e.top}));return 0===o.length?i:(o.unshift({top:0,left:0,right:0,height:i,width:a.width}),o.push({top:a.height-r,left:0,right:0,height:r,width:a.width}),function(t){for(var e=0,n={},i=0;io&&(e=c,o=p)}if(0===e)for(var f=0,h=0;hf)f=d,e=m(g,1)[0].top}if(0===e){var x=a.filter((function(t,e){return 0!==e&&e!==a.length-1})).sort((function(t,e){return n[t].length-n[e].length}));e=m(x,1)[0]}return e}(o))}function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}var b=function(){function n(t,i){var l=this;e(this,n),t.i18n.update(r),t.setting.add(a),t.setting.add(o),t.setting.add(s),t.setting.add(u),this.art=t,this.queue=[],this.option={},this.config(i),this.isStop=!1,this.isHide=!1,this.animationFrameTimer=null,this.$danmuku=t.template.$danmuku,t.on("video:play",this.start.bind(this)),t.on("video:playing",this.start.bind(this)),t.on("video:pause",this.stop.bind(this)),t.on("video:waiting",this.stop.bind(this)),t.on("resize",this.resize.bind(this)),t.on("destroy",this.stop.bind(this)),"function"==typeof this.option.danmuku?this.option.danmuku().then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):"string"==typeof this.option.danmuku?y(this.option.danmuku).then((function(e){e.forEach(l.emit.bind(l)),t.emit("artplayerPluginDanmuku:loaded")})):(this.option.danmuku.forEach(this.emit.bind(this)),t.emit("artplayerPluginDanmuku:loaded"))}return i(n,[{key:"config",value:function(t){var e=this.art.constructor,i=e.utils.clamp,r=e.validator;this.option=Object.assign({},n.option,this.option,t),r(this.option,n.scheme),this.option.speed=i(this.option.speed,1,10),this.option.maxlength=i(this.option.maxlength,10,100),this.option.margin[0]=i(this.option.margin[0],0,100),this.option.margin[1]=i(this.option.margin[1],0,100),this.option.opacity=i(this.option.opacity,0,1),this.option.fontSize=i(this.option.fontSize,12,30),this.art.emit("artplayerPluginDanmuku:config",this.option)}},{key:"continue",value:function(){l(this.queue,"stop",(function(t){switch(t.$state="emit",t.$lastStartTime=Date.now(),t.mode){case 0:t.$ref.style.transform="translateX(".concat(-t.$restWidth,"px) translateY(0px) translateZ(0px)"),t.$ref.style.transition="transform ".concat(t.$restTime,"s linear 0s")}}))}},{key:"suspend",value:function(){var t=this.art.template.$player;l(this.queue,"emit",(function(e){switch(e.$state="stop",e.mode){case 0:var n=c(t),i=n.left,r=n.width-(c(e.$ref).left-i)+5;e.$ref.style.transform="translateX(".concat(-r,"px) translateY(0px) translateZ(0px)"),e.$ref.style.transition="transform 0s linear 0s"}}))}},{key:"resize",value:function(){var t=c(this.art.template.$player,"width");l(this.queue,"wait",(function(e){e.$ref&&(e.$ref.style.border="none",e.$ref.style.left="".concat(t,"px"),e.$ref.style.marginLeft="0px",e.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",e.$ref.style.transition="transform 0s linear 0s")}))}},{key:"update",value:function(){var t=this,e=this.art,n=e.player,i=e.template.$player;this.animationFrameTimer=window.requestAnimationFrame((function(){if(n.playing&&!t.isHide){var e=c(i,"width");l(t.queue,"emit",(function(t){t.$restTime-=(Date.now()-t.$lastStartTime)/1e3,t.$lastStartTime=Date.now(),t.$restTime<=0&&(t.$state="wait",t.$ref.style.border="none",t.$ref.style.left="".concat(e,"px"),t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px) translateY(0px) translateZ(0px)",t.$ref.style.transition="transform 0s linear 0s")})),t.queue.filter((function(t){return n.currentTime+.1>=t.time&&t.time>=n.currentTime-.1&&"wait"===t.$state})).forEach((function(i){i.$ref=function(t){var e=t.find((function(t){return t.$ref&&"wait"===t.$state}));if(e){var n=e.$ref;return e.$ref=null,n}var i=document.createElement("div");return i.style.cssText='\n user-select: none;\n position: absolute;\n white-space: pre;\n pointer-events: none;\n perspective: 500px;\n display: inline-block;\n will-change: transform;\n font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;\n font-weight: normal;\n line-height: 1.125;\n text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;\n ',i}(t.queue),t.$danmuku.appendChild(i.$ref),i.$ref.style.opacity=t.option.opacity,i.$ref.style.fontSize="".concat(t.option.fontSize,"px"),i.$ref.innerText=i.text,i.$ref.style.color=i.color,i.$ref.style.border=i.border?"1px solid ".concat(i.color):"none",i.$restTime=t.option.synchronousPlayback&&n.playbackRate?t.option.speed/Number(n.playbackRate):t.option.speed,i.$lastStartTime=Date.now();var r=c(i.$ref,"width"),a=g(t,i);switch(i.$state="emit",i.mode){case 0:i.$restWidth=e+r+5,i.$ref.style.left="".concat(e,"px"),i.$ref.style.top="".concat(a,"px"),i.$ref.style.transform="translateX(".concat(-i.$restWidth,"px) translateY(0px) translateZ(0px)"),i.$ref.style.transition="transform ".concat(i.$restTime,"s linear 0s");break;case 1:i.$ref.style.top="".concat(a,"px"),i.$ref.style.left="50%",i.$ref.style.marginLeft="-".concat(r/2,"px")}}))}t.isStop||t.update()}))}},{key:"stop",value:function(){this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.animationFrameTimer),this.art.emit("artplayerPluginDanmuku:stop")}},{key:"start",value:function(){this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start")}},{key:"show",value:function(){this.isHide=!1,this.$danmuku.style.display="block",this.art.emit("artplayerPluginDanmuku:show")}},{key:"hide",value:function(){this.isHide=!0,this.$danmuku.style.display="none",this.art.emit("artplayerPluginDanmuku:hide")}},{key:"emit",value:function(e){var n=this.art,i=n.notice,r=n.player,a=n.i18n;e.text.trim()?e.text.length>this.option.maxlength?i.show="".concat(a.get("The length of the danmu does not exceed")," ").concat(this.option.maxlength):("number"!=typeof e.time&&(e.time=r.currentTime),this.queue.push(function(e){for(var n=1;n