mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
add artplayer-plugin-ads
This commit is contained in:
1 parent
463e05fcc0
commit
910c020488
6 files changed
+18
-4
No files matched your search
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* artplayer-plugin-ads.js v1.0.0
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||||
* (c) 2017-2022 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(e,n,l,t,i){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof r.parcelRequirea5da&&r.parcelRequirea5da,o=a.cache||{},d="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(n,l){if(!o[n]){if(!e[n]){var t="function"==typeof r.parcelRequirea5da&&r.parcelRequirea5da;if(!l&&t)return t(n,!0);if(a)return a(n,!0);if(d&&"string"==typeof n)return d(n);var i=new Error("Cannot find module '"+n+"'");throw i.code="MODULE_NOT_FOUND",i}p.resolve=function(l){var t=e[n][1][l];return null!=t?t:l},p.cache={};var s=o[n]=new u.Module(n);e[n][0].call(s.exports,p,s,s.exports,this)}return o[n].exports;function p(e){var n=p.resolve(e);return!1===n?{}:u(n)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=o,u.parent=a,u.register=function(n,l){e[n]=[function(e,n){n.exports=l},{}]},Object.defineProperty(u,"root",{get:function(){return r.parcelRequirea5da}}),r.parcelRequirea5da=u;for(var s=0;s<n.length;s++)u(n[s]);var p=u(l);"object"==typeof exports&&"undefined"!=typeof module?module.exports=p:"function"==typeof define&&define.amd&&define((function(){return p}))}({E13ST:[function(e,n,l){var t=e("@parcel/transformer-js/src/esmodule-helpers.js");t.defineInteropFlag(l);var i=e("bundle-text:./style.less"),r=t.interopDefault(i);function a(e){return n=>{const{template:{$player:l},icons:{volume:t,volumeClose:i,fullscreenOn:r,fullscreenOff:a},constructor:{validator:o,utils:{query:d,append:u,setStyle:s}}}=n;e=o({html:"",video:"",url:"",playDuration:5,totalDuration:10,i18n:{close:"关闭广告",countdown:"%s秒",detail:"查看详情",canBeClosed:"%s秒后可关闭广告"},...e},{html:"?string",video:"?string",url:"?string",playDuration:"number",totalDuration:"number",i18n:{close:"string",countdown:"string",detail:"string",canBeClosed:"string"}});let p=null,c=null,f=null,y=null,g=null,m=0,v=null,x=!1;function h(e,n){return n.replace("%s",e)}function b(){x=!0,n.play(),e.video&&p.pause(),s(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function w(){x||(v=setTimeout((()=>{m+=1;const l=e.playDuration-m;l>=1?f.innerHTML=h(l,e.i18n.canBeClosed):(f.innerHTML=e.i18n.close,n.proxy(f,"click",b)),y.innerHTML=h(e.totalDuration-m,e.i18n.countdown),m>=e.totalDuration?b():w()}),1e3))}function j(){x||clearTimeout(v)}return n.on("ready",(()=>{n.once("play",(()=>{!function(){n.template.$ads=u(l,'<div class="artplayer-plugin-ads"></div>'),p=u(n.template.$ads,e.video?`<video class="artplayer-plugin-ads-video" src="${e.video}" loop></video>`:`<div class="artplayer-plugin-ads-html">${e.html}</div>`),c=u(n.template.$ads,`<div class="artplayer-plugin-ads-timer"><div class="artplayer-plugin-ads-close">${h(e.playDuration,e.i18n.canBeClosed)}</div><div class="artplayer-plugin-ads-countdown">${h(e.totalDuration,e.i18n.countdown)}</div></div>`),f=d(".artplayer-plugin-ads-close",c),y=d(".artplayer-plugin-ads-countdown",c),g=u(n.template.$ads,`<div class="artplayer-plugin-ads-control"><div class="artplayer-plugin-ads-detail">${e.i18n.detail}</div><div class="artplayer-plugin-ads-muted"></div><div class="artplayer-plugin-ads-fullscreen"></div></div>`);const o=d(".artplayer-plugin-ads-detail",g),m=d(".artplayer-plugin-ads-muted",g),v=d(".artplayer-plugin-ads-fullscreen",g);if(e.video){const e=u(m,t),l=u(m,i);s(l,"display","none"),n.proxy(m,"click",(()=>{p.muted=!p.muted,p.muted?(s(e,"display","none"),s(l,"display","inline-flex")):(s(e,"display","inline-flex"),s(l,"display","none"))}))}else s(m,"display","none");const x=u(v,r),b=u(v,a);s(b,"display","none"),n.proxy(v,"click",(()=>{n.fullscreen=!n.fullscreen,n.fullscreen?(s(x,"display","inline-flex"),s(b,"display","none")):(s(x,"display","none"),s(b,"display","inline-flex"))})),n.proxy(p,"click",(()=>{e.url&&window.open(e.url),n.emit("artplayerPluginAds:click",e)})),n.proxy(o,"click",(()=>{e.url&&window.open(e.url),n.emit("artplayerPluginAds:click",e)}))}(),n.pause(),e.video?(n.loading.show=!0,n.proxy(p,"error",b),n.proxy(p,"loadedmetadata",(()=>{w(),p.play(),n.loading.show=!1,s(c,"display","flex")}))):(w(),s(c,"display","flex"))})),n.proxy(document,"visibilitychange",(()=>{document.hidden?j():w()}))})),{name:"artplayerPluginAds",skip:b,pause:j,play:w}}}if(l.default=a,a.env="production",a.version="1.0.0",a.build="1655777323685","undefined"!=typeof document&&!document.getElementById("artplayer-plugin-ads")){const e=document.createElement("style");e.id="artplayer-plugin-ads",e.textContent=r.default,document.head.appendChild(e)}"undefined"!=typeof window&&(window.artplayerPluginAds=a)},{"bundle-text:./style.less":"5j5O2","@parcel/transformer-js/src/esmodule-helpers.js":"9v6Cv"}],"5j5O2":[function(e,n,l){n.exports=".artplayer-plugin-ads{z-index:150;width:100%;height:100%;color:#fff;background-color:#000;font-size:13px;line-height:1;position:absolute;inset:0;overflow:hidden}.artplayer-Line truncated
|
||||
Reference in new issue
Block a user