feat: add danmuku plugin documentation and i18n setup guide

- 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.
This commit is contained in:
Harvey Zack committed 2025-08-01 09:34:07 +08:00
1 parent c1fe0e2b03
commit 5337f9b075
181 files changed
+1680 -1659

No files matched your search

+1 -1
View File
@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,n,l,t,i,a,r,o){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},p="function"==typeof d[t]&&d[t],s=p.i||{},u=p.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function y(n,l){if(!u[n]){if(!e[n]){if(i[n])return i[n];var a="function"==typeof d[t]&&d[t];if(!l&&a)return a(n,!0);if(p)return p(n,!0);if(c&&"string"==typeof n)return c(n);var r=Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}s.resolve=function(l){var t=e[n][1][l];return null!=t?t:l},s.cache={};var o=u[n]=new y.Module(n);e[n][0].call(o.exports,s,o,o.exports,d)}return u[n].exports;function s(e){var n=s.resolve(e);return!1===n?{}:y(n)}}y.isParcelRequire=!0,y.Module=function(e){this.id=e,this.bundle=y,this.require=c,this.exports={}},y.modules=e,y.cache=u,y.parent=p,y.distDir=void 0,y.publicUrl=void 0,y.devServer=void 0,y.i=s,y.register=function(n,l){e[n]=[function(e,n){n.exports=l},{}]},Object.defineProperty(y,"root",{get:function(){return d[t]}}),d[t]=y;for(var f=0;f<n.length;f++)y(n[f]);if(l){var g=y(l);"object"==typeof exports&&"undefined"!=typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({ezZng:[function(e,n,l,t){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(l),i.export(l,"default",()=>o);var a=e("bundle-text:./style.less"),r=i.interopDefault(a);function o(e){return n=>{let{version:l,utils:{errorHandle:t}}=n.constructor,i=l.split(".").map(Number);t(i[0]+i[1]/100>=5,`Artplayer.js@${l} is not compatible the artplayerPluginAds@${o.version}. Please update it to version Artplayer.js@5.x.x`);let{template:{$player:a},icons:{volume:r,volumeClose:d,fullscreenOn:p,fullscreenOff:s,loading:u},constructor:{validator:c,utils:{query:y,append:f,setStyle:g}}}=n;e=c({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"}});let m=null,v=null,x=null,h=null,b=null,w=null,D=0,j=null,k=!1,P=!1,$=!1;function O(e,n){return n.replace("%s",e)}function A(){k=!0,n.play(),e.video&&m.pause(),g(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function M(){k||(j=setTimeout(()=>{D+=1;let n=e.playDuration-D;n>=1?x.innerHTML=O(n,e.i18n.canBeClosed):(x.innerHTML=e.i18n.close,$||($=!0)),h.innerHTML=O(e.totalDuration-D,e.i18n.countdown),D>=e.totalDuration?A():M()},1e3))}function T(){k||clearTimeout(j)}function _(){P||(P=!0,function(){n.template.$ads=f(a,'<div class="artplayer-plugin-ads"></div>'),m=f(n.template.$ads,e.video?`<video class="artplayer-plugin-ads-video" src="${e.video}" loop playsInline></video>`:`<div class="artplayer-plugin-ads-html">${e.html}</div>`),w=f(n.template.$ads,'<div class="artplayer-plugin-ads-loading"></div>'),f(w,u),x=y(".artplayer-plugin-ads-close",v=f(n.template.$ads,`<div class="artplayer-plugin-ads-timer"><div class="artplayer-plugin-ads-close">${e.playDuration<=0?e.i18n.close:O(e.playDuration,e.i18n.canBeClosed)}</div><div class="artplayer-plugin-ads-countdown">${O(e.totalDuration,e.i18n.countdown)}</div></div>`)),h=y(".artplayer-plugin-ads-countdown",v),e.playDuration>=e.totalDuration&&g(x,"display","none"),n.proxy(x,"click",()=>{$&&A()});let l=y(".artplayer-plugin-ads-detail",b=f(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>`)),t=y(".artplayer-plugin-ads-muted",b),i=y(".artplayer-plugin-ads-fullscreen",b);if(e.url?n.proxy(l,"click",()=>{window.open(e.url),n.emit("artplayerPluginAds:click",e)}):g(l,"display","none"),e.video){let l=f(t,r),i=f(t,d);g(i,"display","none"),e.muted&&(m.muted=!0,g(l,"display","none"),g(i,"display","inline-flex")),n.proxy(t,"click",()=>{m.muted=!m.muted,m.muted?(g(l,"display","none"),g(i,"display","inline-flex")):(g(l,"display","inline-flex"),g(i,"display","none"))})}else g(t,"display","none");let o=f(i,p),c=f(i,s);g(c,"display","none"),n.proxy(i,"click",()=>{n.fullscreen=!n.fullscreen,n.fullscreen?(g(o,"display","inline-flex"),g(c,"display","none")):(g(o,"display","none"),g(c,"display","inline-flex"))}),n.proxy(m,"click",()=>{e.url&&window.open(e.url),n.emit("artplayerPluginAds:click",e)})}(),n.pause(),e.video?(n.proxy(m,"error",A),n.proxy(m,"loadedmetadata",()=>{M(),m.play(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")})):(M(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")),n.proxy(document,"visibilitychange",()=>{document.hidden?T():M()}))}return n.on("ready",()=>{n.once("play",_),n.once("video:playing",_)}),{name:"artpLine truncated
!function(e,n,l,t,i,a,r,o){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},p="function"==typeof d[t]&&d[t],s=p.i||{},u=p.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function y(n,l){if(!u[n]){if(!e[n]){if(i[n])return i[n];var a="function"==typeof d[t]&&d[t];if(!l&&a)return a(n,!0);if(p)return p(n,!0);if(c&&"string"==typeof n)return c(n);var r=Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}s.resolve=function(l){var t=e[n][1][l];return null!=t?t:l},s.cache={};var o=u[n]=new y.Module(n);e[n][0].call(o.exports,s,o,o.exports,d)}return u[n].exports;function s(e){var n=s.resolve(e);return!1===n?{}:y(n)}}y.isParcelRequire=!0,y.Module=function(e){this.id=e,this.bundle=y,this.require=c,this.exports={}},y.modules=e,y.cache=u,y.parent=p,y.distDir=void 0,y.publicUrl=void 0,y.devServer=void 0,y.i=s,y.register=function(n,l){e[n]=[function(e,n){n.exports=l},{}]},Object.defineProperty(y,"root",{get:function(){return d[t]}}),d[t]=y;for(var f=0;f<n.length;f++)y(n[f]);if(l){var g=y(l);"object"==typeof exports&&"undefined"!=typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({jz4E5:[function(e,n,l,t){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(l),i.export(l,"default",()=>o);var a=e("bundle-text:./style.less"),r=i.interopDefault(a);function o(e){return n=>{let{version:l,utils:{errorHandle:t}}=n.constructor,i=l.split(".").map(Number);t(i[0]+i[1]/100>=5,`Artplayer.js@${l} is not compatible the artplayerPluginAds@${o.version}. Please update it to version Artplayer.js@5.x.x`);let{template:{$player:a},icons:{volume:r,volumeClose:d,fullscreenOn:p,fullscreenOff:s,loading:u},constructor:{validator:c,utils:{query:y,append:f,setStyle:g}}}=n;e=c({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"}});let m=null,v=null,x=null,h=null,b=null,w=null,j=0,D=null,P=!1,$=!1,k=!1;function O(e,n){return n.replace("%s",e)}function A(){P=!0,n.play(),e.video&&m.pause(),g(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function M(){P||(D=setTimeout(()=>{j+=1;let n=e.playDuration-j;n>=1?x.innerHTML=O(n,e.i18n.canBeClosed):(x.innerHTML=e.i18n.close,k||(k=!0)),h.innerHTML=O(e.totalDuration-j,e.i18n.countdown),j>=e.totalDuration?A():M()},1e3))}function E(){P||clearTimeout(D)}function T(){$||($=!0,function(){n.template.$ads=f(a,'<div class="artplayer-plugin-ads"></div>'),m=f(n.template.$ads,e.video?`<video class="artplayer-plugin-ads-video" src="${e.video}" loop playsInline></video>`:`<div class="artplayer-plugin-ads-html">${e.html}</div>`),w=f(n.template.$ads,'<div class="artplayer-plugin-ads-loading"></div>'),f(w,u),x=y(".artplayer-plugin-ads-close",v=f(n.template.$ads,`<div class="artplayer-plugin-ads-timer"><div class="artplayer-plugin-ads-close">${e.playDuration<=0?e.i18n.close:O(e.playDuration,e.i18n.canBeClosed)}</div><div class="artplayer-plugin-ads-countdown">${O(e.totalDuration,e.i18n.countdown)}</div></div>`)),h=y(".artplayer-plugin-ads-countdown",v),e.playDuration>=e.totalDuration&&g(x,"display","none"),n.proxy(x,"click",()=>{k&&A()});let l=y(".artplayer-plugin-ads-detail",b=f(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>`)),t=y(".artplayer-plugin-ads-muted",b),i=y(".artplayer-plugin-ads-fullscreen",b);if(e.url?n.proxy(l,"click",()=>{window.open(e.url),n.emit("artplayerPluginAds:click",e)}):g(l,"display","none"),e.video){let l=f(t,r),i=f(t,d);g(i,"display","none"),e.muted&&(m.muted=!0,g(l,"display","none"),g(i,"display","inline-flex")),n.proxy(t,"click",()=>{m.muted=!m.muted,m.muted?(g(l,"display","none"),g(i,"display","inline-flex")):(g(l,"display","inline-flex"),g(i,"display","none"))})}else g(t,"display","none");let o=f(i,p),c=f(i,s);g(c,"display","none"),n.proxy(i,"click",()=>{n.fullscreen=!n.fullscreen,n.fullscreen?(g(o,"display","inline-flex"),g(c,"display","none")):(g(o,"display","none"),g(c,"display","inline-flex"))}),n.proxy(m,"click",()=>{e.url&&window.open(e.url),n.emit("artplayerPluginAds:click",e)})}(),n.pause(),e.video?(n.proxy(m,"error",A),n.proxy(m,"loadedmetadata",()=>{M(),m.play(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")})):(M(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")),n.proxy(document,"visibilitychange",()=>{document.hidden?E():M()}))}return n.on("ready",()=>{n.once("play",T),n.once("video:playing",T)}),{name:"artpLine truncated