Files
ArtPlayer/docs/compiled/artplayer-tool-thumbnail.js
T
Harvey Zack 699135afcf Danmuku (#759)
* chore: Bump artplayer-plugin-danmuku version to 5.1.0

* chore: Update danmuku plugin with new mount option

* chore: Update danmuku plugin with new mount option

* chore: Update danmuku plugin with new mount option

* chore: Update danmuku plugin with new mount option

* chore: Update danmuku plugin with new mount option

* chore: Update danmuku plugin with new mount option

* chore: Refactor getDanmuTop function to handle additional cases

* chore: Refactor getDanmuTop function to handle additional cases

* chore: Update danmuku plugin with new mount option

* chore: Update danmuku plugin with new mount option

* chore: Refactor danmuku plugin to always create a new Setting instance

* Refactor danmuku plugin to always create a new Setting instance

* Refactor danmuku plugin to always create a new Setting instance

* Update danmuku.js

* Update danmuku.js

* Refactor danmuku plugin to include a new Setting instance

* Refactor danmuku plugin to include a new Setting instance

* Refactor danmuku plugin styles for better alignment and spacing

* Refactor danmuku plugin styles for better alignment and spacing

* Refactor danmuku plugin styles for better alignment and spacing

* Refactor danmuku plugin styles for better alignment and spacing

* Refactor danmuku plugin styles for better alignment and spacing

* chore: Update package.json files

* Refactor danmuku plugin to remove unnecessary whitespace in the setting template

* chore: Remove ESLint configuration files and update npm dependencies

* chore: Update ESLint configuration to disable console warnings and fix unused variable warnings

* chore: Update ESLint configuration to fix quotes rule

* Update package.json

* Update package.json

* Update setting.js

* chore: Compress CSS code in build script

* chore: Update build script to compress JavaScript code

* chore: Update build script to compress JavaScript code

* chore: Refactor setting.js to improve code organization and remove unused variables

* chore: Add isHover flag to Control component for better control hiding behavior

* chore: Update Control component to use $bottom instead of $controls for better control hiding behavior

* Update package.json

* Update package.json

* Update package.json

* chore: Update lerna.json to use independent versioning and yarn as npm client

* refactor: Update Danmuku class to support configurable modes and visibility

* refactor: Update Danmuku styles for better visibility and configurability

* feat: Update font weight in Danmuku styles for better readability

* refactor: Update Danmuku class to support configurable modes and visibility

* refactor: Add opacity, area, font, and speed sliders to Danmuku settings

* refactor: Initialize sliders for opacity, area, font, and speed in Danmuku settings

* feat: Add slider UI for opacity, area, and speed in Danmuku settings

* feat: Update slider styles in Danmuku settings for better visibility and configurability

* refactor: Improve Danmuku settings UI for better visibility and configurability

* refactor: Improve Danmuku settings UI for better visibility and configurability

* refactor: Update slider styles in Danmuku settings for better visibility and configurability

* refactor: Update margin slider initialization in Danmuku settings

* refactor: Update slider styles and initialization in Danmuku settings

* refactor: Update Danmuku class to support configurable visibility

* refactor: Update Danmuku class to support configurable visibility

* refactor: Update Danmuku class to support configurable visibility

* refactor: Update Danmuku class to support configurable visibility

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Improve Danmuku settings UI for better visibility and configurability

* add lock

* refactor: Add lock and unlock methods to Danmuku settings

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* Update artplayer-plugin-danmuku.d.ts

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings event listeners

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability

* refactor: Update Danmuku settings UI for better visibility and configurability
2024-05-26 14:57:22 +08:00

7 lines
8.0 KiB
JavaScript

/*!
* artplayer-tool-thumbnail.js v4.3.12
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2024 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,i,n,o){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof r[n]&&r[n],l=s.cache||{},h="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function a(t,i){if(!l[t]){if(!e[t]){var o="function"==typeof r[n]&&r[n];if(!i&&o)return o(t,!0);if(s)return s(t,!0);if(h&&"string"==typeof t)return h(t);var d=Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}p.resolve=function(i){var n=e[t][1][i];return null!=n?n:i},p.cache={};var u=l[t]=new a.Module(t);e[t][0].call(u.exports,p,u,u.exports,this)}return l[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:a(t)}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.exports={}},a.modules=e,a.cache=l,a.parent=s,a.register=function(t,i){e[t]=[function(e,t){t.exports=i},{}]},Object.defineProperty(a,"root",{get:function(){return r[n]}}),r[n]=a;for(var d=0;d<t.length;d++)a(t[d]);if(i){var u=a(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd&&define(function(){return u})}}({e1IG9:[function(e,t,i){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=e("./emitter"),r=n.interopDefault(o),s=e("./utils");class l extends r.default{constructor(e={}){super(),this.processing=!1,this.option={},this.setup(Object.assign({},l.DEFAULTS,e)),this.video=l.creatVideo(),this.duration=0,this.inputChange=this.inputChange.bind(this),this.ondrop=this.ondrop.bind(this),this.option.fileInput.addEventListener("change",this.inputChange),this.option.fileInput.addEventListener("dragover",l.ondragover),this.option.fileInput.addEventListener("drop",l.ondrop)}static get DEFAULTS(){return{number:60,width:160,height:90,column:10,begin:0,end:NaN}}static ondragover(e){e.preventDefault()}ondrop(e){e.preventDefault();let t=e.dataTransfer.files[0];this.loadVideo(t)}setup(e={}){this.option=Object.assign({},this.option,e);let{fileInput:t,number:i,width:n,column:o}=this.option;if(this.errorHandle(t instanceof Element,"The 'fileInput' is not a Element"),!("INPUT"===t.tagName&&"file"===t.type)){t.style.position="relative";let e=document.createElement("input");e.type="file",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.left="0",e.style.top="0",e.style.right="0",e.style.bottom="0",e.style.opacity="0",t.appendChild(e),this.option.fileInput=e}return["number","width","column","begin","end"].forEach(e=>{this.errorHandle("number"==typeof this.option[e],`The '${e}' is not a number`)}),this.option.number=(0,s.clamp)(i,10,1e3),this.option.width=(0,s.clamp)(n,10,1e3),this.option.column=(0,s.clamp)(o,1,1e3),this}static creatVideo(){let e=document.createElement("video");return e.style.position="absolute",e.style.top="-9999px",e.style.left="-9999px",e.muted=!0,e.controls=!0,document.body.appendChild(e),e}inputChange(e){let t=this.option.fileInput.files[0];this.loadVideo(t),e.target.value=""}loadVideo(e){if(e){let t=this.video.canPlayType(e.type);this.errorHandle("maybe"===t||"probably"===t,`Playback of this file format is not supported:${e.type}`);let i=URL.createObjectURL(e);this.videoUrl=i,this.file=e,this.emit("file",this.file),this.video.src=i,this.emit("video",this.video)}}start(){if(!this.video.duration)return(0,s.sleep)(1e3).then(()=>this.start());let{width:e,number:t,begin:i,end:n}=this.option,o=this.video.videoHeight/this.video.videoWidth*e;this.option.height=o,this.option.begin=(0,s.clamp)(i,0,this.video.duration),this.option.end=(0,s.clamp)(n||this.video.duration,i,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=t/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 ${this.density}`);let r=this.creatScreenshotDate(),l=this.creatCanvas(),h=l.getContext("2d");this.emit("canvas",l);let a=r.map((i,n)=>()=>new Promise(r=>{this.video.oncanplay=()=>{h.drawImage(this.video,i.x,i.y,e,o),l.toBlob(e=>{this.thumbnailUrl&&URL.revokeObjectURL(this.thumbnailUrl),this.thumbnailUrl=URL.createObjectURL(e),this.emit("update",this.thumbnailUrl,(n+1)/t),this.video.oncanplay=null,r()})},this.video.currentTime=i.time}));return this.processing=!0,(0,s.runPromisesInSeries)(a).then(()=>{this.processing=!1,this.emit("done")}).catch(e=>{throw this.processing=!1,this.emit("error",e.message),e})}creatScreenshotDate(){let{number:e,width:t,height:i,column:n,begin:o}=this.option,r=this.duration/e,s=[o+r];for(;s.length<e;){let e=s[s.length-1];s.push(e+r)}return s.map((e,o)=>({time:e-r/2,x:o%n*t,y:Math.floor(o/n)*i}))}creatCanvas(){let{number:e,width:t,height:i,column:n}=this.option,o=document.createElement("canvas"),r=o.getContext("2d");return o.width=t*n,o.height=Math.ceil(e/n)*i+30,r.fillStyle="black",r.fillRect(0,0,o.width,o.height),r.font="14px Georgia",r.fillStyle="#fff",r.fillText(`From:https://artplayer.org/,Number:${e},Width:${t},Height:${i},Column:${n}`,10,o.height-11),o}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...");let e=document.createElement("a"),t=`${(0,s.getFileName)(this.file.name)}.png`;return e.download=t,e.href=this.thumbnailUrl,document.body.appendChild(e),e.click(),document.body.removeChild(e),this.emit("download",t),this}errorHandle(e,t){if(!e)throw this.emit("error",t),Error(t)}destroy(){this.option.fileInput.removeEventListener("change",this.inputChange),this.option.fileInput.removeEventListener("dragover",l.ondragover),this.option.fileInput.removeEventListener("drop",l.ondrop),document.body.removeChild(this.video),this.videoUrl&&URL.revokeObjectURL(this.videoUrl),this.thumbnailUrl&&URL.revokeObjectURL(this.thumbnailUrl),this.emit("destroy")}}i.default=l,window.ArtplayerToolThumbnail=l},{"./emitter":"k2uxG","./utils":"hkb5L","@parcel/transformer-js/src/esmodule-helpers.js":"hqP7A"}],k2uxG:[function(e,t,i){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(i),i.default=class{on(e,t,i){let n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:t,ctx:i}),this}once(e,t,i){let n=this;function o(...r){n.off(e,o),t.apply(i,r)}return o._=t,this.on(e,o,i)}emit(e,...t){let i=((this.e||(this.e={}))[e]||[]).slice();for(let e=0;e<i.length;e+=1)i[e].fn.apply(i[e].ctx,t);return this}off(e,t){let i=this.e||(this.e={}),n=i[e],o=[];if(n&&t)for(let e=0,i=n.length;e<i;e+=1)n[e].fn!==t&&n[e].fn._!==t&&o.push(n[e]);return o.length?i[e]=o:delete i[e],this}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"hqP7A"}],hqP7A:[function(e,t,i){i.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},i.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},i.exportAll=function(e,t){return Object.keys(e).forEach(function(i){"default"===i||"__esModule"===i||Object.prototype.hasOwnProperty.call(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[i]}})}),t},i.export=function(e,t,i){Object.defineProperty(e,t,{enumerable:!0,get:i})}},{}],hkb5L:[function(e,t,i){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");function o(e){return new Promise(t=>setTimeout(t,e))}function r(e){return e.reduce((e,t)=>e.then(t),Promise.resolve())}function s(e){let t=e.split(".");return t.pop(),t.join(".")}function l(e,t,i){return Math.max(Math.min(e,Math.max(t,i)),Math.min(t,i))}n.defineInteropFlag(i),n.export(i,"sleep",()=>o),n.export(i,"runPromisesInSeries",()=>r),n.export(i,"getFileName",()=>s),n.export(i,"clamp",()=>l)},{"@parcel/transformer-js/src/esmodule-helpers.js":"hqP7A"}]},["e1IG9"],"e1IG9","parcelRequire94c2");