mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
8 lines
8.4 KiB
JavaScript
8 lines
8.4 KiB
JavaScript
|
|
/*!
|
|
* artplayer-plugin-ads.js v2.0.0
|
|
* Github: https://github.com/zhw2590582/ArtPlayer
|
|
* (c) 2017-2026 Harvey Zhao
|
|
* Released under the MIT License.
|
|
*/
|
|
!function(e,n,t,r,l){var i="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},a="function"==typeof i[r]&&i[r],o=a.i||{},u=a.cache||{},s="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(n,t){if(!u[n]){if(!e[n]){if(l[n])return l[n];var o="function"==typeof i[r]&&i[r];if(!t&&o)return o(n,!0);if(a)return a(n,!0);if(s&&"string"==typeof n)return s(n);var d=Error("Cannot find module '"+n+"'");throw d.code="MODULE_NOT_FOUND",d}f.resolve=function(t){var r=e[n][1][t];return null!=r?r:t},f.cache={};var c=u[n]=new p.Module(n);e[n][0].call(c.exports,f,c,c.exports,i)}return u[n].exports;function f(e){var n=f.resolve(e);if(!1===n)return{};if(Array.isArray(n)){var t={__esModule:!0};return n.forEach(function(e){var n=e[0],r=e[1],l=e[2]||e[0],i=p(r);"*"===n?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]}})}):"*"===l?Object.defineProperty(t,n,{enumerable:!0,value:i}):Object.defineProperty(t,n,{enumerable:!0,get:function(){return"default"===l?i.__esModule?i.default:i:i[l]}})}),t}return p(n)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=u,p.parent=a,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=o,p.register=function(n,t){e[n]=[function(e,n){n.exports=t},{}]},Object.defineProperty(p,"root",{get:function(){return i[r]}}),i[r]=p;for(var d=0;d<n.length;d++)p(n[d]);if(t){var c=p(t);"object"==typeof exports&&"u">typeof module?module.exports=c:"function"==typeof define&&define.amd&&define(function(){return c})}}({"1qHWP":[function(e,n,t,r){var l=e("@parcel/transformer-js/src/esmodule-helpers.js");l.defineInteropFlag(t),l.export(t,"default",function(){return u});var i=e("@swc/helpers/cjs/_object_spread.cjs"),a=e("bundle-text:./style.less"),o=l.interopDefault(a);function u(e){return function(n){r=(t=n.constructor).version,(0,t.utils.errorHandle)((l=r.split(".").map(Number))[0]+l[1]/100>=5,"Artplayer.js@".concat(r," is not compatible the artplayerPluginAds@").concat(u.version,". Please update it to version Artplayer.js@5.x.x"));var t,r,l,a=n.template.$player,o=n.icons,s=o.volume,p=o.volumeClose,d=o.fullscreenOn,c=o.fullscreenOff,f=o.loading,y=n.constructor,g=y.validator,m=y.utils,v=m.query,b=m.append,h=m.setStyle;e=g((0,i._)({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 x=null,w=null,j=null,O=null,P=null,_=null,D=0,k=null,M=!1,q=!1,A=!1;function E(e,n){return n.replace("%s",e)}function C(){M=!0,n.play(),e.video&&x.pause(),h(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function T(){M||(k=setTimeout(function(){D+=1;var n=e.playDuration-D;n>=1?j.innerHTML=E(n,e.i18n.canBeClosed):(j.innerHTML=e.i18n.close,A||(A=!0)),O.innerHTML=E(e.totalDuration-D,e.i18n.countdown),D>=e.totalDuration?C():T()},1e3))}function H(){M||clearTimeout(k)}function $(){q||(q=!0,function(){n.template.$ads=b(a,'<div class="artplayer-plugin-ads"></div>'),x=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>")),_=b(n.template.$ads,'<div class="artplayer-plugin-ads-loading"></div>'),b(_,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:E(e.playDuration,e.i18n.canBeClosed),'</div>\n<div class="artplayer-plugin-ads-countdown">').concat(E(e.totalDuration,e.i18n.countdown),"</div>\n</div>"))),O=v(".artplayer-plugin-ads-countdown",w),e.playDuration>=e.totalDuration&&h(j,"display","none"),n.proxy(j,"click",function(){A&&C()});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>'))),r=v(".artplayer-plugin-ads-muted",P),l=v(".artplayer-plugin-ads-fullscreen",P);if(e.url?n.proxy(t,"click",function(){window.open(e.url),n.emit("artplayerPluginAds:click",e)}):h(t,"display","none"),e.video){var i=b(r,s),o=b(r,p);h(o,"display","none"),e.muted&&(x.muted=!0,h(i,"display","none"),h(o,"display","inline-flex")),n.proxy(r,"click",function(){x.muted=!x.muted,x.muted?(h(i,"display","none"),h(o,"display","inline-flex")):(h(i,"display","inline-flex"),h(o,"display","none"))})}else h(r,"display","none");var u=b(l,d),y=b(l,c);h(y,"display","none"),n.proxy(l,"click",function(){n.fullscreen=!n.fullscreen,n.fullscreen?(h(u,"display","inline-flex"),h(y,"display","none")):(h(u,"display","none"),h(y,"display","inline-flex"))}),n.proxy(x,"click",function(){e.url&&window.open(e.url),n.emit("artplayerPluginAds:click",e)})}(),n.pause(),e.video?(n.proxy(x,"error",C),n.proxy(x,"loadedmetadata",function(){T(),x.play(),h(w,"display","flex"),h(P,"display","flex"),h(_,"display","none")})):(T(),h(w,"display","flex"),h(P,"display","flex"),h(_,"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:C,pause:H,play:T}}}if("u">typeof document&&!document.getElementById("artplayer-plugin-ads")){var s=document.createElement("style");s.id="artplayer-plugin-ads",s.textContent=o.default,document.head.appendChild(s)}"u">typeof window&&(window.artplayerPluginAds=u)},{"@swc/helpers/cjs/_object_spread.cjs":"kyoEj","bundle-text:./style.less":"8pNer","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],kyoEj:[function(e,n,t,r){"use strict";var l=e("9f9b8a24218ee51e");t._=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.forEach(function(n){l._(e,n,t[n])})}return e}},{"9f9b8a24218ee51e":"ltU3W"}],ltU3W:[function(e,n,t,r){"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}},{}],"8pNer":[function(e,n,t,r){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,r){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",{}); |