mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
9 lines
2.3 KiB
JavaScript
9 lines
2.3 KiB
JavaScript
/*!
|
|
* artplayer-plugin-blur.js v3.1.10
|
|
* Github: https://github.com/zhw2590582/ArtPlayer#readme
|
|
* (c) 2017-2019 Harvey Zack
|
|
* Released under the MIT License.
|
|
*/
|
|
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).artplayerPluginBlur=t()}(this,function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,u=(function(e,t){e.exports=function(e,r){return new Promise(function(a){var i=new Image;i.onload=function(){var e=i.naturalWidth,t=i.naturalHeight,n=document.createElement("canvas");n.style.width=e+"px",n.style.height=t+"px",n.width=e,n.height=t;var o=n.getContext("2d");o.filter="blur("+r+"px)",o.drawImage(i,-r,-r,e+2*r,t+2*r),n.toBlob(function(e){a(URL.createObjectURL(e)),i.onload=null})},i.src=e})}}(e={exports:{}},e.exports),e.exports);return function(t){var e=t.constructor.utils,n=e.errorHandle,l=e.clamp;n(CanvasRenderingContext2D&&Object.prototype.hasOwnProperty.call(CanvasRenderingContext2D.prototype,"filter"),"artplayerPluginBlur: Your browser does not support canvas blur");var s=t.player,c="";return{name:"artplayerPluginBlur",attach:function(a){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:15;function r(){window.URL.revokeObjectURL(c),a.classList.remove("artplayer-blur-show"),a.style.visibility="hidden",a.style.opacity="0",a.style.backgroundImage="none"}function e(){var e=a.getBoundingClientRect(),t=e.left,n=e.top;a.style.backgroundImage="none",a.style.backgroundSize="".concat(s.width,"px ").concat(s.height,"px"),a.style.backgroundPosition="".concat(s.left-t,"px ").concat(s.top-n,"px");var o=s.currentTime;s.getScreenshotBlobUrl().then(function(t){u(t,l(i,0,50)).then(function(e){window.URL.revokeObjectURL(t),s.playing||o!==s.currentTime?r():(c=e,a.classList.add("artplayer-blur-show"),a.style.visibility="visible",a.style.opacity="1",a.style.backgroundImage="url(".concat(e,")"))})})}n(a instanceof Element,"The attach element is not a dom element"),a.style.backgroundRepeat="no-repeat",a.style.transition="all .2s ease",r(),t.on("video:pause",e),t.on("video:seeked",e),t.on("video:playing",r),t.on("video:seeking",r),t.on("video:timeupdate",r)}}}});
|