mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
8 lines
5.7 KiB
JavaScript
8 lines
5.7 KiB
JavaScript
|
|
/*!
|
|
* artplayer-plugin-ambilight.js v1.0.0
|
|
* Github: https://github.com/zhw2590582/ArtPlayer
|
|
* (c) 2017-2025 Harvey Zack
|
|
* Released under the MIT License.
|
|
*/
|
|
!function(e,r,t,n,o,i,a,u){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},c="function"==typeof f[n]&&f[n],l=c.i||{},d=c.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(r,t){if(!d[r]){if(!e[r]){if(o[r])return o[r];var i="function"==typeof f[n]&&f[n];if(!t&&i)return i(r,!0);if(c)return c(r,!0);if(s&&"string"==typeof r)return s(r);var a=Error("Cannot find module '"+r+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},l.cache={};var u=d[r]=new p.Module(r);e[r][0].call(u.exports,l,u,u.exports,f)}return d[r].exports;function l(e){var r=l.resolve(e);if(!1===r)return{};if(Array.isArray(r)){var t={__esModule:!0};return r.forEach(function(e){var r=e[0],n=e[1],o=e[2]||e[0],i=p(n);"*"===r?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(t,r,{enumerable:!0,value:i}):Object.defineProperty(t,r,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),t}return p(r)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=d,p.parent=c,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(p,"root",{get:function(){return f[n]}}),f[n]=p;for(var y=0;y<r.length;y++)p(r[y]);if(t){var m=p(t);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({"8Uro8":[function(e,r,t,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(t),o.export(t,"default",function(){return a});var i=e("@swc/helpers/cjs/_sliced_to_array.cjs");function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){var t,n,o,a,u,f,c,l,d,s,p,y,m,b=r.template.$video,v=r.constructor.utils,h=v.createElement,g=v.addClass,_=v.setStyles,j=e.blur,w=e.opacity,O=e.frequency,A=e.duration,x=h("div"),M=((t=x).innerHTML=Array.from({length:9}).fill("<div></div>").join(""),Array.from(t.children));n=x,o=b,g(n,"artplayer-plugin-ambilight"),o.parentNode.insertBefore(n,o),_(n,{position:"absolute",top:0,left:0,zIndex:9,inset:0,display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gridTemplateRows:"1fr 1fr 1fr"}),a=M,u=void 0===j?"50px":j,f=void 0===w?.5:w,c=void 0===A?.3:A,a.forEach(function(e){_(e,{opacity:f,filter:"blur(".concat(u,")"),transition:"background-color ".concat(c,"s ease")})});var S=(l=b,d=M,s=void 0===O?10:O,y=(p=h("canvas")).getContext("2d"),p.width=3,p.height=3,m=0,function e(){var t=performance.now();if(t-m<1e3/s||!r.playing){P=requestAnimationFrame(e);return}m=t;var n=l.videoWidth/3,o=l.videoHeight/3,a=[[0,0],[n,0],[2*n,0],[0,o],[n,o],[2*n,o],[0,2*o],[n,2*o],[2*n,2*o]].map(function(e){var r,t,a,u,f=(0,i._)(e,2),c=f[0],d=f[1];return y.drawImage(l,c,d,n,o,0,0,1,1),t=(r=(0,i._)(y.getImageData(0,0,1,1).data,3))[0],a=r[1],u=r[2],"rgb(".concat(t,", ").concat(a,", ").concat(u,")")});d.forEach(function(e,r){e.style.backgroundColor=a[r]}),P=requestAnimationFrame(e)}),P=null;function q(){P||S()}function I(){P&&(cancelAnimationFrame(P),P=null)}return r.on("ready",q),r.on("destroy",I),{name:"artplayerPluginAmbilight",start:q,stop:I}}}"undefined"!=typeof window&&(window.artplayerPluginAmbilight=a)},{"@swc/helpers/cjs/_sliced_to_array.cjs":"gIQTH","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],gIQTH:[function(e,r,t,n){"use strict";var o=e("d7c30a5ae0c1ab2"),i=e("3aacfce52f67defd"),a=e("f0dae09a1a08b16a"),u=e("83f3648e614d0830");t._=function(e,r){return o._(e)||i._(e,r)||u._(e,r)||a._()}},{d7c30a5ae0c1ab2:"3QSPl","3aacfce52f67defd":"5SSeo",f0dae09a1a08b16a:"heYSj","83f3648e614d0830":"fh7mx"}],"3QSPl":[function(e,r,t,n){"use strict";t._=function(e){if(Array.isArray(e))return e}},{}],"5SSeo":[function(e,r,t,n){"use strict";t._=function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(t=o.next()).done)&&(i.push(t.value),!r||i.length!==r);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw n}}return i}}},{}],heYSj:[function(e,r,t,n){"use strict";t._=function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],fh7mx:[function(e,r,t,n){"use strict";var o=e("3ee51b7dc02d0c44");t._=function(e,r){if(e){if("string"==typeof e)return o._(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o._(e,r)}}},{"3ee51b7dc02d0c44":"1WOAB"}],"1WOAB":[function(e,r,t,n){"use strict";t._=function(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}},{}],qpMMf:[function(e,r,t,n){t.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},t.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.exportAll=function(e,r){return Object.keys(e).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:function(){return e[t]}})}),r},t.export=function(e,r,t){Object.defineProperty(e,r,{enumerable:!0,get:t})}},{}]},["8Uro8"],"8Uro8","parcelRequire4dc0",{}); |