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

@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,o,i,s,a){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],l=u.i||{},f=u.cache||{},d="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof c[n]&&c[n];if(!r&&i)return i(t,!0);if(u)return u(t,!0);if(d&&"string"==typeof t)return d(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var a=f[t]=new p.Module(t);e[t][0].call(a.exports,l,a,a.exports,c)}return f[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=d,this.exports={}},p.modules=e,p.cache=f,p.parent=u,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return c[n]}}),c[n]=p;for(var v=0;v<t.length;v++)p(t[v]);if(r){var h=p(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({"4kqKD":[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return a});var i=e("./adapter"),s=o.interopDefault(i);function a(e){return function(t){var r=new(0,s.default)(t,e);return{name:"artplayerPluginLibass",libass:r.libass,visible:r.visible,init:r.init.bind(r),switch:r.switch.bind(r),show:r.show.bind(r),hide:r.hide.bind(r),destroy:r.destroy.bind(r)}}}"undefined"!=typeof window&&(window.artplayerPluginLibass=a)},{"./adapter":"jEGLL","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],jEGLL:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return O});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),s=e("@swc/helpers/cjs/_class_call_check.cjs"),a=e("@swc/helpers/cjs/_class_private_method_get.cjs"),c=e("@swc/helpers/cjs/_class_private_method_init.cjs"),u=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_object_spread.cjs"),f=e("@swc/helpers/cjs/_object_spread_props.cjs"),d=e("@swc/helpers/cjs/_sliced_to_array.cjs"),p=e("@swc/helpers/cjs/_type_of.cjs"),v=e("@swc/helpers/cjs/_ts_generator.cjs"),h=e("libass-wasm"),b=o.interopDefault(h),y=new WeakSet,m=new WeakSet,w=new WeakSet,g=new WeakSet,_=new WeakSet,k=new WeakSet,j=new WeakSet,x=new WeakSet,O=function(){"use strict";function e(t,r){(0,s._)(this,e),(0,c._)(this,y),(0,c._)(this,m),(0,c._)(this,w),(0,c._)(this,g),(0,c._)(this,_),(0,c._)(this,k),(0,c._)(this,j),(0,c._)(this,x);var n=t.constructor,o=t.template;this.art=t,this.$video=o.$video,this.$webvtt=o.$subtitle,this.utils=n.utils,this.libass=null,t.once("ready",this.init.bind(this,r))}return(0,u._)(e,[{key:"init",value:function(e){var t=this;return(0,i._)(function(){var r,n,o,i;return(0,v._)(this,function(s){switch(s.label){case 0:return(0,a._)(t,x,C).call(t),[4,(0,a._)(t,y,E).call(t,e)];case 1:return s.sent(),(0,a._)(t,m,L).call(t),t.art.emit("artplayerPluginLibass:init",t),(i=null==(o=t.art)||null==(n=o.option)||null==(r=n.subtitle)?void 0:r.url)&&"ass"===t.utils.getExt(i)&&t.switch(i),[2]}})})()}},{key:"switch",value:function(e){this.art.emit("artplayerPluginLibass:switch",e),e&&"ass"===this.utils.getExt(e)?(this.currentType="ass",this.libass.freeTrack(),this.libass.setTrackByUrl((0,a._)(this,_,M).call(this,e)),this.visible=this.art.subtitle.show):(this.currentType="webvtt",this.hide(),this.libass.freeTrack())}},{key:"setVisibility",value:function(e){this.visible=e}},{key:"setOffset",value:function(e){this.timeOffset=e}},{key:"active",get:function(){return"ass"===this.currentType}},{key:"visible",get:function(){return!!this.libass&&"none"!==this.libass.canvasParent.style.display},set:function(e){this.art.emit("artplayerPluginLibass:visible",e),(0,a._)(this,g,T).call(this,!this.active),this.libass.canvasParent&&(this.libass.canvasParent.style.display=e?"block":"none",e&&this.libass.resize())}},{key:"timeOffset",get:function(){return this.libass.timeOffset},set:function(e){this.art.emit("artplayerPluginLibass:timeOffset",e),this.libass.timeOffset=e}},{key:"show",value:function(){this.visible=!0}},{key:"hide",value:function(){this.visible=!1}},{key:"destroy",value:function(){this.art.emit("artplayerPluginLibass:destroy"),(0,a._)(this,w,S).call(this),this.libass.dispose(),URL.revokeObjectURL(this.workerScriptUrl),this.libass=null}}]),e}();function E(){return P.apply(this,arguments)}function P(){return(P=(0,i._)(function(){var e,t,r,n,o,i,s,c=arguments;return(0,v._)(this,function(u){switch(u.label){case 0:if(e=this,!(t=c.length>0&&void 0!==c[0]?c[0]:{}).fallbackFont)return[2,this.utils.errorHandle(t.fallbackFont,"artplayerPluginLibass: fallbackFonLine truncated
!function(e,t,r,n,o,s,i,a){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],l=u.i||{},f=u.cache||{},d="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var s="function"==typeof c[n]&&c[n];if(!r&&s)return s(t,!0);if(u)return u(t,!0);if(d&&"string"==typeof t)return d(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var a=f[t]=new p.Module(t);e[t][0].call(a.exports,l,a,a.exports,c)}return f[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=d,this.exports={}},p.modules=e,p.cache=f,p.parent=u,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return c[n]}}),c[n]=p;for(var v=0;v<t.length;v++)p(t[v]);if(r){var h=p(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({bzF6W:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return a});var s=e("./adapter"),i=o.interopDefault(s);function a(e){return function(t){var r=new(0,i.default)(t,e);return{name:"artplayerPluginLibass",libass:r.libass,visible:r.visible,init:r.init.bind(r),switch:r.switch.bind(r),show:r.show.bind(r),hide:r.hide.bind(r),destroy:r.destroy.bind(r)}}}"undefined"!=typeof window&&(window.artplayerPluginLibass=a)},{"./adapter":"kvT3o","@parcel/transformer-js/src/esmodule-helpers.js":"ihnSZ"}],kvT3o:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return O});var s=e("@swc/helpers/cjs/_async_to_generator.cjs"),i=e("@swc/helpers/cjs/_class_call_check.cjs"),a=e("@swc/helpers/cjs/_class_private_method_get.cjs"),c=e("@swc/helpers/cjs/_class_private_method_init.cjs"),u=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_object_spread.cjs"),f=e("@swc/helpers/cjs/_object_spread_props.cjs"),d=e("@swc/helpers/cjs/_sliced_to_array.cjs"),p=e("@swc/helpers/cjs/_type_of.cjs"),v=e("@swc/helpers/cjs/_ts_generator.cjs"),h=e("libass-wasm"),b=o.interopDefault(h),y=new WeakSet,m=new WeakSet,w=new WeakSet,g=new WeakSet,_=new WeakSet,k=new WeakSet,j=new WeakSet,x=new WeakSet,O=function(){"use strict";function e(t,r){(0,i._)(this,e),(0,c._)(this,y),(0,c._)(this,m),(0,c._)(this,w),(0,c._)(this,g),(0,c._)(this,_),(0,c._)(this,k),(0,c._)(this,j),(0,c._)(this,x);var n=t.constructor,o=t.template;this.art=t,this.$video=o.$video,this.$webvtt=o.$subtitle,this.utils=n.utils,this.libass=null,t.once("ready",this.init.bind(this,r))}return(0,u._)(e,[{key:"init",value:function(e){var t=this;return(0,s._)(function(){var r,n,o,s;return(0,v._)(this,function(i){switch(i.label){case 0:return(0,a._)(t,x,F).call(t),[4,(0,a._)(t,y,E).call(t,e)];case 1:return i.sent(),(0,a._)(t,m,L).call(t),t.art.emit("artplayerPluginLibass:init",t),(s=null==(o=t.art)||null==(n=o.option)||null==(r=n.subtitle)?void 0:r.url)&&"ass"===t.utils.getExt(s)&&t.switch(s),[2]}})})()}},{key:"switch",value:function(e){this.art.emit("artplayerPluginLibass:switch",e),e&&"ass"===this.utils.getExt(e)?(this.currentType="ass",this.libass.freeTrack(),this.libass.setTrackByUrl((0,a._)(this,_,M).call(this,e)),this.visible=this.art.subtitle.show):(this.currentType="webvtt",this.hide(),this.libass.freeTrack())}},{key:"setVisibility",value:function(e){this.visible=e}},{key:"setOffset",value:function(e){this.timeOffset=e}},{key:"active",get:function(){return"ass"===this.currentType}},{key:"visible",get:function(){return!!this.libass&&"none"!==this.libass.canvasParent.style.display},set:function(e){this.art.emit("artplayerPluginLibass:visible",e),(0,a._)(this,g,S).call(this,!this.active),this.libass.canvasParent&&(this.libass.canvasParent.style.display=e?"block":"none",e&&this.libass.resize())}},{key:"timeOffset",get:function(){return this.libass.timeOffset},set:function(e){this.art.emit("artplayerPluginLibass:timeOffset",e),this.libass.timeOffset=e}},{key:"show",value:function(){this.visible=!0}},{key:"hide",value:function(){this.visible=!1}},{key:"destroy",value:function(){this.art.emit("artplayerPluginLibass:destroy"),(0,a._)(this,w,T).call(this),this.libass.dispose(),URL.revokeObjectURL(this.workerScriptUrl),this.libass=null}}]),e}();function E(){return P.apply(this,arguments)}function P(){return(P=(0,s._)(function(){var e,t,r,n,o,s,i,c=arguments;return(0,v._)(this,function(u){switch(u.label){case 0:if(e=this,!(t=c.length>0&&void 0!==c[0]?c[0]:{}).fallbackFont)return[2,this.utils.errorHandle(t.fallbackFont,"artplayerPluginLibass: fallbackFont Line truncated