mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 04:36:15 -08:00
update
This commit is contained in:
1 parent
c4b4d4e7a8
commit
3fc4b99841
15 files changed
+39
-7438
No files matched your search
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/*!
|
||||
* artplayer-plugin-danmuku.js v4.3.0
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer#readme
|
||||
* (c) 2017-2022 Harvey Zack
|
||||
* 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="undefined"!=typeof globalThis?globalThis:t||self).artplayerPluginDanmuku=e()}(this,(function(){"use strict";function t(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var n={"zh-cn":{"Danmu opacity":"弹幕透明度","Danmu speed":"弹幕速度","Danmu size":"弹幕大小","Danmu text cannot be empty":"弹幕文本不能为空","The length of the danmu does not exceed":"弹幕文本字数不能超过","Danmu speed synchronous playback multiple":"弹幕速度同步播放倍数"},"zh-tw":{"Danmu opacity":"彈幕透明度","Danmu speed":"彈幕速度","Danmu size":"弹幕大小","Danmu text cannot be empty":"彈幕文本不能為空","The length of the danmu does not exceed":"彈幕文本字數不能超過","Danmu speed synchronous playback multiple":"彈幕速度同步播放倍數"}};function r(t,e,n){return t.filter((function(t){return t.$state===e})).map(n)}function i(t,e){var n=t.getBoundingClientRect();return e?n[e]:n}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t){switch(t){case 1:case 2:case 3:default:return 0;case 4:case 5:return 1}}function u(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(/<d([\S ]*?>[\S ]*?)<\/d>/gi);return e&&e.length?e.map((function(t){var e=a(t.match(/<d p="(.+)">(.+)<\/d>/),3),n=e[1],r=e[2],i=n.split(",");return 8===i.length&&r.trim()?{text:r,time:Number(i[0]),mode:s(Number(i[1])),fontSize:Number(i[2]),color:"#".concat(Number(i[3]).toString(16)),timestamp:Number(i[4]),pool:Number(i[5]),userID:i[6],rowID:Number(i[7])}:null})):[]}(t)}))}function l(t,e){var n=a(t.option.margin,2),r=n[0],o=n[1],s=i(t.art.template.$player),u=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)<=s.height-o})).map((function(t){var e=i(t.$ref),n=e.width,r=e.height,o=e.top-s.top,a=e.left-s.left;return{top:o,left:a,height:r,width:n,right:s.width-a-n}})).sort((function(t,e){return t.top-e.top}));return 0===u.length?r:(u.unshift({top:0,left:0,right:0,height:r,width:s.width}),u.push({top:s.height-o,left:0,right:0,height:o,width:s.width}),function(t){for(var e=0,n={},r=0;r<t.length;r+=1){var i=t[r];n[i.top]?n[i.top].push(i):n[i.top]=[i]}for(var o=Object.keys(n),s=0,u=1;u<t.length;u+=1){var l=t[u],f=t[u-1],c=f.top+f.height,p=l.top-c;p>s&&(e=c,s=p)}if(0===e)for(var h=0,m=0;m<o.length;m+=1){for(var d=t[0].width,y=o[m],g=n[y],b=0;b<g.length;b+=1){var $=g[b];$.right<d&&(d=$.right)}d>h&&(h=d,e=a(g,1)[0].top)}if(0===e){var v=o.filter((function(t,e){return 0!==e&&e!==o.length-1})).sort((function(t,e){return n[t].length-n[e].length}));e=a(v,1)[0]}return e}(u))}function f(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?f(Object(r),!0).forEach((function(n){t(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.i18n.update(n),this.art=e,this.queue=[],this.option={},this.config(r),this.isStop=!1,this.isHide=!1,this.animationFrameTimer=null,this.$danmuku=e.template.$danmuku,e.on("video:play",this.start.bind(this)),e.on("video:playing",this.start.bind(this)),e.on("video:pause",this.stop.bind(this)),e.on("video:waiting",Line truncated
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/*!
|
||||
* artplayer-tool-thumbnail.js v4.0.0
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer#readme
|
||||
* (c) 2017-2022 Harvey Zack
|
||||
* 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="undefined"!=typeof globalThis?globalThis:t||self).ArtplayerToolThumbnail=e()}(this,(function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function n(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t,e){return i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function r(t,e){if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return n(t)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}var s={exports:{}};function u(){}function l(t,e,n){return Math.max(Math.min(t,Math.max(e,n)),Math.min(e,n))}function c(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,i=a(t);if(e){var o=a(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return r(this,n)}}u.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this;function o(){i.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;i<o;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,a=i.length;r<a;r++)i[r].fn!==e&&i[r].fn._!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}},s.exports=u,s.exports.TinyEmitter=u;var h=function(o){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(h,o);var r,a,s,u=c(h);function h(){var e,i=arguments.length>0&&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.endLine truncated
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/*!
|
||||
* artplayer.js v4.3.11
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer#readme
|
||||
* (c) 2017-2022 Harvey Zack
|
||||
* 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="undefined"!=typeof globalThis?globalThis:t||self).Artplayer=e()}(this,(function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function o(t,e){return o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(t,e)}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function c(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return n(t)}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}!function(t,e){void 0===e&&(e={});var r=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}('.art-video-player{zoom:1;-webkit-tap-highlight-color:rgba(0,0,0,0);-ms-high-contrast-adjust:none;background-color:#000;color:#eee;direction:ltr;display:flex;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:14px;height:100%;line-height:1.3;margin:0 auto;outline:0;position:relative;text-align:left;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%;z-index:20}.art-video-player *{box-sizing:border-box;margin:0;padding:0}.art-video-player ::-webkit-scrollbar{height:5px;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{align-items:center;display:inline-flex;justify-content:center;line-height:1.5}.art-video-player .art-icon svg{fill:#fff}.art-video-player img{max-width:100%;vertical-align:top}@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{background-color:#000;cursor:pointer;z-index:10}.art-video-player .art-poster,.art-video-player .art-video{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%}.art-video-player .art-poster{background-position:50%;background-repeat:no-repeat;background-size:cover;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:11}.art-video-player .art-subtitle{bottom:10px;color:#fff;display:none;font-size:20px;padding:0 20px;pointer-events:none;position:absolute;text-align:center;text-shadow:.5px .5px .5px rgba(0,0,0,.5);width:100%;z-index:20}.art-video-player .art-subtitle p{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;line-height:1.2;margin:5px 0 0;word-break:break-all}.art-video-player.art-subtitle-show .art-subtitle{display:block}.art-video-player.art-control-show .art-subtitle{bottom:50px}.art-video-player .art-danmuku{z-index:30}.art-video-player .art-danmuku,.art-video-player .art-layers{bottom:0;height:100%;left:0;overflow:hidden;pointer-events:none;position:absolute;right:0;top:0;width:100%}.art-video-player .art-layers{display:none;z-index:40}.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{align-items:center;bottom:0;display:none;height:100%;justify-content:center;left:0;overflow:hidden;pointer-events:none;position:absolute;right:0;top:0;width:100%;z-index:50}.art-video-player .art-mask .art-state{align-items:center;bottom:65px;cursor:pointer;display:flex;height:60px;justify-content:center;opacity:.85;pointer-events:all;position:absolute;right:30px;width:60px}.art-video-player.art-mask-show .art-mask{display:flex}.art-video-player.art-mobile .art-state{position:static}.art-video-player .art-loading{align-Line truncated
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
<p class="tip"></p>
|
||||
</div>
|
||||
<script src="./assets/js/vconsole.min.js"></script>
|
||||
<script src="./uncompiled/artplayer.js"></script>
|
||||
<script src="./uncompiled/artplayer/index.js"></script>
|
||||
<script>
|
||||
var vConsole = new VConsole();
|
||||
|
||||
|
||||
@@ -1,640 +0,0 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.artplayerPluginDanmuku = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
var i18n = {
|
||||
'zh-cn': {
|
||||
'Danmu opacity': '弹幕透明度',
|
||||
'Danmu speed': '弹幕速度',
|
||||
'Danmu size': '弹幕大小',
|
||||
'Danmu text cannot be empty': '弹幕文本不能为空',
|
||||
'The length of the danmu does not exceed': '弹幕文本字数不能超过',
|
||||
'Danmu speed synchronous playback multiple': '弹幕速度同步播放倍数'
|
||||
},
|
||||
'zh-tw': {
|
||||
'Danmu opacity': '彈幕透明度',
|
||||
'Danmu speed': '彈幕速度',
|
||||
'Danmu size': '弹幕大小',
|
||||
'Danmu text cannot be empty': '彈幕文本不能為空',
|
||||
'The length of the danmu does not exceed': '彈幕文本字數不能超過',
|
||||
'Danmu speed synchronous playback multiple': '彈幕速度同步播放倍數'
|
||||
}
|
||||
};
|
||||
|
||||
function filter(queue, state, callback) {
|
||||
return queue.filter(function (danmu) {
|
||||
return danmu.$state === state;
|
||||
}).map(callback);
|
||||
}
|
||||
function getRect(ref, key) {
|
||||
var result = ref.getBoundingClientRect();
|
||||
return key ? result[key] : result;
|
||||
}
|
||||
function getDanmuRef(queue) {
|
||||
var result = queue.find(function (danmu) {
|
||||
return danmu.$ref && danmu.$state === 'wait';
|
||||
});
|
||||
|
||||
if (result) {
|
||||
var _$ref = result.$ref;
|
||||
result.$ref = null;
|
||||
return _$ref;
|
||||
}
|
||||
|
||||
var $ref = document.createElement('div');
|
||||
$ref.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 ";
|
||||
return $ref;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
||||
|
||||
if (_i == null) return;
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
|
||||
var _s, _e;
|
||||
|
||||
try {
|
||||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayLikeToArray(arr, len) {
|
||||
if (len == null || len > arr.length) len = arr.length;
|
||||
|
||||
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
||||
arr2[i] = arr[i];
|
||||
}
|
||||
|
||||
return arr2;
|
||||
}
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) {
|
||||
if (!o) return;
|
||||
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
||||
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||||
if (n === "Object" && o.constructor) n = o.constructor.name;
|
||||
if (n === "Map" || n === "Set") return Array.from(o);
|
||||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function getMode(key) {
|
||||
switch (key) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return 0;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
function bilibiliDanmuParseFromXml(xmlString) {
|
||||
if (typeof xmlString !== 'string') return [];
|
||||
var srtList = xmlString.match(/<d([\S ]*?>[\S ]*?)<\/d>/gi);
|
||||
return srtList && srtList.length ? srtList.map(function (item) {
|
||||
var _item$match = item.match(/<d p="(.+)">(.+)<\/d>/),
|
||||
_item$match2 = _slicedToArray(_item$match, 3),
|
||||
attrStr = _item$match2[1],
|
||||
text = _item$match2[2];
|
||||
|
||||
var attr = attrStr.split(',');
|
||||
return attr.length === 8 && text.trim() ? {
|
||||
text: text,
|
||||
time: Number(attr[0]),
|
||||
mode: getMode(Number(attr[1])),
|
||||
fontSize: Number(attr[2]),
|
||||
color: "#".concat(Number(attr[3]).toString(16)),
|
||||
timestamp: Number(attr[4]),
|
||||
pool: Number(attr[5]),
|
||||
userID: attr[6],
|
||||
rowID: Number(attr[7])
|
||||
} : null;
|
||||
}) : [];
|
||||
}
|
||||
function bilibiliDanmuParseFromUrl(url) {
|
||||
return fetch(url).then(function (res) {
|
||||
return res.text();
|
||||
}).then(function (xmlString) {
|
||||
return bilibiliDanmuParseFromXml(xmlString);
|
||||
});
|
||||
}
|
||||
|
||||
function calculatedTop(danmus) {
|
||||
var top = 0;
|
||||
var topMap = {};
|
||||
|
||||
for (var index = 0; index < danmus.length; index += 1) {
|
||||
var item = danmus[index];
|
||||
|
||||
if (topMap[item.top]) {
|
||||
topMap[item.top].push(item);
|
||||
} else {
|
||||
topMap[item.top] = [item];
|
||||
}
|
||||
}
|
||||
|
||||
var topMapKeys = Object.keys(topMap);
|
||||
var maxDiff = 0;
|
||||
|
||||
for (var _index = 1; _index < danmus.length; _index += 1) {
|
||||
var _item = danmus[_index];
|
||||
var prev = danmus[_index - 1];
|
||||
var prevTop = prev.top + prev.height;
|
||||
var diff = _item.top - prevTop;
|
||||
|
||||
if (diff > maxDiff) {
|
||||
top = prevTop;
|
||||
maxDiff = diff;
|
||||
}
|
||||
}
|
||||
|
||||
if (top === 0) {
|
||||
var maxRight = 0;
|
||||
|
||||
for (var _index2 = 0; _index2 < topMapKeys.length; _index2 += 1) {
|
||||
var minRight = danmus[0].width;
|
||||
var topKey = topMapKeys[_index2];
|
||||
var danmuArr = topMap[topKey];
|
||||
|
||||
for (var _index3 = 0; _index3 < danmuArr.length; _index3 += 1) {
|
||||
var danmu = danmuArr[_index3];
|
||||
|
||||
if (danmu.right < minRight) {
|
||||
minRight = danmu.right;
|
||||
}
|
||||
}
|
||||
|
||||
if (minRight > maxRight) {
|
||||
maxRight = minRight;
|
||||
|
||||
var _danmuArr = _slicedToArray(danmuArr, 1);
|
||||
|
||||
top = _danmuArr[0].top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (top === 0) {
|
||||
var _topMapKeys$filter$so = topMapKeys.filter(function (item, index) {
|
||||
return index !== 0 && index !== topMapKeys.length - 1;
|
||||
}).sort(function (prev, next) {
|
||||
return topMap[prev].length - topMap[next].length;
|
||||
});
|
||||
|
||||
var _topMapKeys$filter$so2 = _slicedToArray(_topMapKeys$filter$so, 1);
|
||||
|
||||
top = _topMapKeys$filter$so2[0];
|
||||
}
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
function getDanmuTop(ins, danmu) {
|
||||
var _ins$option$margin = _slicedToArray(ins.option.margin, 2),
|
||||
marginTop = _ins$option$margin[0],
|
||||
marginBottom = _ins$option$margin[1];
|
||||
|
||||
var playerData = getRect(ins.art.template.$player);
|
||||
var danmus = ins.queue.filter(function (item) {
|
||||
return item.mode === danmu.mode && item.$state === 'emit' && item.$ref && item.$ref.style.fontSize === danmu.$ref.style.fontSize && parseFloat(item.$ref.style.top) <= playerData.height - marginBottom;
|
||||
}).map(function (item) {
|
||||
var danmuData = getRect(item.$ref);
|
||||
var width = danmuData.width,
|
||||
height = danmuData.height;
|
||||
var top = danmuData.top - playerData.top;
|
||||
var left = danmuData.left - playerData.left;
|
||||
var right = playerData.width - left - width;
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
height: height,
|
||||
width: width,
|
||||
right: right
|
||||
};
|
||||
}).sort(function (prev, next) {
|
||||
return prev.top - next.top;
|
||||
});
|
||||
|
||||
if (danmus.length === 0) {
|
||||
return marginTop;
|
||||
}
|
||||
|
||||
danmus.unshift({
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: marginTop,
|
||||
width: playerData.width
|
||||
});
|
||||
danmus.push({
|
||||
top: playerData.height - marginBottom,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: marginBottom,
|
||||
width: playerData.width
|
||||
});
|
||||
return calculatedTop(danmus);
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
var Danmuku = /*#__PURE__*/function () {
|
||||
function Danmuku(art, option) {
|
||||
_classCallCheck(this, Danmuku);
|
||||
|
||||
art.i18n.update(i18n);
|
||||
this.art = art;
|
||||
this.queue = [];
|
||||
this.option = {};
|
||||
this.config(option);
|
||||
this.isStop = false;
|
||||
this.isHide = false;
|
||||
this.animationFrameTimer = null;
|
||||
this.$danmuku = art.template.$danmuku;
|
||||
art.on('video:play', this.start.bind(this));
|
||||
art.on('video:playing', this.start.bind(this));
|
||||
art.on('video:pause', this.stop.bind(this));
|
||||
art.on('video:waiting', this.stop.bind(this));
|
||||
art.on('resize', this.resize.bind(this));
|
||||
art.on('destroy', this.stop.bind(this));
|
||||
this.load();
|
||||
}
|
||||
|
||||
_createClass(Danmuku, [{
|
||||
key: "load",
|
||||
value: function load() {
|
||||
var _this = this;
|
||||
|
||||
if (typeof this.option.danmuku === 'function') {
|
||||
this.option.danmuku().then(function (danmus) {
|
||||
_this.queue = [];
|
||||
_this.$danmuku.innerText = '';
|
||||
danmus.forEach(_this.emit.bind(_this));
|
||||
|
||||
_this.art.emit('artplayerPluginDanmuku:loaded');
|
||||
});
|
||||
} else if (typeof this.option.danmuku === 'string') {
|
||||
bilibiliDanmuParseFromUrl(this.option.danmuku).then(function (danmus) {
|
||||
_this.queue = [];
|
||||
_this.$danmuku.innerText = '';
|
||||
danmus.forEach(_this.emit.bind(_this));
|
||||
|
||||
_this.art.emit('artplayerPluginDanmuku:loaded');
|
||||
});
|
||||
} else {
|
||||
this.queue = [];
|
||||
this.$danmuku.innerText = '';
|
||||
this.option.danmuku.forEach(this.emit.bind(this));
|
||||
this.art.emit('artplayerPluginDanmuku:loaded');
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "config",
|
||||
value: function config(option) {
|
||||
var _this$art$constructor = this.art.constructor,
|
||||
clamp = _this$art$constructor.utils.clamp,
|
||||
validator = _this$art$constructor.validator;
|
||||
this.option = Object.assign({}, Danmuku.option, this.option, option);
|
||||
validator(this.option, Danmuku.scheme);
|
||||
this.option.speed = clamp(this.option.speed, 1, 10);
|
||||
this.option.maxlength = clamp(this.option.maxlength, 10, 100);
|
||||
this.option.margin[0] = clamp(this.option.margin[0], 0, 100);
|
||||
this.option.margin[1] = clamp(this.option.margin[1], 0, 100);
|
||||
this.option.opacity = clamp(this.option.opacity, 0, 1);
|
||||
this.option.fontSize = clamp(this.option.fontSize, 12, 30);
|
||||
this.art.emit('artplayerPluginDanmuku:config', this.option);
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "continue",
|
||||
value: function _continue() {
|
||||
filter(this.queue, 'stop', function (danmu) {
|
||||
danmu.$state = 'emit';
|
||||
danmu.$lastStartTime = Date.now();
|
||||
|
||||
switch (danmu.mode) {
|
||||
case 0:
|
||||
danmu.$ref.style.transform = "translateX(".concat(-danmu.$restWidth, "px) translateY(0px) translateZ(0px)");
|
||||
danmu.$ref.style.transition = "transform ".concat(danmu.$restTime, "s linear 0s");
|
||||
break;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "suspend",
|
||||
value: function suspend() {
|
||||
var $player = this.art.template.$player;
|
||||
filter(this.queue, 'emit', function (danmu) {
|
||||
danmu.$state = 'stop';
|
||||
|
||||
switch (danmu.mode) {
|
||||
case 0:
|
||||
{
|
||||
var _getRect = getRect($player),
|
||||
playerLeft = _getRect.left,
|
||||
playerWidth = _getRect.width;
|
||||
|
||||
var _getRect2 = getRect(danmu.$ref),
|
||||
danmuLeft = _getRect2.left;
|
||||
|
||||
var translateX = playerWidth - (danmuLeft - playerLeft) + 5;
|
||||
danmu.$ref.style.transform = "translateX(".concat(-translateX, "px) translateY(0px) translateZ(0px)");
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "resize",
|
||||
value: function resize() {
|
||||
var $player = this.art.template.$player;
|
||||
var danmuLeft = getRect($player, 'width');
|
||||
filter(this.queue, 'wait', function (danmu) {
|
||||
if (danmu.$ref) {
|
||||
danmu.$ref.style.border = 'none';
|
||||
danmu.$ref.style.left = "".concat(danmuLeft, "px");
|
||||
danmu.$ref.style.marginLeft = '0px';
|
||||
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "update",
|
||||
value: function update() {
|
||||
var _this2 = this;
|
||||
|
||||
var $player = this.art.template.$player;
|
||||
this.animationFrameTimer = window.requestAnimationFrame(function () {
|
||||
if (_this2.art.playing && !_this2.isHide) {
|
||||
var danmuLeft = getRect($player, 'width');
|
||||
filter(_this2.queue, 'emit', function (danmu) {
|
||||
danmu.$restTime -= (Date.now() - danmu.$lastStartTime) / 1000;
|
||||
danmu.$lastStartTime = Date.now();
|
||||
|
||||
if (danmu.$restTime <= 0) {
|
||||
danmu.$state = 'wait';
|
||||
danmu.$ref.style.border = 'none';
|
||||
danmu.$ref.style.left = "".concat(danmuLeft, "px");
|
||||
danmu.$ref.style.marginLeft = '0px';
|
||||
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
}
|
||||
});
|
||||
|
||||
_this2.queue.filter(function (danmu) {
|
||||
return _this2.art.currentTime + 0.1 >= danmu.time && danmu.time >= _this2.art.currentTime - 0.1 && danmu.$state === 'wait';
|
||||
}).forEach(function (danmu) {
|
||||
danmu.$ref = getDanmuRef(_this2.queue);
|
||||
|
||||
_this2.$danmuku.appendChild(danmu.$ref);
|
||||
|
||||
danmu.$ref.style.opacity = _this2.option.opacity;
|
||||
danmu.$ref.style.fontSize = "".concat(_this2.option.fontSize, "px");
|
||||
danmu.$ref.innerText = danmu.text;
|
||||
danmu.$ref.style.color = danmu.color || '#fff';
|
||||
danmu.$ref.style.border = danmu.border ? "1px solid ".concat(danmu.color || '#fff') : 'none';
|
||||
danmu.$restTime = _this2.option.synchronousPlayback && _this2.art.playbackRate ? _this2.option.speed / Number(_this2.art.playbackRate) : _this2.option.speed;
|
||||
danmu.$lastStartTime = Date.now();
|
||||
var danmuWidth = getRect(danmu.$ref, 'width');
|
||||
var danmuTop = getDanmuTop(_this2, danmu);
|
||||
danmu.$state = 'emit';
|
||||
|
||||
switch (danmu.mode) {
|
||||
case 0:
|
||||
{
|
||||
danmu.$restWidth = danmuLeft + danmuWidth + 5;
|
||||
danmu.$ref.style.left = "".concat(danmuLeft, "px");
|
||||
danmu.$ref.style.top = "".concat(danmuTop, "px");
|
||||
danmu.$ref.style.transform = "translateX(".concat(-danmu.$restWidth, "px) translateY(0px) translateZ(0px)");
|
||||
danmu.$ref.style.transition = "transform ".concat(danmu.$restTime, "s linear 0s");
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
danmu.$ref.style.top = "".concat(danmuTop, "px");
|
||||
danmu.$ref.style.left = '50%';
|
||||
danmu.$ref.style.marginLeft = "-".concat(danmuWidth / 2, "px");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!_this2.isStop) {
|
||||
_this2.update();
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "stop",
|
||||
value: function stop() {
|
||||
this.isStop = true;
|
||||
this.suspend();
|
||||
window.cancelAnimationFrame(this.animationFrameTimer);
|
||||
this.art.emit('artplayerPluginDanmuku:stop');
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "start",
|
||||
value: function start() {
|
||||
this.isStop = false;
|
||||
this.continue();
|
||||
this.update();
|
||||
this.art.emit('artplayerPluginDanmuku:start');
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "show",
|
||||
value: function show() {
|
||||
this.isHide = false;
|
||||
this.$danmuku.style.display = 'block';
|
||||
this.art.emit('artplayerPluginDanmuku:show');
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "hide",
|
||||
value: function hide() {
|
||||
this.isHide = true;
|
||||
this.$danmuku.style.display = 'none';
|
||||
this.art.emit('artplayerPluginDanmuku:hide');
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "emit",
|
||||
value: function emit(danmu) {
|
||||
var _this$art = this.art,
|
||||
notice = _this$art.notice,
|
||||
i18n = _this$art.i18n;
|
||||
var _this$art$constructor2 = this.art.constructor,
|
||||
clamp = _this$art$constructor2.utils.clamp,
|
||||
validator = _this$art$constructor2.validator;
|
||||
validator(danmu, {
|
||||
text: 'string',
|
||||
mode: 'number|undefined',
|
||||
color: 'string|undefined',
|
||||
time: 'number|undefined',
|
||||
border: 'boolean|undefined'
|
||||
});
|
||||
|
||||
if (!danmu.text.trim()) {
|
||||
notice.show = i18n.get('Danmu text cannot be empty');
|
||||
return this;
|
||||
}
|
||||
|
||||
if (danmu.text.length > this.option.maxlength) {
|
||||
notice.show = "".concat(i18n.get('The length of the danmu does not exceed'), " ").concat(this.option.maxlength);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (danmu.time) {
|
||||
danmu.time = clamp(danmu.time, 0, Infinity);
|
||||
} else {
|
||||
danmu.time = this.art.currentTime + 0.5;
|
||||
}
|
||||
|
||||
this.queue.push(_objectSpread(_objectSpread({
|
||||
mode: 0
|
||||
}, danmu), {}, {
|
||||
$state: 'wait',
|
||||
$ref: null,
|
||||
$restTime: 0,
|
||||
$lastStartTime: 0,
|
||||
$restWidth: 0
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
}], [{
|
||||
key: "option",
|
||||
get: function get() {
|
||||
return {
|
||||
danmuku: [],
|
||||
speed: 5,
|
||||
maxlength: 50,
|
||||
margin: [10, 100],
|
||||
opacity: 1,
|
||||
fontSize: 25,
|
||||
synchronousPlayback: false
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "scheme",
|
||||
get: function get() {
|
||||
return {
|
||||
danmuku: 'array|function|string',
|
||||
speed: 'number',
|
||||
maxlength: 'number',
|
||||
margin: 'array',
|
||||
opacity: 'number',
|
||||
fontSize: 'number',
|
||||
synchronousPlayback: 'boolean'
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return Danmuku;
|
||||
}();
|
||||
|
||||
function artplayerPluginDanmuku(option) {
|
||||
return function (art) {
|
||||
var danmuku = new Danmuku(art, option);
|
||||
return {
|
||||
name: 'artplayerPluginDanmuku',
|
||||
emit: danmuku.emit.bind(danmuku),
|
||||
config: danmuku.config.bind(danmuku),
|
||||
hide: danmuku.hide.bind(danmuku),
|
||||
show: danmuku.show.bind(danmuku),
|
||||
|
||||
get isHide() {
|
||||
return danmuku.isHide;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
return artplayerPluginDanmuku;
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=artplayer-plugin-danmuku.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"artplayer-plugin-danmuku.js","sources":["../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/defineProperty.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/classCallCheck.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/createClass.js","../../packages/artplayer-plugin-danmuku/src/i18n.js","../../packages/artplayer-plugin-danmuku/src/utils.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/arrayWithHoles.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/iterableToArrayLimit.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/arrayLikeToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/nonIterableRest.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/slicedToArray.js","../../packages/artplayer-plugin-danmuku/src/bilibili.js","../../packages/artplayer-plugin-danmuku/src/getDanmuTop.js","../../packages/artplayer-plugin-danmuku/src/danmuku.js","../../packages/artplayer-plugin-danmuku/src/index.js"],"sourcesContent":["export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}","export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}","export default {\n 'zh-cn': {\n 'Danmu opacity': '弹幕透明度',\n 'Danmu speed': '弹幕速度',\n 'Danmu size': '弹幕大小',\n 'Danmu text cannot be empty': '弹幕文本不能为空',\n 'The length of the danmu does not exceed': '弹幕文本字数不能超过',\n 'Danmu speed synchronous playback multiple': '弹幕速度同步播放倍数',\n },\n 'zh-tw': {\n 'Danmu opacity': '彈幕透明度',\n 'Danmu speed': '彈幕速度',\n 'Danmu size': '弹幕大小',\n 'Danmu text cannot be empty': '彈幕文本不能為空',\n 'The length of the danmu does not exceed': '彈幕文本字數不能超過',\n 'Danmu speed synchronous playback multiple': '彈幕速度同步播放倍數',\n },\n};","export function filter(queue, state, callback) {\n return queue.filter(danmu => danmu.$state === state).map(callback);\n}\n\nexport function getRect(ref, key) {\n const result = ref.getBoundingClientRect();\n return key ? result[key] : result;\n}\n\nexport function getDanmuRef(queue) {\n const result = queue.find(danmu => {\n return danmu.$ref && danmu.$state === 'wait';\n });\n\n if (result) {\n const { $ref } = result;\n result.$ref = null;\n return $ref;\n }\n\n const $ref = document.createElement('div');\n $ref.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 `;\n\n return $ref;\n}","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _iterableToArrayLimit(arr, i) {\n var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"];\n\n if (_i == null) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n\n var _s, _e;\n\n try {\n for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}","export default function _arrayLikeToArray(arr, Line truncated
|
||||
@@ -1,471 +0,0 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ArtplayerToolThumbnail = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
function _assertThisInitialized(self) {
|
||||
if (self === void 0) {
|
||||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
function _setPrototypeOf(o, p) {
|
||||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
||||
o.__proto__ = p;
|
||||
return o;
|
||||
};
|
||||
|
||||
return _setPrototypeOf(o, p);
|
||||
}
|
||||
|
||||
function _inherits(subClass, superClass) {
|
||||
if (typeof superClass !== "function" && superClass !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function");
|
||||
}
|
||||
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
constructor: {
|
||||
value: subClass,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superClass) _setPrototypeOf(subClass, superClass);
|
||||
}
|
||||
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function _typeof(obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
_typeof = function _typeof(obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function _possibleConstructorReturn(self, call) {
|
||||
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||
return call;
|
||||
} else if (call !== void 0) {
|
||||
throw new TypeError("Derived constructors may only return object or undefined");
|
||||
}
|
||||
|
||||
return _assertThisInitialized(self);
|
||||
}
|
||||
|
||||
function _getPrototypeOf(o) {
|
||||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
||||
return o.__proto__ || Object.getPrototypeOf(o);
|
||||
};
|
||||
return _getPrototypeOf(o);
|
||||
}
|
||||
|
||||
var tinyEmitter = {exports: {}};
|
||||
|
||||
function E () {
|
||||
// Keep this empty so it's easier to inherit from
|
||||
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
||||
}
|
||||
|
||||
E.prototype = {
|
||||
on: function (name, callback, ctx) {
|
||||
var e = this.e || (this.e = {});
|
||||
|
||||
(e[name] || (e[name] = [])).push({
|
||||
fn: callback,
|
||||
ctx: ctx
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
once: function (name, callback, ctx) {
|
||||
var self = this;
|
||||
function listener () {
|
||||
self.off(name, listener);
|
||||
callback.apply(ctx, arguments);
|
||||
}
|
||||
listener._ = callback;
|
||||
return this.on(name, listener, ctx);
|
||||
},
|
||||
|
||||
emit: function (name) {
|
||||
var data = [].slice.call(arguments, 1);
|
||||
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
||||
var i = 0;
|
||||
var len = evtArr.length;
|
||||
|
||||
for (i; i < len; i++) {
|
||||
evtArr[i].fn.apply(evtArr[i].ctx, data);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
off: function (name, callback) {
|
||||
var e = this.e || (this.e = {});
|
||||
var evts = e[name];
|
||||
var liveEvents = [];
|
||||
|
||||
if (evts && callback) {
|
||||
for (var i = 0, len = evts.length; i < len; i++) {
|
||||
if (evts[i].fn !== callback && evts[i].fn._ !== callback)
|
||||
liveEvents.push(evts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove event from queue to prevent memory leak
|
||||
// Suggested by https://github.com/lazd
|
||||
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
|
||||
|
||||
(liveEvents.length)
|
||||
? e[name] = liveEvents
|
||||
: delete e[name];
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
tinyEmitter.exports = E;
|
||||
tinyEmitter.exports.TinyEmitter = E;
|
||||
|
||||
var Emitter = tinyEmitter.exports;
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(function (resolve) {
|
||||
return setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
function runPromisesInSeries(ps) {
|
||||
return ps.reduce(function (p, next) {
|
||||
return p.then(next);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
function getFileName(name) {
|
||||
var nameArray = name.split('.');
|
||||
nameArray.pop();
|
||||
return nameArray.join('.');
|
||||
}
|
||||
function clamp(num, a, b) {
|
||||
return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
|
||||
}
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
var ArtplayerToolThumbnail = /*#__PURE__*/function (_Emitter) {
|
||||
_inherits(ArtplayerToolThumbnail, _Emitter);
|
||||
|
||||
var _super = _createSuper(ArtplayerToolThumbnail);
|
||||
|
||||
function ArtplayerToolThumbnail() {
|
||||
var _this;
|
||||
|
||||
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
_classCallCheck(this, ArtplayerToolThumbnail);
|
||||
|
||||
_this = _super.call(this);
|
||||
_this.processing = false;
|
||||
_this.option = {};
|
||||
|
||||
_this.setup(Object.assign({}, ArtplayerToolThumbnail.DEFAULTS, option));
|
||||
|
||||
_this.video = ArtplayerToolThumbnail.creatVideo();
|
||||
_this.duration = 0;
|
||||
_this.inputChange = _this.inputChange.bind(_assertThisInitialized(_this));
|
||||
_this.ondrop = _this.ondrop.bind(_assertThisInitialized(_this));
|
||||
|
||||
_this.option.fileInput.addEventListener('change', _this.inputChange);
|
||||
|
||||
_this.option.fileInput.addEventListener('dragover', ArtplayerToolThumbnail.ondragover);
|
||||
|
||||
_this.option.fileInput.addEventListener('drop', ArtplayerToolThumbnail.ondrop);
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(ArtplayerToolThumbnail, [{
|
||||
key: "ondrop",
|
||||
value: function ondrop(event) {
|
||||
event.preventDefault();
|
||||
var file = event.dataTransfer.files[0];
|
||||
this.loadVideo(file);
|
||||
}
|
||||
}, {
|
||||
key: "setup",
|
||||
value: function setup() {
|
||||
var _this2 = this;
|
||||
|
||||
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
this.option = Object.assign({}, this.option, option);
|
||||
var _this$option = this.option,
|
||||
fileInput = _this$option.fileInput,
|
||||
number = _this$option.number,
|
||||
width = _this$option.width,
|
||||
column = _this$option.column;
|
||||
this.errorHandle(fileInput instanceof Element, "The 'fileInput' is not a Element");
|
||||
|
||||
if (!(fileInput.tagName === 'INPUT' && fileInput.type === 'file')) {
|
||||
fileInput.style.position = 'relative';
|
||||
var newFileInput = document.createElement('input');
|
||||
newFileInput.type = 'file';
|
||||
newFileInput.style.position = 'absolute';
|
||||
newFileInput.style.width = '100%';
|
||||
newFileInput.style.height = '100%';
|
||||
newFileInput.style.left = '0';
|
||||
newFileInput.style.top = '0';
|
||||
newFileInput.style.right = '0';
|
||||
newFileInput.style.bottom = '0';
|
||||
newFileInput.style.opacity = '0';
|
||||
fileInput.appendChild(newFileInput);
|
||||
this.option.fileInput = newFileInput;
|
||||
}
|
||||
|
||||
['number', 'width', 'column', 'begin', 'end'].forEach(function (item) {
|
||||
_this2.errorHandle(typeof _this2.option[item] === 'number', "The '".concat(item, "' is not a number"));
|
||||
});
|
||||
this.option.number = clamp(number, 10, 1000);
|
||||
this.option.width = clamp(width, 10, 1000);
|
||||
this.option.column = clamp(column, 1, 1000);
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "inputChange",
|
||||
value: function inputChange(event) {
|
||||
var file = this.option.fileInput.files[0];
|
||||
this.loadVideo(file);
|
||||
event.target.value = '';
|
||||
}
|
||||
}, {
|
||||
key: "loadVideo",
|
||||
value: function loadVideo(file) {
|
||||
if (file) {
|
||||
var canPlayType = this.video.canPlayType(file.type);
|
||||
this.errorHandle(canPlayType === 'maybe' || canPlayType === 'probably', "Playback of this file format is not supported: ".concat(file.type));
|
||||
var videoUrl = URL.createObjectURL(file);
|
||||
this.videoUrl = videoUrl;
|
||||
this.file = file;
|
||||
this.emit('file', this.file);
|
||||
this.video.src = videoUrl;
|
||||
this.emit('video', this.video);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "start",
|
||||
value: function start() {
|
||||
var _this3 = this;
|
||||
|
||||
if (!this.video.duration) return sleep(1000).then(function () {
|
||||
return _this3.start();
|
||||
});
|
||||
var _this$option2 = this.option,
|
||||
width = _this$option2.width,
|
||||
number = _this$option2.number,
|
||||
begin = _this$option2.begin,
|
||||
end = _this$option2.end;
|
||||
var height = this.video.videoHeight / this.video.videoWidth * width;
|
||||
this.option.height = height;
|
||||
this.option.begin = clamp(begin, 0, this.video.duration);
|
||||
this.option.end = clamp(end || this.video.duration, begin, 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 = number / 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 screenshotDate = this.creatScreenshotDate();
|
||||
var canvas = this.creatCanvas();
|
||||
var context2D = canvas.getContext('2d');
|
||||
this.emit('canvas', canvas);
|
||||
var promiseList = screenshotDate.map(function (item, index) {
|
||||
return function () {
|
||||
return new Promise(function (resolve) {
|
||||
_this3.video.oncanplay = function () {
|
||||
context2D.drawImage(_this3.video, item.x, item.y, width, height);
|
||||
canvas.toBlob(function (blob) {
|
||||
if (_this3.thumbnailUrl) {
|
||||
URL.revokeObjectURL(_this3.thumbnailUrl);
|
||||
}
|
||||
|
||||
_this3.thumbnailUrl = URL.createObjectURL(blob);
|
||||
|
||||
_this3.emit('update', _this3.thumbnailUrl, (index + 1) / number);
|
||||
|
||||
_this3.video.oncanplay = null;
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
_this3.video.currentTime = item.time;
|
||||
});
|
||||
};
|
||||
});
|
||||
this.processing = true;
|
||||
return runPromisesInSeries(promiseList).then(function () {
|
||||
_this3.processing = false;
|
||||
|
||||
_this3.emit('done');
|
||||
}).catch(function (err) {
|
||||
_this3.processing = false;
|
||||
|
||||
_this3.emit('error', err.message);
|
||||
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "creatScreenshotDate",
|
||||
value: function creatScreenshotDate() {
|
||||
var _this$option3 = this.option,
|
||||
number = _this$option3.number,
|
||||
width = _this$option3.width,
|
||||
height = _this$option3.height,
|
||||
column = _this$option3.column,
|
||||
begin = _this$option3.begin;
|
||||
var timeGap = this.duration / number;
|
||||
var timePoints = [begin + timeGap];
|
||||
|
||||
while (timePoints.length < number) {
|
||||
var last = timePoints[timePoints.length - 1];
|
||||
timePoints.push(last + timeGap);
|
||||
}
|
||||
|
||||
return timePoints.map(function (item, index) {
|
||||
return {
|
||||
time: item - timeGap / 2,
|
||||
x: index % column * width,
|
||||
y: Math.floor(index / column) * height
|
||||
};
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "creatCanvas",
|
||||
value: function creatCanvas() {
|
||||
var _this$option4 = this.option,
|
||||
number = _this$option4.number,
|
||||
width = _this$option4.width,
|
||||
height = _this$option4.height,
|
||||
column = _this$option4.column;
|
||||
var canvas = document.createElement('canvas');
|
||||
var context2D = canvas.getContext('2d');
|
||||
canvas.width = width * column;
|
||||
canvas.height = Math.ceil(number / column) * height + 30;
|
||||
context2D.fillStyle = 'black';
|
||||
context2D.fillRect(0, 0, canvas.width, canvas.height);
|
||||
context2D.font = '14px Georgia';
|
||||
context2D.fillStyle = '#fff';
|
||||
context2D.fillText("From: https://artplayer.org/, Number: ".concat(number, ", Width: ").concat(width, ", Height: ").concat(height, ", Column: ").concat(column), 10, canvas.height - 11);
|
||||
return canvas;
|
||||
}
|
||||
}, {
|
||||
key: "download",
|
||||
value: function download() {
|
||||
this.errorHandle(this.file && this.thumbnailUrl, 'Download does not seem to be ready, please create preview first');
|
||||
this.errorHandle(!this.processing, 'There is currently a task in progress, please wait a moment...');
|
||||
var elink = document.createElement('a');
|
||||
var name = "".concat(getFileName(this.file.name), ".png");
|
||||
elink.download = name;
|
||||
elink.href = this.thumbnailUrl;
|
||||
document.body.appendChild(elink);
|
||||
elink.click();
|
||||
document.body.removeChild(elink);
|
||||
this.emit('download', name);
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "errorHandle",
|
||||
value: function errorHandle(condition, msg) {
|
||||
if (!condition) {
|
||||
this.emit('error', msg);
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "destroy",
|
||||
value: function destroy() {
|
||||
this.option.fileInput.removeEventListener('change', this.inputChange);
|
||||
this.option.fileInput.removeEventListener('dragover', ArtplayerToolThumbnail.ondragover);
|
||||
this.option.fileInput.removeEventListener('drop', ArtplayerToolThumbnail.ondrop);
|
||||
document.body.removeChild(this.video);
|
||||
|
||||
if (this.videoUrl) {
|
||||
URL.revokeObjectURL(this.videoUrl);
|
||||
}
|
||||
|
||||
if (this.thumbnailUrl) {
|
||||
URL.revokeObjectURL(this.thumbnailUrl);
|
||||
}
|
||||
|
||||
this.emit('destroy');
|
||||
}
|
||||
}], [{
|
||||
key: "DEFAULTS",
|
||||
get: function get() {
|
||||
return {
|
||||
number: 60,
|
||||
width: 160,
|
||||
height: 90,
|
||||
column: 10,
|
||||
begin: 0,
|
||||
end: NaN
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "ondragover",
|
||||
value: function ondragover(event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}, {
|
||||
key: "creatVideo",
|
||||
value: function creatVideo() {
|
||||
var video = document.createElement('video');
|
||||
video.style.position = 'absolute';
|
||||
video.style.top = '-9999px';
|
||||
video.style.left = '-9999px';
|
||||
video.muted = true;
|
||||
video.controls = true;
|
||||
document.body.appendChild(video);
|
||||
return video;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ArtplayerToolThumbnail;
|
||||
}(Emitter);
|
||||
|
||||
return ArtplayerToolThumbnail;
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=artplayer-tool-thumbnail.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"artplayer-tool-thumbnail.js","sources":["../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/classCallCheck.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/createClass.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/assertThisInitialized.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/setPrototypeOf.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/inherits.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/typeof.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/possibleConstructorReturn.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/getPrototypeOf.js","../../packages/artplayer-tool-thumbnail/node_modules/tiny-emitter/index.js","../../packages/artplayer-tool-thumbnail/src/utils.js","../../packages/artplayer-tool-thumbnail/src/index.js"],"sourcesContent":["export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}","export default function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function _typeof(obj) {\n return typeof obj;\n };\n } else {\n _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}","import _typeof from \"@babel/runtime/helpers/typeof\";\nimport assertThisInitialized from \"./assertThisInitialized.js\";\nexport default function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n\n return assertThisInitialized(self);\n}","export default function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}","function E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/classCallCheck.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/createClass.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/assertThisInitialized.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/setPrototypeOf.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/inherits.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/typeof.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/possibleConstructorReturn.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/getPrototypeOf.js","../../node_modules/_style-inject@0.3.0@style-inject/dist/style-inject.es.js","../../packages/artplayer/node_modules/_option-validator@2.0.6@option-validator/dist/option-validator.js","../../packages/artplayer/src/utils/emitter.js","../../packages/artplayer/src/utils/compatibility.js","../../packages/artplayer/src/utils/dom.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/isNativeFunction.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/isNativeReflectConstruct.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/construct.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/wrapNativeSuper.js","../../packages/artplayer/src/utils/error.js","../../packages/artplayer/src/utils/subtitle.js","../../packages/artplayer/src/utils/file.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/arrayLikeToArray.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/arrayWithoutHoles.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/iterableToArray.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/nonIterableSpread.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/toConsumableArray.js","../../packages/artplayer/src/utils/property.js","../../packages/artplayer/src/utils/time.js","../../packages/artplayer/src/utils/format.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/defineProperty.js","../../packages/artplayer/src/scheme/index.js","../../packages/artplayer/src/config/index.js","../../packages/artplayer/src/whitelist.js","../../packages/artplayer/src/template.js","../../packages/artplayer/src/i18n/index.js","../../packages/artplayer/src/player/urlMix.js","../../packages/artplayer/src/player/attrMix.js","../../packages/artplayer/src/player/playMix.js","../../packages/artplayer/src/player/pauseMix.js","../../packages/artplayer/src/player/toggleMix.js","../../packages/artplayer/src/player/seekMix.js","../../packages/artplayer/src/player/volumeMix.js","../../packages/artplayer/src/player/currentTimeMix.js","../../packages/artplayer/src/player/durationMix.js","../../packages/artplayer/src/player/switchMix.js","../../packages/artplayer/src/player/playbackRateMix.js","../../packages/artplayer/src/player/aspectRatioMix.js","../../packages/artplayer/src/player/screenshotMix.js","../../packages/artplayer/node_modules/_screenfull@6.0.1@screenfull/index.js","../../packages/artplayer/src/player/fullscreenMix.js","../../packages/artplayer/src/player/fullscreenWebMix.js","../../packages/artplayer/src/player/pipMix.js","../../packages/artplayer/src/player/loadedMix.js","../../packages/artplayer/src/player/playedMix.js","../../packages/artplayer/src/player/playingMix.js","../../packages/artplayer/src/player/autoSizeMix.js","../../packages/artplayer/src/player/rectMix.js","../../packages/artplayer/src/player/flipMix.js","../../packages/artplayer/src/player/miniMix.js","../../packages/artplayer/src/player/loopMix.js","../../packages/artplayer/src/player/posterMix.js","../../packages/artplayer/src/player/autoHeightMix.js","../../packages/artplayer/src/player/themeMix.js","../../packages/artplayer/src/player/titleMix.js","../../packages/artplayer/src/player/exclusiveMix.js","../../packages/artplayer/src/player/subtitleOffsetMix.js","../../packages/artplayer/src/player/optionInit.js","../../packages/artplayer/src/player/eventInit.js","../../packages/artplayer/src/player/index.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/superPropBase.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/get.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/helpers/esm/asyncToGenerator.js","../../node_modules/_regenerator-runtime@0.13.9@regenerator-runtime/runtime.js","../../node_modules/_@babel_runtime@7.17.9@@babel/runtime/regenerator/index.js","../../packages/artplayer/src/utils/component.js","../../packages/artplayer/src/control/fullscreen.js","../../packages/artplayer/src/control/fullscreenWeb.js","../../packages/artplayer/src/Line truncated
|
||||
@@ -31,6 +31,7 @@
|
||||
"@parcel/config-default": "^2.5.0",
|
||||
"@parcel/core": "^2.5.0",
|
||||
"@parcel/reporter-cli": "^2.5.0",
|
||||
"@parcel/transformer-inline-string": "^2.5.0",
|
||||
"@parcel/transformer-less": "^2.5.0",
|
||||
"eslint": "^8.14.0",
|
||||
"glob": "^8.0.1",
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import { append, def, addClass } from '../utils';
|
||||
import loading from './loading.svg';
|
||||
import state from './state.svg';
|
||||
import check from './check.svg';
|
||||
import play from './play.svg';
|
||||
import pause from './pause.svg';
|
||||
import volume from './volume.svg';
|
||||
import volumeClose from './volume-close.svg';
|
||||
import subtitle from './subtitle.svg';
|
||||
import screenshot from './screenshot.svg';
|
||||
import setting from './setting.svg';
|
||||
import fullscreen from './fullscreen.svg';
|
||||
import fullscreenWeb from './fullscreen-web.svg';
|
||||
import arrowLeft from './arrow-left.svg';
|
||||
import arrowRight from './arrow-right.svg';
|
||||
import playbackRate from './playback-rate.svg';
|
||||
import aspectRatio from './aspect-ratio.svg';
|
||||
import config from './config.svg';
|
||||
import pip from './pip.svg';
|
||||
import lock from './lock.svg';
|
||||
import unlock from './unlock.svg';
|
||||
import loading from 'bundle-text:./loading.svg';
|
||||
import state from 'bundle-text:./state.svg';
|
||||
import check from 'bundle-text:./check.svg';
|
||||
import play from 'bundle-text:./play.svg';
|
||||
import pause from 'bundle-text:./pause.svg';
|
||||
import volume from 'bundle-text:./volume.svg';
|
||||
import volumeClose from 'bundle-text:./volume-close.svg';
|
||||
import subtitle from 'bundle-text:./subtitle.svg';
|
||||
import screenshot from 'bundle-text:./screenshot.svg';
|
||||
import setting from 'bundle-text:./setting.svg';
|
||||
import fullscreen from 'bundle-text:./fullscreen.svg';
|
||||
import fullscreenWeb from 'bundle-text:./fullscreen-web.svg';
|
||||
import arrowLeft from 'bundle-text:./arrow-left.svg';
|
||||
import arrowRight from 'bundle-text:./arrow-right.svg';
|
||||
import playbackRate from 'bundle-text:./playback-rate.svg';
|
||||
import aspectRatio from 'bundle-text:./aspect-ratio.svg';
|
||||
import config from 'bundle-text:./config.svg';
|
||||
import pip from 'bundle-text:./pip.svg';
|
||||
import lock from 'bundle-text:./lock.svg';
|
||||
import unlock from 'bundle-text:./unlock.svg';
|
||||
|
||||
export default class Icons {
|
||||
constructor(art) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import './style/index.less';
|
||||
import style from 'bundle-text:./style/index.less';
|
||||
import validator from 'option-validator';
|
||||
import Emitter from './utils/emitter';
|
||||
import * as utils from './utils';
|
||||
@@ -221,6 +221,10 @@ Artplayer.INFO_LOOP_TIME = 1000;
|
||||
Artplayer.FAST_FORWARD_VALUE = 3;
|
||||
Artplayer.FAST_FORWARD_TIME = 1000;
|
||||
|
||||
const $style = document.createElement('style');
|
||||
$style.textContent = style;
|
||||
shadowRoot.appendChild($style);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
'%c ArtPlayer %c __VERSION__ %c https://artplayer.org',
|
||||
|
||||
+4
-2
@@ -12,14 +12,16 @@ async function develop(name) {
|
||||
reload: true,
|
||||
port: 8081,
|
||||
});
|
||||
|
||||
openBrowser(url);
|
||||
|
||||
const dir = projects[name];
|
||||
const bundler = new Parcel({
|
||||
entries: `${dir}/src/index.js`,
|
||||
entries: `${projects[name]}/src/index.js`,
|
||||
defaultConfig: '@parcel/config-default',
|
||||
mode: 'development',
|
||||
targets: ['modern'],
|
||||
defaultTargetOptions: {
|
||||
distDir: `docs/uncompiled`,
|
||||
engines: {
|
||||
browsers: ['last 1 Chrome version'],
|
||||
},
|
||||
|
||||
+8
-5
@@ -1,8 +1,11 @@
|
||||
import path from 'path';
|
||||
import glob from 'glob';
|
||||
|
||||
export default glob.sync(path.join(process.cwd(), 'packages/*')).reduce((result, item) => {
|
||||
const name = item.split(path.sep).pop();
|
||||
result[name] = item;
|
||||
return result;
|
||||
}, {});
|
||||
export default glob
|
||||
.sync(path.join(process.cwd(), 'packages/*'))
|
||||
.filter((item) => !item.endsWith('artplayer-document'))
|
||||
.reduce((result, item) => {
|
||||
const name = item.split(path.sep).pop();
|
||||
result[name] = item;
|
||||
return result;
|
||||
}, {});
|
||||
Reference in new issue
Block a user