mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
- Created a new documentation file for the danmuku plugin, detailing its usage and providing code examples. - Added a comprehensive guide for language settings (i18n), including instructions for importing languages, setting default languages, and modifying language options. - Included code snippets for initializing the Artplayer with different languages and examples for adding new languages.
8 lines
8.0 KiB
JavaScript
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,i,l,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[i]&&d[i],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(l[n])return l[n];var r="function"==typeof d[i]&&d[i];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 i=e[n][1][t];return null!=i?i: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[i]}}),d[i]=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})}}({bzF6W:[function(e,n,t,i){var l=e("@parcel/transformer-js/src/esmodule-helpers.js");l.defineInteropFlag(t),l.export(t,"default",function(){return d});var r=e("@swc/helpers/cjs/_object_spread.cjs"),a=e("bundle-text:./style.less"),o=l.interopDefault(a);function d(e){return function(n){i=(t=n.constructor).version,(0,t.utils.errorHandle)((l=i.split(".").map(Number))[0]+l[1]/100>=5,"Artplayer.js@".concat(i," is not compatible the artplayerPluginAds@").concat(d.version,". Please update it to version Artplayer.js@5.x.x"));var t,i,l,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,h=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 x=null,w=null,j=null,O=null,D=null,P=null,_=0,k=null,A=!1,M=!1,q=!1;function C(e,n){return n.replace("%s",e)}function T(){A=!0,n.play(),e.video&&x.pause(),h(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function B(){A||(k=setTimeout(function(){_+=1;var n=e.playDuration-_;n>=1?j.innerHTML=C(n,e.i18n.canBeClosed):(j.innerHTML=e.i18n.close,q||(q=!0)),O.innerHTML=C(e.totalDuration-_,e.i18n.countdown),_>=e.totalDuration?T():B()},1e3))}function $(){A||clearTimeout(k)}function E(){M||(M=!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>")),P=b(n.template.$ads,'<div class="artplayer-plugin-ads-loading"></div>'),b(P,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&&h(j,"display","none"),n.proxy(j,"click",function(){q&&T()});var t=v(".artplayer-plugin-ads-detail",D=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>'))),i=v(".artplayer-plugin-ads-muted",D),l=v(".artplayer-plugin-ads-fullscreen",D);if(e.url?n.proxy(t,"click",function(){window.open(e.url),n.emit("artplayerPluginAds:click",e)}):h(t,"display","none"),e.video){var r=b(i,u),o=b(i,s);h(o,"display","none"),e.muted&&(x.muted=!0,h(r,"display","none"),h(o,"display","inline-flex")),n.proxy(i,"click",function(){x.muted=!x.muted,x.muted?(h(r,"display","none"),h(o,"display","inline-flex")):(h(r,"display","inline-flex"),h(o,"display","none"))})}else h(i,"display","none");var d=b(l,p),y=b(l,c);h(y,"display","none"),n.proxy(l,"click",function(){n.fullscreen=!n.fullscreen,n.fullscreen?(h(d,"display","inline-flex"),h(y,"display","none")):(h(d,"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",T),n.proxy(x,"loadedmetadata",function(){B(),x.play(),h(w,"display","flex"),h(D,"display","flex"),h(P,"display","none")})):(B(),h(w,"display","flex"),h(D,"display","flex"),h(P,"display","none")),n.proxy(document,"visibilitychange",function(){document.hidden?$():B()}))}return n.on("ready",function(){n.once("play",E),n.once("video:playing",E)}),{name:"artplayerPluginAds",skip:T,pause:$,play:B}}}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":"7vaqr","bundle-text:./style.less":"9Oi7e","@parcel/transformer-js/src/esmodule-helpers.js":"ihnSZ"}],"7vaqr":[function(e,n,t,i){"use strict";var l=e("b3d0f206b721b857");t._=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.forEach(function(n){l._(e,n,t[n])})}return e}},{b3d0f206b721b857:"dgB2K"}],dgB2K:[function(e,n,t,i){"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}},{}],"9Oi7e":[function(e,n,t,i){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}"},{}],ihnSZ:[function(e,n,t,i){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})}},{}]},["bzF6W"],"bzF6W","parcelRequirea5da",{}); |