Files
ArtPlayer/docs/compiled/artplayer-plugin-ads.legacy.js
T
Harvey Zack fa0961a9f9 refactor: update event handling in plugins and core
- Changed event handling from `art.proxy` to `art.on` for visibility change and pointer events in the ads and danmuku plugins to improve consistency and maintainability.
- Bumped version of the danmuku plugin from 5.1.8 to 5.1.9.
- Added pointer events to the global event initialization in the core to ensure proper event handling across the application.
2025-08-16 21:17:29 +08:00

8 lines
8.0 KiB
JavaScript

/*!
* artplayer-plugin-ads.js v2.0.0
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,n,t,l,i,r,a,o){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof d[l]&&d[l],s=u.i||{},p=u.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(n,t){if(!p[n]){if(!e[n]){if(i[n])return i[n];var r="function"==typeof d[l]&&d[l];if(!t&&r)return r(n,!0);if(u)return u(n,!0);if(c&&"string"==typeof n)return c(n);var a=Error("Cannot find module '"+n+"'");throw a.code="MODULE_NOT_FOUND",a}s.resolve=function(t){var l=e[n][1][t];return null!=l?l:t},s.cache={};var o=p[n]=new f.Module(n);e[n][0].call(o.exports,s,o,o.exports,d)}return p[n].exports;function s(e){var n=s.resolve(e);return!1===n?{}:f(n)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=c,this.exports={}},f.modules=e,f.cache=p,f.parent=u,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=s,f.register=function(n,t){e[n]=[function(e,n){n.exports=t},{}]},Object.defineProperty(f,"root",{get:function(){return d[l]}}),d[l]=f;for(var y=0;y<n.length;y++)f(n[y]);if(t){var g=f(t);"object"==typeof exports&&"undefined"!=typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({"1qHWP":[function(e,n,t,l){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(t),i.export(t,"default",function(){return d});var r=e("@swc/helpers/cjs/_object_spread.cjs"),a=e("bundle-text:./style.less"),o=i.interopDefault(a);function d(e){return function(n){l=(t=n.constructor).version,(0,t.utils.errorHandle)((i=l.split(".").map(Number))[0]+i[1]/100>=5,"Artplayer.js@".concat(l," is not compatible the artplayerPluginAds@").concat(d.version,". Please update it to version Artplayer.js@5.x.x"));var t,l,i,a=n.template.$player,o=n.icons,u=o.volume,s=o.volumeClose,p=o.fullscreenOn,c=o.fullscreenOff,f=o.loading,y=n.constructor,g=y.validator,m=y.utils,v=m.query,b=m.append,x=m.setStyle;e=g((0,r._)({html:"",video:"",url:"",playDuration:5,totalDuration:10,muted:!1,i18n:{close:"关闭广告",countdown:"%s秒",detail:"查看详情",canBeClosed:"%s秒后可关闭广告"}},e),{html:"?string",video:"?string",url:"?string",playDuration:"number",totalDuration:"number",muted:"?boolean",i18n:{close:"string",countdown:"string",detail:"string",canBeClosed:"string"}});var h=null,w=null,j=null,O=null,P=null,k=null,D=0,_=null,M=!1,q=!1,A=!1;function C(e,n){return n.replace("%s",e)}function E(){M=!0,n.play(),e.video&&h.pause(),x(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function T(){M||(_=setTimeout(function(){D+=1;var n=e.playDuration-D;n>=1?j.innerHTML=C(n,e.i18n.canBeClosed):(j.innerHTML=e.i18n.close,A||(A=!0)),O.innerHTML=C(e.totalDuration-D,e.i18n.countdown),D>=e.totalDuration?E():T()},1e3))}function H(){M||clearTimeout(_)}function $(){q||(q=!0,function(){n.template.$ads=b(a,'<div class="artplayer-plugin-ads"></div>'),h=b(n.template.$ads,e.video?'<video class="artplayer-plugin-ads-video" src="'.concat(e.video,'" loop playsInline></video>'):'<div class="artplayer-plugin-ads-html">'.concat(e.html,"</div>")),k=b(n.template.$ads,'<div class="artplayer-plugin-ads-loading"></div>'),b(k,f),j=v(".artplayer-plugin-ads-close",w=b(n.template.$ads,'<div class="artplayer-plugin-ads-timer">\n<div class="artplayer-plugin-ads-close">'.concat(e.playDuration<=0?e.i18n.close:C(e.playDuration,e.i18n.canBeClosed),'</div>\n<div class="artplayer-plugin-ads-countdown">').concat(C(e.totalDuration,e.i18n.countdown),"</div>\n</div>"))),O=v(".artplayer-plugin-ads-countdown",w),e.playDuration>=e.totalDuration&&x(j,"display","none"),n.proxy(j,"click",function(){A&&E()});var t=v(".artplayer-plugin-ads-detail",P=b(n.template.$ads,'<div class="artplayer-plugin-ads-control">\n<div class="artplayer-plugin-ads-detail">'.concat(e.i18n.detail,'</div>\n<div class="artplayer-plugin-ads-muted"></div>\n<div class="artplayer-plugin-ads-fullscreen"></div>\n</div>'))),l=v(".artplayer-plugin-ads-muted",P),i=v(".artplayer-plugin-ads-fullscreen",P);if(e.url?n.proxy(t,"click",function(){window.open(e.url),n.emit("artplayerPluginAds:click",e)}):x(t,"display","none"),e.video){var r=b(l,u),o=b(l,s);x(o,"display","none"),e.muted&&(h.muted=!0,x(r,"display","none"),x(o,"display","inline-flex")),n.proxy(l,"click",function(){h.muted=!h.muted,h.muted?(x(r,"display","none"),x(o,"display","inline-flex")):(x(r,"display","inline-flex"),x(o,"display","none"))})}else x(l,"display","none");var d=b(i,p),y=b(i,c);x(y,"display","none"),n.proxy(i,"click",function(){n.fullscreen=!n.fullscreen,n.fullscreen?(x(d,"display","inline-flex"),x(y,"display","none")):(x(d,"display","none"),x(y,"display","inline-flex"))}),n.proxy(h,"click",function(){e.url&&window.open(e.url),n.emit("artplayerPluginAds:click",e)})}(),n.pause(),e.video?(n.proxy(h,"error",E),n.proxy(h,"loadedmetadata",function(){T(),h.play(),x(w,"display","flex"),x(P,"display","flex"),x(k,"display","none")})):(T(),x(w,"display","flex"),x(P,"display","flex"),x(k,"display","none")),n.on("document:visibilitychange",function(){document.hidden?H():T()}))}return n.on("ready",function(){n.once("play",$),n.once("video:playing",$)}),{name:"artplayerPluginAds",skip:E,pause:H,play:T}}}if("undefined"!=typeof document&&!document.getElementById("artplayer-plugin-ads")){var u=document.createElement("style");u.id="artplayer-plugin-ads",u.textContent=o.default,document.head.appendChild(u)}"undefined"!=typeof window&&(window.artplayerPluginAds=d)},{"@swc/helpers/cjs/_object_spread.cjs":"kyoEj","bundle-text:./style.less":"g8Z3k","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],kyoEj:[function(e,n,t,l){"use strict";var i=e("9f9b8a24218ee51e");t._=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},l=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(l=l.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),l.forEach(function(n){i._(e,n,t[n])})}return e}},{"9f9b8a24218ee51e":"ltU3W"}],ltU3W:[function(e,n,t,l){"use strict";t._=function(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}},{}],g8Z3k:[function(e,n,t,l){n.exports=".artplayer-plugin-ads{z-index:150;color:#fff;background-color:#000;width:100%;height:100%;font-size:13px;line-height:1;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden}.artplayer-plugin-ads .artplayer-plugin-ads-html{justify-content:center;align-items:center;width:100%;height:100%;display:flex}.artplayer-plugin-ads .artplayer-plugin-ads-video{width:100%;height:100%}.artplayer-plugin-ads .artplayer-plugin-ads-timer{display:none;position:absolute;top:10px;right:10px}.artplayer-plugin-ads .artplayer-plugin-ads-timer>div{cursor:pointer;background-color:rgba(0,0,0,.5);border-radius:15px;align-items:center;margin-left:5px;padding:5px 10px;display:flex}.artplayer-plugin-ads .artplayer-plugin-ads-control{display:none;position:absolute;bottom:10px;right:10px}.artplayer-plugin-ads .artplayer-plugin-ads-control>div{cursor:pointer;background-color:rgba(0,0,0,.5);border-radius:15px;align-items:center;margin-left:5px;padding:5px 10px;display:flex}.artplayer-plugin-ads .artplayer-plugin-ads-control .art-icon svg{width:20px;height:20px}.artplayer-plugin-ads .artplayer-plugin-ads-loading{justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}"},{}],qpMMf:[function(e,n,t,l){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,n){return Object.keys(e).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[t]}})}),n},t.export=function(e,n,t){Object.defineProperty(e,n,{enumerable:!0,get:t})}},{}]},["1qHWP"],"1qHWP","parcelRequire4dc0",{});