From c91192816652857da8f5eeb32c5e2b1246f7e8b1 Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Sun, 17 Aug 2025 12:09:50 +0800 Subject: [PATCH] feat: add danmuku plugin documentation and i18n setup - Created a new documentation file for the danmuku plugin with interactive code execution. - Added comprehensive i18n setup instructions, including default language settings, language imports, and examples for adding and modifying languages. - Introduced a test file to verify the integration of the danmuku plugin. --- CHANGELOG_CN.md | 1 + docs/assets/ts/artplayer-plugin-danmuku.d.ts | 20 ++- ...in-ads.esm.js => artplayer-plugin-ads.mjs} | 2 +- ...sm.js.map => artplayer-plugin-ads.mjs.map} | 0 ....esm.js => artplayer-plugin-ambilight.mjs} | 2 +- ...map => artplayer-plugin-ambilight.mjs.map} | 0 ...in-asr.esm.js => artplayer-plugin-asr.mjs} | 2 +- ...sm.js.map => artplayer-plugin-asr.mjs.map} | 0 ...js => artplayer-plugin-auto-thumbnail.mjs} | 2 +- ...> artplayer-plugin-auto-thumbnail.mjs.map} | 0 ...er.esm.js => artplayer-plugin-chapter.mjs} | 2 +- ...s.map => artplayer-plugin-chapter.mjs.map} | 0 ...esm.js => artplayer-plugin-chromecast.mjs} | 2 +- ...ap => artplayer-plugin-chromecast.mjs.map} | 0 ...m.js => artplayer-plugin-danmuku-mask.mjs} | 2 +- ... => artplayer-plugin-danmuku-mask.mjs.map} | 0 ...ku.esm.js => artplayer-plugin-danmuku.mjs} | 2 +- ...s.map => artplayer-plugin-danmuku.mjs.map} | 0 ...m.js => artplayer-plugin-dash-control.mjs} | 2 +- ... => artplayer-plugin-dash-control.mjs.map} | 0 .../compiled/artplayer-plugin-dash-quality.js | 1 - .../artplayer-plugin-dash-quality.legacy.js | 1 - ...m.js => artplayer-plugin-document-pip.mjs} | 2 +- ... => artplayer-plugin-document-pip.mjs.map} | 0 ...sm.js => artplayer-plugin-hls-control.mjs} | 2 +- ...p => artplayer-plugin-hls-control.mjs.map} | 0 ...ame.esm.js => artplayer-plugin-iframe.mjs} | 2 +- ...js.map => artplayer-plugin-iframe.mjs.map} | 0 ...ass.esm.js => artplayer-plugin-libass.mjs} | 2 +- ...js.map => artplayer-plugin-libass.mjs.map} | 0 ...> artplayer-plugin-multiple-subtitles.mjs} | 2 +- ...tplayer-plugin-multiple-subtitles.mjs.map} | 0 ...-vast.esm.js => artplayer-plugin-vast.mjs} | 2 +- ...m.js.map => artplayer-plugin-vast.mjs.map} | 0 ....js => artplayer-plugin-vtt-thumbnail.mjs} | 2 +- ...=> artplayer-plugin-vtt-thumbnail.mjs.map} | 0 ...nvas.esm.js => artplayer-proxy-canvas.mjs} | 2 +- ....js.map => artplayer-proxy-canvas.mjs.map} | 0 ...il.esm.js => artplayer-tool-thumbnail.mjs} | 2 +- ...s.map => artplayer-tool-thumbnail.mjs.map} | 0 .../{artplayer.esm.js => artplayer.mjs} | 2 +- ...artplayer.esm.js.map => artplayer.mjs.map} | 0 docs/document/404.html | 2 +- docs/document/advanced/built-in.html | 2 +- docs/document/advanced/class.html | 2 +- docs/document/advanced/event.html | 2 +- docs/document/advanced/global.html | 2 +- docs/document/advanced/plugin.html | 2 +- docs/document/advanced/property.html | 2 +- ...md.CVTkjvLi.js => en_index.md.BoUDo3iv.js} | 8 +- ...i.lean.js => en_index.md.BoUDo3iv.lean.js} | 0 ...PhEMUT.js => en_start_i18n.md.DAQP9Wc-.js} | 2 +- ...n.js => en_start_i18n.md.DAQP9Wc-.lean.js} | 0 ...ex.md.B7z5s1WD.js => index.md.Ct-mw3b5.js} | 8 +- ...s1WD.lean.js => index.md.Ct-mw3b5.lean.js} | 0 ...dwoB_.js => plugin_danmuku.md.4zCywahu.js} | 2 +- ....js => plugin_danmuku.md.4zCywahu.lean.js} | 0 ....DkqeV9gh.js => start_i18n.md.B_Jqm0vZ.js} | 2 +- ...lean.js => start_i18n.md.B_Jqm0vZ.lean.js} | 0 docs/document/component/contextmenu.html | 2 +- docs/document/component/controls.html | 2 +- docs/document/component/layers.html | 2 +- docs/document/component/setting.html | 2 +- docs/document/en/advanced/built-in.html | 2 +- docs/document/en/advanced/class.html | 2 +- docs/document/en/advanced/event.html | 2 +- docs/document/en/advanced/global.html | 2 +- docs/document/en/advanced/plugin.html | 2 +- docs/document/en/advanced/property.html | 2 +- docs/document/en/component/contextmenu.html | 2 +- docs/document/en/component/controls.html | 2 +- docs/document/en/component/layers.html | 2 +- docs/document/en/component/setting.html | 2 +- docs/document/en/index.html | 12 +- docs/document/en/start/i18n.html | 6 +- docs/document/en/start/option.html | 2 +- docs/document/hashmap.json | 2 +- docs/document/index.html | 12 +- docs/document/plugin/danmuku.html | 6 +- docs/document/start/i18n.html | 6 +- docs/document/start/option.html | 2 +- docs/esm.html | 4 +- packages/artplayer-plugin-ads/package.json | 15 +- .../artplayer-plugin-ambilight/package.json | 15 +- packages/artplayer-plugin-asr/package.json | 15 +- .../package.json | 15 +- .../artplayer-plugin-chapter/package.json | 15 +- .../artplayer-plugin-chromecast/package.json | 15 +- .../package.json | 15 +- .../artplayer-plugin-danmuku/package.json | 13 +- .../package.json | 15 +- .../package.json | 13 +- .../artplayer-plugin-hls-control/package.json | 15 +- packages/artplayer-plugin-iframe/package.json | 15 +- packages/artplayer-plugin-libass/package.json | 15 +- .../package.json | 15 +- packages/artplayer-plugin-vast/package.json | 15 +- .../package.json | 15 +- packages/artplayer-proxy-canvas/package.json | 15 +- packages/artplayer-vitepress/docs/en/index.md | 154 ++++++++--------- packages/artplayer-vitepress/docs/index.md | 156 +++++++++--------- scripts/build.js | 45 +++-- test/esm.test.js | 3 + 103 files changed, 416 insertions(+), 370 deletions(-) rename docs/compiled/{artplayer-plugin-ads.esm.js => artplayer-plugin-ads.mjs} (99%) rename docs/compiled/{artplayer-plugin-ads.esm.js.map => artplayer-plugin-ads.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-ambilight.esm.js => artplayer-plugin-ambilight.mjs} (98%) rename docs/compiled/{artplayer-plugin-ambilight.esm.js.map => artplayer-plugin-ambilight.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-asr.esm.js => artplayer-plugin-asr.mjs} (99%) rename docs/compiled/{artplayer-plugin-asr.esm.js.map => artplayer-plugin-asr.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-auto-thumbnail.esm.js => artplayer-plugin-auto-thumbnail.mjs} (98%) rename docs/compiled/{artplayer-plugin-auto-thumbnail.esm.js.map => artplayer-plugin-auto-thumbnail.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-chapter.esm.js => artplayer-plugin-chapter.mjs} (99%) rename docs/compiled/{artplayer-plugin-chapter.esm.js.map => artplayer-plugin-chapter.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-chromecast.esm.js => artplayer-plugin-chromecast.mjs} (98%) rename docs/compiled/{artplayer-plugin-chromecast.esm.js.map => artplayer-plugin-chromecast.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-danmuku-mask.esm.js => artplayer-plugin-danmuku-mask.mjs} (99%) rename docs/compiled/{artplayer-plugin-danmuku-mask.esm.js.map => artplayer-plugin-danmuku-mask.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-danmuku.esm.js => artplayer-plugin-danmuku.mjs} (99%) rename docs/compiled/{artplayer-plugin-danmuku.esm.js.map => artplayer-plugin-danmuku.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-dash-control.esm.js => artplayer-plugin-dash-control.mjs} (98%) rename docs/compiled/{artplayer-plugin-dash-control.esm.js.map => artplayer-plugin-dash-control.mjs.map} (100%) delete mode 100644 docs/compiled/artplayer-plugin-dash-quality.js delete mode 100644 docs/compiled/artplayer-plugin-dash-quality.legacy.js rename docs/compiled/{artplayer-plugin-document-pip.esm.js => artplayer-plugin-document-pip.mjs} (99%) rename docs/compiled/{artplayer-plugin-document-pip.esm.js.map => artplayer-plugin-document-pip.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-hls-control.esm.js => artplayer-plugin-hls-control.mjs} (98%) rename docs/compiled/{artplayer-plugin-hls-control.esm.js.map => artplayer-plugin-hls-control.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-iframe.esm.js => artplayer-plugin-iframe.mjs} (98%) rename docs/compiled/{artplayer-plugin-iframe.esm.js.map => artplayer-plugin-iframe.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-libass.esm.js => artplayer-plugin-libass.mjs} (99%) rename docs/compiled/{artplayer-plugin-libass.esm.js.map => artplayer-plugin-libass.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-multiple-subtitles.esm.js => artplayer-plugin-multiple-subtitles.mjs} (99%) rename docs/compiled/{artplayer-plugin-multiple-subtitles.esm.js.map => artplayer-plugin-multiple-subtitles.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-vast.esm.js => artplayer-plugin-vast.mjs} (99%) rename docs/compiled/{artplayer-plugin-vast.esm.js.map => artplayer-plugin-vast.mjs.map} (100%) rename docs/compiled/{artplayer-plugin-vtt-thumbnail.esm.js => artplayer-plugin-vtt-thumbnail.mjs} (98%) rename docs/compiled/{artplayer-plugin-vtt-thumbnail.esm.js.map => artplayer-plugin-vtt-thumbnail.mjs.map} (100%) rename docs/compiled/{artplayer-proxy-canvas.esm.js => artplayer-proxy-canvas.mjs} (98%) rename docs/compiled/{artplayer-proxy-canvas.esm.js.map => artplayer-proxy-canvas.mjs.map} (100%) rename docs/compiled/{artplayer-tool-thumbnail.esm.js => artplayer-tool-thumbnail.mjs} (99%) rename docs/compiled/{artplayer-tool-thumbnail.esm.js.map => artplayer-tool-thumbnail.mjs.map} (100%) rename docs/compiled/{artplayer.esm.js => artplayer.mjs} (99%) rename docs/compiled/{artplayer.esm.js.map => artplayer.mjs.map} (100%) rename docs/document/assets/{en_index.md.CVTkjvLi.js => en_index.md.BoUDo3iv.js} (98%) rename docs/document/assets/{en_index.md.CVTkjvLi.lean.js => en_index.md.BoUDo3iv.lean.js} (100%) rename docs/document/assets/{en_start_i18n.md.BsPhEMUT.js => en_start_i18n.md.DAQP9Wc-.js} (98%) rename docs/document/assets/{en_start_i18n.md.BsPhEMUT.lean.js => en_start_i18n.md.DAQP9Wc-.lean.js} (100%) rename docs/document/assets/{index.md.B7z5s1WD.js => index.md.Ct-mw3b5.js} (98%) rename docs/document/assets/{index.md.B7z5s1WD.lean.js => index.md.Ct-mw3b5.lean.js} (100%) rename docs/document/assets/{plugin_danmuku.md.DGwdwoB_.js => plugin_danmuku.md.4zCywahu.js} (99%) rename docs/document/assets/{plugin_danmuku.md.DGwdwoB_.lean.js => plugin_danmuku.md.4zCywahu.lean.js} (100%) rename docs/document/assets/{start_i18n.md.DkqeV9gh.js => start_i18n.md.B_Jqm0vZ.js} (98%) rename docs/document/assets/{start_i18n.md.DkqeV9gh.lean.js => start_i18n.md.B_Jqm0vZ.lean.js} (100%) create mode 100644 test/esm.test.js diff --git a/CHANGELOG_CN.md b/CHANGELOG_CN.md index 610e1e303..8abe33f65 100644 --- a/CHANGELOG_CN.md +++ b/CHANGELOG_CN.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +- 重命名 `.esm.js` 到 `.mjs` - 移除 `svg` 默认的 `fill` 颜色值 - 优化 `autoOrientation` 逻辑 - 添加 `artplayer-plugin-document-pip` 插件 diff --git a/docs/assets/ts/artplayer-plugin-danmuku.d.ts b/docs/assets/ts/artplayer-plugin-danmuku.d.ts index 80a7ef540..6f6a5ec04 100644 --- a/docs/assets/ts/artplayer-plugin-danmuku.d.ts +++ b/docs/assets/ts/artplayer-plugin-danmuku.d.ts @@ -1,17 +1,21 @@ -type Mode = 0 | 1 | 2 -type Danmuku = Danmu[] | string | (() => Promise) | Promise +export type Mode = 0 | 1 | 2 +export type Danmuku + = | Danmu[] + | string // URL + | (() => Promise) + | Promise -interface Slider { +export interface Slider { min?: number max?: number steps?: { name?: string - value?: any + value?: number | string show?: boolean }[] } -interface Danmu { +export interface Danmu { /** * 弹幕文本 */ @@ -43,7 +47,7 @@ interface Danmu { style?: Partial } -interface Option { +export interface Option { /** * 弹幕数据: 函数,数组,Promise,URL */ @@ -125,7 +129,7 @@ interface Option { /** * 热力图数据 */ - points?: any[] + points?: { time: number, value: number }[] /** * 弹幕载入前的过滤器,只支持返回布尔值 @@ -193,7 +197,7 @@ interface Option { COLOR?: string[] } -interface Result { +export interface Result { name: 'artplayerPluginDanmuku' /** diff --git a/docs/compiled/artplayer-plugin-ads.esm.js b/docs/compiled/artplayer-plugin-ads.mjs similarity index 99% rename from docs/compiled/artplayer-plugin-ads.esm.js rename to docs/compiled/artplayer-plugin-ads.mjs index d8bf54bbd..07063a412 100644 --- a/docs/compiled/artplayer-plugin-ads.esm.js +++ b/docs/compiled/artplayer-plugin-ads.mjs @@ -6,4 +6,4 @@ * 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;fo);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,P=!1,$=!1,k=!1;function M(e,n){return n.replace("%s",e)}function O(){P=!0,n.play(),e.video&&m.pause(),g(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function A(){P||(j=setTimeout(()=>{D+=1;let n=e.playDuration-D;n>=1?x.innerHTML=M(n,e.i18n.canBeClosed):(x.innerHTML=e.i18n.close,k||(k=!0)),h.innerHTML=M(e.totalDuration-D,e.i18n.countdown),D>=e.totalDuration?O():A()},1e3))}function _(){P||clearTimeout(j)}function T(){$||($=!0,function(){n.template.$ads=f(a,'
'),m=f(n.template.$ads,e.video?``:`
${e.html}
`),w=f(n.template.$ads,'
'),f(w,u),x=y(".artplayer-plugin-ads-close",v=f(n.template.$ads,`
${e.playDuration<=0?e.i18n.close:M(e.playDuration,e.i18n.canBeClosed)}
${M(e.totalDuration,e.i18n.countdown)}
`)),h=y(".artplayer-plugin-ads-countdown",v),e.playDuration>=e.totalDuration&&g(x,"display","none"),n.proxy(x,"click",()=>{k&&O()});let l=y(".artplayer-plugin-ads-detail",b=f(n.template.$ads,`
${e.i18n.detail}
`)),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",O),n.proxy(m,"loadedmetadata",()=>{A(),m.play(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")})):(A(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")),n.on("document:visibilitychange",()=>{document.hidden?_():A()}))}return n.on("ready",()=>{n.once("play",T),n.once("video:playing",T)}),{name:"artplayerPluginAds",skip:O,pause:_,play:A}}}if("undefined"!=typeof document&&!document.getElementById("artplayer-plugin-ads")){let e=document.createElement("style");e.id="artplayer-plugin-ads",e.textContent=r.default,document.head.appendChild(e)}"undefined"!=typeof window&&(window.artplayerPluginAds=o)},{"bundle-text:./style.less":"1GXMH","@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"1GXMH":[function(e,n,l,t){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;inset: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:#00000080;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:#00000080;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;inset:0}"},{}],"5lQoW":[function(e,n,l,t){l.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},l.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},l.exportAll=function(e,n){return Object.keys(e).forEach(function(l){"default"===l||"__esModule"===l||Object.prototype.hasOwnProperty.call(n,l)||Object.defineProperty(n,l,{enumerable:!0,get:function(){return e[l]}})}),n},l.export=function(e,n,l){Object.defineProperty(e,n,{enumerable:!0,get:l})}},{}]},["2Uydo"],"2Uydo","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("2Uydo");export{e as default}; -//# sourceMappingURL=artplayer-plugin-ads.esm.js.map \ No newline at end of file +//# sourceMappingURL=artplayer-plugin-ads.mjs.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-ads.esm.js.map b/docs/compiled/artplayer-plugin-ads.mjs.map similarity index 100% rename from docs/compiled/artplayer-plugin-ads.esm.js.map rename to docs/compiled/artplayer-plugin-ads.mjs.map diff --git a/docs/compiled/artplayer-plugin-ambilight.esm.js b/docs/compiled/artplayer-plugin-ambilight.mjs similarity index 98% rename from docs/compiled/artplayer-plugin-ambilight.esm.js rename to docs/compiled/artplayer-plugin-ambilight.mjs index c8fef94c2..7cb8a2201 100644 --- a/docs/compiled/artplayer-plugin-ambilight.esm.js +++ b/docs/compiled/artplayer-plugin-ambilight.mjs @@ -6,4 +6,4 @@ * Released under the MIT License. */ !function(e,r,t,n,o,i,l,u){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof f[n]&&f[n],d=a.i||{},c=a.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(r,t){if(!c[r]){if(!e[r]){if(o[r])return o[r];var i="function"==typeof f[n]&&f[n];if(!t&&i)return i(r,!0);if(a)return a(r,!0);if(s&&"string"==typeof r)return s(r);var l=Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}d.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},d.cache={};var u=c[r]=new p.Module(r);e[r][0].call(u.exports,d,u,u.exports,f)}return c[r].exports;function d(e){var r=d.resolve(e);return!1===r?{}:p(r)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=c,p.parent=a,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=d,p.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(p,"root",{get:function(){return f[n]}}),f[n]=p;for(var m=0;m{var t,n,o,i,l,u,f;let{$video:a}=r.template,{createElement:d,addClass:c,setStyles:s}=r.constructor.utils,{blur:p="50px",opacity:m=.5,frequency:g=10,duration:y=.3}=e,h=d("div"),b=((t=h).innerHTML=Array.from({length:9}).fill("
").join(""),Array.from(t.children));n=h,o=a,c(n,"artplayer-plugin-ambilight"),o.parentNode.insertBefore(n,o),s(n,{position:"absolute",top:0,left:0,zIndex:9,inset:0,display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gridTemplateRows:"1fr 1fr 1fr"}),i=b,l=p,u=m,f=y,i.forEach(e=>{s(e,{opacity:u,filter:`blur(${l})`,transition:`background-color ${f}s ease`})});let v=function(e,t,n){let o=d("canvas"),i=o.getContext("2d");o.width=3,o.height=3;let l=0;return function o(){let u=performance.now();if(u-l<1e3/n||!r.playing){w=requestAnimationFrame(o);return}l=u;let f=e.videoWidth/3,a=e.videoHeight/3,d=[[0,0],[f,0],[2*f,0],[0,a],[f,a],[2*f,a],[0,2*a],[f,2*a],[2*f,2*a]].map(([r,t])=>(function(r,t,n,o){i.drawImage(e,r,t,n,o,0,0,1,1);let[l,u,f]=i.getImageData(0,0,1,1).data;return`rgb(${l}, ${u}, ${f})`})(r,t,f,a));t.forEach((e,r)=>{e.style.backgroundColor=d[r]}),w=requestAnimationFrame(o)}}(a,b,g),w=null;function x(){w||v()}function j(){w&&(cancelAnimationFrame(w),w=null)}return r.on("ready",x),r.on("destroy",j),{name:"artplayerPluginAmbilight",start:x,stop:j}}}o.defineInteropFlag(t),o.export(t,"default",()=>i),"undefined"!=typeof window&&(window.artplayerPluginAmbilight=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,r,t,n){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,r){return Object.keys(e).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:function(){return e[t]}})}),r},t.export=function(e,r,t){Object.defineProperty(e,r,{enumerable:!0,get:t})}},{}]},["9P7rs"],"9P7rs","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("9P7rs");export{e as default}; -//# sourceMappingURL=artplayer-plugin-ambilight.esm.js.map \ No newline at end of file +//# sourceMappingURL=artplayer-plugin-ambilight.mjs.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-ambilight.esm.js.map b/docs/compiled/artplayer-plugin-ambilight.mjs.map similarity index 100% rename from docs/compiled/artplayer-plugin-ambilight.esm.js.map rename to docs/compiled/artplayer-plugin-ambilight.mjs.map diff --git a/docs/compiled/artplayer-plugin-asr.esm.js b/docs/compiled/artplayer-plugin-asr.mjs similarity index 99% rename from docs/compiled/artplayer-plugin-asr.esm.js rename to docs/compiled/artplayer-plugin-asr.mjs index aede905f9..5630ef3ff 100644 --- a/docs/compiled/artplayer-plugin-asr.esm.js +++ b/docs/compiled/artplayer-plugin-asr.mjs @@ -6,4 +6,4 @@ * Released under the MIT License. */ !function(e,t,r,n,o,a,i,l){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof u[n]&&u[n],c=s.i||{},d=s.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!d[t]){if(!e[t]){if(o[t])return o[t];var a="function"==typeof u[n]&&u[n];if(!r&&a)return a(t,!0);if(s)return s(t,!0);if(p&&"string"==typeof t)return p(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}c.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},c.cache={};var l=d[t]=new f.Module(t);e[t][0].call(l.exports,c,l,l.exports,u)}return d[t].exports;function c(e){var t=c.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=p,this.exports={}},f.modules=e,f.cache=d,f.parent=s,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=c,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return u[n]}}),u[n]=f;for(var y=0;yl);var a=e("bundle-text:./style.less"),i=o.interopDefault(a);function l(e={}){let{length:t=3,interval:r=100,sampleRate:n=16e3,autoHideTimeout:o=1e4,onAudioChunk:a=()=>null}=e;return e=>{let i=!1,l=null,u=null,s=null,c=null,d=[],p=null,f=!1,y=null,m=null,b=null,g=e.layers.add({name:"asr",html:""});function v(){g.style.display="none"}function h(e){"string"==typeof e&&(clearTimeout(y),y=setTimeout(v,o),g.style.display="",g.innerHTML=e.split(/(?<=[、。!?!?.])\s*/u).map(e=>e.trim()).filter(Boolean).slice(-t).map(e=>`
${e}
`).join(""))}let w=` class RecorderProcessor extends AudioWorkletProcessor { process(inputs) { const input = inputs[0]; if (input && input[0]) { this.port.postMessage(input[0]); } return true; } } registerProcessor('recorder-processor', RecorderProcessor); `;async function x(){return l||"suspended"===(l=new(window.AudioContext||window.webkitAudioContext)({sampleRate:n})).state&&await l.resume(),l}async function A(){if(!u&&e.video)try{return u=l.createMediaElementSource(e.video)}catch(e){console.warn("[artplayerPluginAsr] Direct connection failed:",e)}try{if(m||(m=await U(e.video)),m)return b=l.createMediaStreamSource(m)}catch(e){console.warn("[artplayerPluginAsr] MediaStream fallback failed:",e)}return null}async function U(e){try{if(e.captureStream)return e.captureStream();if(e.mozCaptureStream)return e.mozCaptureStream();return console.warn("[artplayerPluginAsr] captureStream not supported"),null}catch(e){return console.warn("[artplayerPluginAsr] Error capturing stream:",e),null}}async function P(){if(!i)try{await x();let e=await A();if(!e)throw Error("Could not establish audio source");if(!f){let e=(()=>{let e=new Blob([w],{type:"application/javascript"});return URL.createObjectURL(e)})();await l.audioWorklet.addModule(e),URL.revokeObjectURL(e),f=!0}(c=l.createGain()).gain.value=1,(s=new AudioWorkletNode(l,"recorder-processor")).port.onmessage=e=>{d.push(new Float32Array(e.data))},e.connect(s),e.connect(c),c.connect(l.destination);let t=r/1e3*n;p=setInterval(async()=>{if(0===d.length)return;let e=new Float32Array(0);for(;e.length{for(let r=0;re.stop()),m=null),l&&(await l.close(),l=null),f=!1}return e.on("video:volumechange",()=>{c&&(c.gain.value=e.volume)}),e.on("play",P),e.on("pause",j),e.on("destroy",M),{name:"artplayerPluginAsr",stop:M,hide:v,append:h}}}if("undefined"!=typeof document&&!document.getElementById("artplayer-plugin-asr")){let e=document.createElement("style");e.id="artplayer-plugin-asr",e.textContent=i.default,document.head.appendChild(e)}"undefined"!=typeof window&&(window.artplayerPluginAsr=l)},{"bundle-text:./style.less":"dKHY3","@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],dKHY3:[function(e,t,r,n){t.exports=".art-video-player .art-layer-asr{z-index:150;justify-content:end;gap:var(--art-subtitle-gap);padding:0 2%;padding-bottom:var(--art-subtitle-bottom);transition:padding-bottom var(--art-transition-duration)ease;text-shadow:var(--art-subtitle-border)1px 0 1px,var(--art-subtitle-border)0 1px 1px,var(--art-subtitle-border)-1px 0 1px,var(--art-subtitle-border)0 -1px 1px,var(--art-subtitle-border)1px 1px 1px,var(--art-subtitle-border)-1px -1px 1px,var(--art-subtitle-border)1px -1px 1px,var(--art-subtitle-border)-1px 1px 1px;flex-direction:column;font-size:1rem;display:flex;position:absolute;inset:0;pointer-events:none!important}.art-video-player.art-control-show .art-layer-asr{padding-bottom:calc(var(--art-control-height) + var(--art-subtitle-bottom))}"},{}],"5lQoW":[function(e,t,r,n){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["40eeC"],"40eeC","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("40eeC");export{e as default}; -//# sourceMappingURL=artplayer-plugin-asr.esm.js.map \ No newline at end of file +//# sourceMappingURL=artplayer-plugin-asr.mjs.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-asr.esm.js.map b/docs/compiled/artplayer-plugin-asr.mjs.map similarity index 100% rename from docs/compiled/artplayer-plugin-asr.esm.js.map rename to docs/compiled/artplayer-plugin-asr.mjs.map diff --git a/docs/compiled/artplayer-plugin-auto-thumbnail.esm.js b/docs/compiled/artplayer-plugin-auto-thumbnail.mjs similarity index 98% rename from docs/compiled/artplayer-plugin-auto-thumbnail.esm.js rename to docs/compiled/artplayer-plugin-auto-thumbnail.mjs index 90f1ec6c1..09336870d 100644 --- a/docs/compiled/artplayer-plugin-auto-thumbnail.esm.js +++ b/docs/compiled/artplayer-plugin-auto-thumbnail.mjs @@ -6,4 +6,4 @@ * Released under the MIT License. */ !function(e,t,n,o,r,u,i,l){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},f="function"==typeof d[o]&&d[o],a=f.i||{},c=f.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!c[t]){if(!e[t]){if(r[t])return r[t];var u="function"==typeof d[o]&&d[o];if(!n&&u)return u(t,!0);if(f)return f(t,!0);if(s&&"string"==typeof t)return s(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}a.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},a.cache={};var l=c[t]=new p.Module(t);e[t][0].call(l.exports,a,l,l.exports,d)}return c[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=c,p.parent=f,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=a,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return d[o]}}),d[o]=p;for(var m=0;m(t.on("video:loadedmetadata",()=>{let n=e.url||t.option.url,o=e.width||160,r=e.number||100,u=e.scale||1;!function({url:e,width:t,number:n},o){let r=document.createElement("video");r.crossOrigin="anonymous",r.src=e,r.onloadedmetadata=()=>{let e=r.duration,u=document.createElement("canvas"),i=u.getContext("2d"),l=Math.floor(t*r.videoHeight/r.videoWidth);u.width=10*t,u.height=l*Math.ceil(n/10);let d=null;!function f(a){u.toBlob(e=>{URL.revokeObjectURL(d),o({url:d=URL.createObjectURL(e),height:l})},"image/jpeg"),a>=n||(r.currentTime=e*a/n,r.onseeked=()=>{i.drawImage(r,a%10*t,Math.floor(a/10)*l,t,l),f(a+1)})}(0)}}({url:n,width:o,number:r},e=>{t.thumbnails={...e,column:10,number:r,width:o,scale:u}})}),{name:"artplayerPluginAutoThumbnail"})}r.defineInteropFlag(n),r.export(n,"default",()=>u),"undefined"!=typeof window&&(window.artplayerPluginAutoThumbnail=u)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,n,o){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["guSFC"],"guSFC","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("guSFC");export{e as default}; -//# sourceMappingURL=artplayer-plugin-auto-thumbnail.esm.js.map \ No newline at end of file +//# sourceMappingURL=artplayer-plugin-auto-thumbnail.mjs.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-auto-thumbnail.esm.js.map b/docs/compiled/artplayer-plugin-auto-thumbnail.mjs.map similarity index 100% rename from docs/compiled/artplayer-plugin-auto-thumbnail.esm.js.map rename to docs/compiled/artplayer-plugin-auto-thumbnail.mjs.map diff --git a/docs/compiled/artplayer-plugin-chapter.esm.js b/docs/compiled/artplayer-plugin-chapter.mjs similarity index 99% rename from docs/compiled/artplayer-plugin-chapter.esm.js rename to docs/compiled/artplayer-plugin-chapter.mjs index 09bc82bb0..e3a4200e3 100644 --- a/docs/compiled/artplayer-plugin-chapter.esm.js +++ b/docs/compiled/artplayer-plugin-chapter.mjs @@ -6,4 +6,4 @@ * Released under the MIT License. */ !function(e,t,r,a,n,o,i,l){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},p="function"==typeof d[a]&&d[a],s=p.i||{},u=p.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!u[t]){if(!e[t]){if(n[t])return n[t];var o="function"==typeof d[a]&&d[a];if(!r&&o)return o(t,!0);if(p)return p(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}s.resolve=function(r){var a=e[t][1][r];return null!=a?a:r},s.cache={};var l=u[t]=new f.Module(t);e[t][0].call(l.exports,s,l,l.exports,d)}return u[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=c,this.exports={}},f.modules=e,f.cache=u,f.parent=p,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=s,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return d[a]}}),d[a]=f;for(var h=0;hl);var o=e("bundle-text:./style.less"),i=n.interopDefault(o);function l(e={}){return t=>{let{$player:r}=t.template,{setStyle:a,append:n,clamp:o,query:i,isMobile:l,addClass:d,removeClass:p}=t.constructor.utils,s=`
`,u=null,c=[],f=t.query(".art-control-progress"),h=t.query(".art-control-progress-inner"),g=n(h,'
'),y=n(h,'
');function m({$chapter:e,width:t}){let r=e.dataset.title.trim();if(r){a(y,"display","flex"),y.textContent=r;let e=y.clientWidth;t<=e/2?a(y,"left",0):t>h.clientWidth-e/2?a(y,"left",`${h.clientWidth-e}px`):a(y,"left",`${t-e/2}px`)}else a(y,"display","none")}function v(e=[]){if((c=[],g.textContent="",p(r,"artplayer-plugin-chapter"),Array.isArray(e)&&e.length)&&t.duration){e=e.sort((e,t)=>e.start-t.start);for(let r=0;rt.duration||a.start>=a.end||n&&a.end>n.start)throw Error("Illegal chapter time point")}e[0].start>0&&e.unshift({start:0,end:e[0].start,title:""}),e[e.length-1].end{let r=n(g,s),a=o(e.start,0,t.duration),l=o(e.end,0,t.duration),d=l-a,p=d/t.duration;return r.dataset.start=a,r.dataset.end=l,r.dataset.duration=d,r.dataset.title=e.title.trim(),r.style.width=`${100*p}%`,{$chapter:r,$hover:i(".art-progress-hover",r),$loaded:i(".art-progress-loaded",r),$played:i(".art-progress-played",r)}}),d(r,"artplayer-plugin-chapter"),t.emit("setBar","loaded",t.loaded||0)}}return t.on("setBar",(e,r,n)=>{if(c.length)for(let o=0;ow&&a(f,"width","100%"),v>=x&&v<=w){let t=(v-x)/b;a(f,"width",`${100*t}%`),l?"played"===e&&n&&(m({$chapter:i,width:h}),clearTimeout(u),u=setTimeout(()=>{a(y,"display","none")},500)):"hover"===e&&m({$chapter:i,width:h})}}}),l||t.proxy(f,"mouseleave",()=>{c.length&&a(y,"display","none")}),t.once("video:loadedmetadata",()=>v(e.chapters)),{name:"artplayerPluginChapter",update:({chapters:e})=>v(e)}}}if("undefined"!=typeof document){let e="artplayer-plugin-chapter",t=document.getElementById(e);t||((t=document.createElement("style")).id=e,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(t)}):(document.head||document.documentElement).appendChild(t)),t.textContent=i.default}"undefined"!=typeof window&&(window.artplayerPluginChapter=l)},{"bundle-text:./style.less":"e5E4m","@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],e5E4m:[function(e,t,r,a){t.exports=".artplayer-plugin-chapter .art-control-progress-inner{background-color:#0000!important;height:100%!important}.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-hover,.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-loaded,.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-played{display:none!important}.artplayer-plugin-chapter .art-control-thumbnails{bottom:calc(var(--art-bottom-gap) + 64px)!important}.artplayer-plugin-chapter .art-chapters{z-index:0;align-items:center;gap:4px;height:100%;display:flex;position:absolute;inset:0;transform:scaleY(1.25)}.artplayer-plugin-chapter .art-chapters .art-chapter{align-items:center;height:100%;display:flex}.artplayer-plugin-chapter .art-chapters .art-chapter .art-chapter-inner{cursor:pointer;width:100%;height:50%;transition:height var(--art-transition-duration)ease;background-color:var(--art-progress-color);border-radius:10px;position:relative;overflow:hidden}.artplayer-plugin-chapter .art-chapters .art-chapter:hover .art-chapter-inner{height:100%}.artplayer-plugin-chapter .art-chapter-title{z-index:70;border-radius:var(--art-border-radius);white-space:nowrap;background-color:var(--art-tip-background);padding:3px 5px;font-size:14px;line-height:1;display:none;position:absolute;top:-50px;left:0}"},{}],"5lQoW":[function(e,t,r,a){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["1LLzi"],"1LLzi","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("1LLzi");export{e as default}; -//# sourceMappingURL=artplayer-plugin-chapter.esm.js.map \ No newline at end of file +//# sourceMappingURL=artplayer-plugin-chapter.mjs.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-chapter.esm.js.map b/docs/compiled/artplayer-plugin-chapter.mjs.map similarity index 100% rename from docs/compiled/artplayer-plugin-chapter.esm.js.map rename to docs/compiled/artplayer-plugin-chapter.mjs.map diff --git a/docs/compiled/artplayer-plugin-chromecast.esm.js b/docs/compiled/artplayer-plugin-chromecast.mjs similarity index 98% rename from docs/compiled/artplayer-plugin-chromecast.esm.js rename to docs/compiled/artplayer-plugin-chromecast.mjs index b89309a2e..a2993d56d 100644 --- a/docs/compiled/artplayer-plugin-chromecast.esm.js +++ b/docs/compiled/artplayer-plugin-chromecast.mjs @@ -6,4 +6,4 @@ * Released under the MIT License. */ !function(e,t,o,n,r,i,a,c){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof s[n]&&s[n],l=d.i||{},u=d.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,o){if(!u[t]){if(!e[t]){if(r[t])return r[t];var i="function"==typeof s[n]&&s[n];if(!o&&i)return i(t,!0);if(d)return d(t,!0);if(f&&"string"==typeof t)return f(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(o){var n=e[t][1][o];return null!=n?n:o},l.cache={};var c=u[t]=new p.Module(t);e[t][0].call(c.exports,l,c,c.exports,s)}return u[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=f,this.exports={}},p.modules=e,p.cache=u,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,o){e[t]=[function(e,t){t.exports=o},{}]},Object.defineProperty(p,"root",{get:function(){return s[n]}}),s[n]=p;for(var w=0;w{let t=document.querySelector(".art-icon-cast");if(t)switch(e){case"connected":t.style.color="red";break;case"connecting":case"disconnecting":t.style.color="orange";break;default:t.style.color="white"}},i=(t,o)=>{let n=e.url||t.option.url,r=new window.chrome.cast.media.MediaInfo(n,e.mimeType||({mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mp3:"audio/mp3",wav:"audio/wav",flv:"video/x-flv",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",mpd:"application/dash+xml",m3u8:"application/x-mpegURL"})[n.split("?")[0].split("#")[0].split(".").pop().toLowerCase()]||"application/octet-stream"),i=new window.chrome.cast.media.LoadRequest(r);o.loadMedia(i).then(()=>{t.notice.show="Casting started",e.onCastStart?.()}).catch(o=>{throw t.notice.show="Error casting media",e.onError?.(o),o})};return async a=>(a.controls.add({name:"chromecast",position:"right",tooltip:"Chromecast",html:`${e.icon||''}`,click:async()=>{if(!t)try{await new Promise((i,a)=>{var c;window.__onGCastApiAvailable=c=>{if(c){let a=window.cast.framework.CastContext.getInstance();a.setOptions({receiverApplicationId:window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,t=>{let i=window.cast.framework.SessionState;switch(n=t.sessionState,o=t.session,t.sessionState){case i.NO_SESSION:e.onStateChange?.("disconnected"),r("disconnected");break;case i.SESSION_STARTING:e.onStateChange?.("connecting"),r("connecting");break;case i.SESSION_STARTED:e.onStateChange?.("connected"),r("connected");break;case i.SESSION_ENDING:e.onStateChange?.("disconnecting"),r("disconnecting");break;case i.SESSION_RESUMED:e.onStateChange?.("connected"),r("connected")}}),a.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED,t=>{let o=window.cast.framework.CastState;switch(t.castState){case o.NO_DEVICES_AVAILABLE:e.onCastAvailable?.(!1);break;case o.NOT_CONNECTED:case o.CONNECTING:case o.CONNECTED:e.onCastAvailable?.(!0)}}),t=!0,i()}else a(Error("Cast API is not available"))},window.chrome&&window.chrome.cast||(c=e.sdk||"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",new Promise((e,t)=>{let o=document.createElement("script");o.src=c,o.onload=e,o.onerror=t,document.body.appendChild(o)})).catch(a)})}catch(t){throw a.notice.show="Failed to initialize Cast API",e.onError?.(t),t}let c=window.cast.framework.CastContext.getInstance();if(o)i(a,o);else try{let e=await c.requestSession();i(a,e)}catch(t){throw a.notice.show="Error connecting to cast session",e.onError?.(t),t}}}),{name:"artplayerPluginChromecast",getCastState:()=>n,isCasting:()=>null!==o})}r.defineInteropFlag(o),r.export(o,"default",()=>i),"undefined"!=typeof window&&(window.artplayerPluginChromecast=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,o,n){o.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},o.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},o.exportAll=function(e,t){return Object.keys(e).forEach(function(o){"default"===o||"__esModule"===o||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[o]}})}),t},o.export=function(e,t,o){Object.defineProperty(e,t,{enumerable:!0,get:o})}},{}]},["cv67D"],"cv67D","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("cv67D");export{e as default}; -//# sourceMappingURL=artplayer-plugin-chromecast.esm.js.map \ No newline at end of file +//# sourceMappingURL=artplayer-plugin-chromecast.mjs.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-chromecast.esm.js.map b/docs/compiled/artplayer-plugin-chromecast.mjs.map similarity index 100% rename from docs/compiled/artplayer-plugin-chromecast.esm.js.map rename to docs/compiled/artplayer-plugin-chromecast.mjs.map diff --git a/docs/compiled/artplayer-plugin-danmuku-mask.esm.js b/docs/compiled/artplayer-plugin-danmuku-mask.mjs similarity index 99% rename from docs/compiled/artplayer-plugin-danmuku-mask.esm.js rename to docs/compiled/artplayer-plugin-danmuku-mask.mjs index 45bfbd849..34f03dd79 100644 --- a/docs/compiled/artplayer-plugin-danmuku-mask.esm.js +++ b/docs/compiled/artplayer-plugin-danmuku-mask.mjs @@ -6,4 +6,4 @@ * Released under the MIT License. */ !function(e,t,r,n,s,a,o,l){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof i[n]&&i[n],p=u.i||{},c=u.cache||{},d="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!c[t]){if(!e[t]){if(s[t])return s[t];var a="function"==typeof i[n]&&i[n];if(!r&&a)return a(t,!0);if(u)return u(t,!0);if(d&&"string"==typeof t)return d(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}p.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},p.cache={};var l=c[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,i)}return c[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=d,this.exports={}},f.modules=e,f.cache=c,f.parent=u,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=p,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return i[n]}}),i[n]=f;for(var m=0;ml);var a=e("@tensorflow-models/body-segmentation"),o=e("@tensorflow/tfjs-core");function l(e={}){return t=>{let{template:{$video:r,$danmuku:n}}=t,s=null,l=null,i=null,u=null,p=!1,c={solutionPath:e.solutionPath||"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation",modelSelection:e.modelSelection||1,smoothSegmentation:void 0===e.smoothSegmentation||e.smoothSegmentation,minDetectionConfidence:e.minDetectionConfidence||.5,minTrackingConfidence:e.minTrackingConfidence||.5,selfieMode:e.selfieMode||!1,drawContour:e.drawContour||!1,foregroundThreshold:e.foregroundThreshold||.5,opacity:e.opacity||1,maskBlurAmount:e.maskBlurAmount||3};async function d(){try{await o.setBackend("webgl")}catch(e){console.warn("WebGL backend not available, falling back to CPU",e.message),await o.setBackend("cpu")}}async function f(){await d();let e=a.SupportedModels.MediaPipeSelfieSegmentation,t={runtime:"mediapipe",modelType:"general",solutionPath:c.solutionPath,modelSelection:c.modelSelection,smoothSegmentation:c.smoothSegmentation,minDetectionConfidence:c.minDetectionConfidence,minTrackingConfidence:c.minTrackingConfidence,selfieMode:c.selfieMode};try{s=await a.createSegmenter(e,t),p=!0}catch(e){console.error("Error initializing segmenter:",e),p=!1}}async function m(){if(!p||r.paused||r.ended){u=requestAnimationFrame(m);return}try{l.width=r.videoWidth,l.height=r.videoHeight;let e=await s.segmentPeople(r);if(!e||0===e.length){u=requestAnimationFrame(m);return}let t=await a.toBinaryMask(e,{r:255,g:255,b:255,a:255},{r:0,g:0,b:0,a:255},c.drawContour,c.foregroundThreshold);await a.drawMask(l,r,t,c.opacity,c.maskBlurAmount);let o=i.getImageData(0,0,l.width,l.height);i.putImageData(function(e){let t=e.data;for(let e=0;e250&&t[e+1]>250&&t[e+2]>250&&(t[e+3]=0);return e}(o),0,0),n.style.maskImage=`url(${l.toDataURL()})`}catch(e){console.error("Error in segmentBody:",e)}u=requestAnimationFrame(m)}async function h(){p||await f(),l||(i=(l=document.createElement("canvas")).getContext("2d")),Object.assign(n.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),m()}function g(){n.style.maskImage="none",u&&(cancelAnimationFrame(u),u=null)}return t.on("ready",h),t.on("destroy",g),{name:"artplayerPluginDanmukuMask",start:h,stop:g}}}e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu"),"undefined"!=typeof window&&(window.artplayerPluginDanmukuMask=l)},{"@tensorflow-models/body-segmentation":"lcmzA","@tensorflow/tfjs-core":"biUij","@tensorflow/tfjs-backend-webgl":"c8bRp","@tensorflow/tfjs-backend-cpu":"hOvdB","@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],lcmzA:[function(e,t,r,n){var s,a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(r),a.export(r,"SupportedModels",()=>eR),a.export(r,"blurBodyPart",()=>eZ),a.export(r,"bodyPixMaskValueToRainbowColor",()=>b),a.export(r,"createSegmenter",()=>eD),a.export(r,"drawBokehEffect",()=>eJ),a.export(r,"drawMask",()=>eX),a.export(r,"drawPixelatedMask",()=>eY),a.export(r,"toBinaryMask",()=>eH),a.export(r,"toColoredMask",()=>eK);var o=e("@tensorflow/tfjs-core"),l=e("@tensorflow/tfjs-converter"),i=e("@mediapipe/selfie_segmentation"),u=function(e,t){return(u=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function p(e,t){function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var c=function(){return(c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&s[s.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]=256)throw Error("Mask value must be in range [0, 255] but got "+e);if(!Number.isInteger(e))throw Error("Mask value must be an integer but got "+e)}var y=[[110,64,170],[143,61,178],[178,60,178],[210,62,167],[238,67,149],[255,78,125],[255,94,99],[255,115,75],[255,140,56],[239,167,47],[217,194,49],[194,219,64],[175,240,91],[135,245,87],[96,247,96],[64,243,115],[40,234,141],[28,219,169],[26,199,194],[33,176,213],[47,150,224],[65,125,224],[84,101,214],[99,81,195]];function b(e){if(v(e),er&&(s+=1,n+=Math.pow(e[a].x-t.keypoints[a].position.x,2)+Math.pow(e[a].y-t.keypoints[a].position.y,2));return 0===s?n=1/0:n/=s,n}(g,r[k]);j<_&&(b=k,_=j)}return b}function R(e,t){var r=e[0];return[Math.round((e[1]-1)/t+1),Math.round((r-1)/t+1)]}function P(e,t,r,n,s,a,l,i,u,p,c){for(var d=l[0],f=l[1],m=e.shape,h=m[0],g=m[1],x=t.shape.slice(0,2),v=x[0],y=x[1],b=(0,o.reshape)(t,[v,y,2,T]),_=new Float32Array(c*T*3).fill(0),k=0;k"+p+") {\n numKpt = numKpt + 1;\n curDistSum = curDistSum + dist(x, y, poseX, poseY);\n }\n }\n if (numKpt > 0 && curDistSum / float(numKpt)< minDist) {\n minDist = curDistSum / float(numKpt);\n iMin = i;\n }\n }\n return iMin;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int nearestPose = findNearestPose(coords[0], coords[1]);\n setOutput(float(nearestPose));\n }\n "};return(0,o.backend)().compileAndRun($,[e,b,R])}function D(){return"webgl"===(0,o.getBackend)()}function $(e){return Math.floor(e/2)}[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]].map(function(e){var t=e[0],r=e[1];return[C[t],C[r]]});var O=function(){function e(e,t){this.priorityQueue=Array(e),this.numberOfElements=-1,this.getElementValue=t}return e.prototype.enqueue=function(e){this.priorityQueue[++this.numberOfElements]=e,this.swim(this.numberOfElements)},e.prototype.dequeue=function(){var e=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,e},e.prototype.empty=function(){return -1===this.numberOfElements},e.prototype.size=function(){return this.numberOfElements+1},e.prototype.all=function(){return this.priorityQueue.slice(0,this.numberOfElements+1)},e.prototype.max=function(){return this.priorityQueue[0]},e.prototype.swim=function(e){for(;e>0&&this.less($(e),e);)this.exchange(e,$(e)),e=$(e)},e.prototype.sink=function(e){for(;2*e<=this.numberOfElements;){var t=2*e;if(ta?a:s),x:(o=Math.round(e.x/t),l=n-1,o<0?0:o>l?l:o)}}function V(e,t,r,n,s,a,o,l){void 0===l&&(l=2);for(var i,u,p=n.shape,c=p[0],d=p[1],f=(i=L(t.position,a,c,d),u=o.shape[2]/2,{y:o.get(i.y,i.x,e),x:o.get(i.y,i.x,u+e)}),m=F(t.position,f),h=0;ht){u=!1;break}if(!u)break}return u}(p,c,i,u,1,r)&&l.enqueue({score:c,part:{heatmapY:i,heatmapX:u,id:p}})}return l}(o,0,e),p=l*l;i.length=0;--d){var f=W[d],m=B[d];i[f]&&!i[m]&&(i[m]=V(d,i[f],m,t,r,n,a))}for(d=0;d=.1,function(){return"inputResolution must be a string or number between 0.1 and 2, but was "+e}),e}(e);return[Y(n*a,t),Y(s*a,t)]}function et(e,t,r,n,s){var a=t[0],l=t[1],i=r[0],u=r[1],p=n[0],c=p[0],d=p[1],f=n[1],m=f[0],h=f[1];return void 0===s&&(s=!1),(0,o.tidy)(function(){var t,r,n,p,f,g,x,v,y,b,_,k=o.image.resizeBilinear(e,[i,u],!0);return s&&(k=(0,o.sigmoid)(k)),t=k,r=[a,l],n=[[c,d],[m,h]],p=r[0],f=r[1],x=(g=n[0])[0],v=g[1],b=(y=n[1])[0],_=y[1],(0,o.tidy)(function(){var e=(0,o.expandDims)(t);return(0,o.squeeze)(o.image.cropAndResize(e,[[x/(p+x+v-1),b/(f+b+_-1),(x+p-1)/(p+x+v-1),(b+f-1)/(f+b+_-1)]],[0],[p,f]),[0])})})}function er(e,t){var r=t[0],n=t[1],s=X(e),a=s[0],l=s[1],i=n/r,u=0,p=0,c=0,d=0;return l/a1)throw Error("segmentationThreshold "+t+". Should be in range [0.0, 1.0]");if(r<=0)throw Error("Invalid maxDetections "+r+". Should be >0");if(n<0||n>1)throw Error("Invalid scoreThreshold "+n+". Should be in range [0.0, 1.0]");if(s<=0)throw Error("Invalid nmsRadius "+s+".")}function ef(e){var t=e.segmentationThreshold,r=e.maxDetections,n=e.scoreThreshold,s=e.nmsRadius,a=e.minKeypointScore,o=e.refineSteps;if(t<0||t>1)throw Error("segmentationThreshold "+t+". Should be in range [0.0, 1.0]");if(r<=0)throw Error("Invalid maxDetections "+r+". Should be >0");if(n<0||n>1)throw Error("Invalid scoreThreshold "+n+". Should be in range [0.0, 1.0]");if(s<=0)throw Error("Invalid nmsRadius "+s+".");if(a<0||a>1)throw Error("Invalid minKeypointScore "+a+".Should be in range [0.0, 1.0]");if(o<=0||o>20)throw Error("Invalid refineSteps "+o+".Should be in range [1, 20]")}var em=function(){function e(e){this.baseModel=e}return e.prototype.predictForPersonSegmentation=function(e){var t=this.baseModel.predict(e);return{segmentLogits:t.segmentation,heatmapScores:t.heatmapScores,offsets:t.offsets,displacementFwd:t.displacementFwd,displacementBwd:t.displacementBwd}},e.prototype.predictForPersonSegmentationAndPart=function(e){var t=this.baseModel.predict(e);return{segmentLogits:t.segmentation,partHeatmapLogits:t.partHeatmaps,heatmapScores:t.heatmapScores,offsets:t.offsets,displacementFwd:t.displacementFwd,displacementBwd:t.displacementBwd}},e.prototype.predictForMultiPersonInstanceSegmentationAndPart=function(e){var t=this.baseModel.predict(e);return{segmentLogits:t.segmentation,longOffsets:t.longOffsets,heatmapScores:t.heatmapScores,offsets:t.offsets,displacementFwd:t.displacementFwd,displacementBwd:t.displacementBwd,partHeatmaps:t.partHeatmaps}},e.prototype.segmentPersonActivation=function(e,t,r){var n=this;void 0===r&&(r=.5);var s=X(e),a=s[0],l=s[1],i=ee(t,this.baseModel.outputStride,[a,l]),u=er(e,i),p=u.resized,c=u.padding,d=(0,o.tidy)(function(){var e=n.predictForPersonSegmentation(p),t=e.segmentLogits,s=e.heatmapScores,i=e.offsets,u=e.displacementFwd,d=e.displacementBwd,f=p.shape,m=et(t,[a,l],[f[0],f[1]],[[c.top,c.bottom],[c.left,c.right]],!0);return{segmentation:k((0,o.squeeze)(m),r),heatmapScores:s,offsets:i,displacementFwd:u,displacementBwd:d}}),f=d.segmentation,m=d.heatmapScores,h=d.offsets,g=d.displacementFwd,x=d.displacementBwd;return p.dispose(),{segmentation:f,heatmapScores:m,offsets:h,displacementFwd:g,displacementBwd:x,padding:c,internalResolutionHeightAndWidth:i}},e.prototype.segmentPerson=function(e,t){return void 0===t&&(t=ep),d(this,void 0,void 0,function(){var r,n,s,a,o,l,i,u,p,d,m,h,g,x,v,y;return f(this,function(f){switch(f.label){case 0:return ed(t=c(c({},ep),t)),n=(r=this.segmentPersonActivation(e,t.internalResolution,t.segmentationThreshold)).segmentation,s=r.heatmapScores,a=r.offsets,o=r.displacementFwd,l=r.displacementBwd,i=r.padding,u=r.internalResolutionHeightAndWidth,d=(p=n.shape)[0],m=p[1],[4,n.data()];case 1:return h=f.sent(),n.dispose(),[4,en([s,a,o,l])];case 2:return x=(g=f.sent())[0],v=g[1],y=es(y=G(x,v,g[2],g[3],this.baseModel.outputStride,t.maxDetections,t.scoreThreshold,t.nmsRadius),[d,m],u,i,!1),s.dispose(),a.dispose(),o.dispose(),l.dispose(),[2,{height:d,width:m,data:h,allPoses:y}]}})})},e.prototype.segmentMultiPerson=function(e,t){return void 0===t&&(t=ec),d(this,void 0,void 0,function(){var r,n,s,a,l,i,u,p,m,h,g,x,v,y,b,_,j,w,I,T=this;return f(this,function(C){switch(C.label){case 0:return ef(t=c(c({},ec),t)),n=(r=X(e))[0],s=r[1],i=(l=er(e,a=ee(t.internalResolution,this.baseModel.outputStride,[n,s]))).resized,u=l.padding,m=(p=(0,o.tidy)(function(){var e=T.predictForMultiPersonInstanceSegmentationAndPart(i),r=e.segmentLogits,l=e.longOffsets,p=e.heatmapScores,c=e.offsets,d=e.displacementFwd,f=e.displacementBwd,m=et(r,[n,s],a,[[u.top,u.bottom],[u.left,u.right]],!0);return{segmentation:k((0,o.squeeze)(m),t.segmentationThreshold),longOffsets:l,heatmapScoresRaw:p,offsetsRaw:c,displacementFwdRaw:d,displacementBwdRaw:f}})).segmentation,h=p.longOffsets,g=p.heatmapScoresRaw,x=p.offsetsRaw,v=p.displacementFwdRaw,y=p.displacementBwdRaw,[4,en([g,x,v,y])];case 1:return _=(b=C.sent())[0],j=b[1],w=es(w=G(_,j,b[2],b[3],this.baseModel.outputStride,t.maxDetections,t.scoreThreshold,t.nmsRadius),[n,s],a,u,!1),[4,function(e,t,r,n,s,a,l,i,u,p,c,m){var h=l[0],g=l[1];return void 0===u&&(u=.2),void 0===p&&(p=8),void 0===c&&(c=.3),void 0===m&&(m=10),d(this,void 0,void 0,function(){var l,d,x,v,y;return f(this,function(f){switch(f.label){case 0:return l=r.filter(function(e){return e.score>=u}),D()?[4,Promise.all((x=(0,o.tidy)(function(){var r=P(e,t,l,n,s,a,[h,g],i,p,c,m),u=(0,o.engine)().makeTensorFromDataId(r.dataId,r.shape,r.dtype);return l.map(function(e,t){return(0,o.tidy)(function(){return(0,o.cast)((0,o.equal)(u,(0,o.scalar)(t)),"int32")})})})).map(function(e){return e.data()}))]:[3,2];case 1:return d=f.sent(),x.forEach(function(e){return e.dispose()}),[3,5];case 2:return[4,e.data()];case 3:return v=f.sent(),[4,t.data()];case 4:y=f.sent(),d=function(e,t,r,n,s,a,o,l,i,u){var p=o[0],c=o[1];void 0===u&&(u=5);for(var d=r.map(function(e){return new Uint8Array(n*s).fill(0)}),f=l.top,m=l.left,h=S([n,s],[p,c],l),g=h[0],x=h[1],v=R([p,c],a)[0],y=0;y=0&&(d[k][_]=1)}}return d}(v,y,l,n,s,a,[h,g],i,p),f.label=5;case 5:return[2,d.map(function(e,t){return{data:e,pose:l[t],width:s,height:n}})]}})})}(m,h,w,n,s,this.baseModel.outputStride,a,u,t.scoreThreshold,t.refineSteps,t.minKeypointScore,t.maxDetections)];case 2:return I=C.sent(),i.dispose(),m.dispose(),h.dispose(),g.dispose(),x.dispose(),v.dispose(),y.dispose(),[2,I]}})})},e.prototype.segmentPersonPartsActivation=function(e,t,r){var n=this;void 0===r&&(r=.5);var s=X(e),a=s[0],l=s[1],i=ee(t,this.baseModel.outputStride,[a,l]),u=er(e,i),p=u.resized,c=u.padding,d=(0,o.tidy)(function(){var e,t,s,i,u,d=n.predictForPersonSegmentationAndPart(p),f=d.segmentLogits,m=d.partHeatmapLogits,h=d.heatmapScores,g=d.offsets,x=d.displacementFwd,v=d.displacementBwd,y=p.shape,b=y[0],j=y[1],w=et(f,[a,l],[b,j],[[c.top,c.bottom],[c.left,c.right]],!0),I=et(m,[a,l],[b,j],[[c.top,c.bottom],[c.left,c.right]],!0);return{partSegmentation:(e=k((0,o.squeeze)(w),r),s=(t=I.shape)[0],i=t[1],u=t[2],(0,o.tidy)(function(){var t=_(I),r=(0,o.expandDims)((0,o.range)(0,u,1,"int32"),1),n=(0,o.cast)((0,o.matMul)(t,r),"int32"),a=(0,o.reshape)(n,[s,i]),l=(0,o.add)(a,(0,o.scalar)(1,"int32"));return(0,o.sub)((0,o.mul)(l,e),(0,o.scalar)(1,"int32"))})),heatmapScores:h,offsets:g,displacementFwd:x,displacementBwd:v}}),f=d.partSegmentation,m=d.heatmapScores,h=d.offsets,g=d.displacementFwd,x=d.displacementBwd;return p.dispose(),{partSegmentation:f,heatmapScores:m,offsets:h,displacementFwd:g,displacementBwd:x,padding:c,internalResolutionHeightAndWidth:i}},e.prototype.segmentPersonParts=function(e,t){return void 0===t&&(t=ep),d(this,void 0,void 0,function(){var r,n,s,a,o,l,i,u,p,d,m,h,g,x,v,y;return f(this,function(f){switch(f.label){case 0:return ed(t=c(c({},ep),t)),n=(r=this.segmentPersonPartsActivation(e,t.internalResolution,t.segmentationThreshold)).partSegmentation,s=r.heatmapScores,a=r.offsets,o=r.displacementFwd,l=r.displacementBwd,i=r.padding,u=r.internalResolutionHeightAndWidth,d=(p=n.shape)[0],m=p[1],[4,n.data()];case 1:return h=f.sent(),n.dispose(),[4,en([s,a,o,l])];case 2:return x=(g=f.sent())[0],v=g[1],y=es(y=G(x,v,g[2],g[3],this.baseModel.outputStride,t.maxDetections,t.scoreThreshold,t.nmsRadius),[d,m],u,i,!1),s.dispose(),a.dispose(),o.dispose(),l.dispose(),[2,{height:d,width:m,data:h,allPoses:y}]}})})},e.prototype.segmentMultiPersonParts=function(e,t){return void 0===t&&(t=ec),d(this,void 0,void 0,function(){var r,n,s,a,l,i,u,p,m,h,g,x,v,y,b,j,w,I,T,C,N=this;return f(this,function(E){switch(E.label){case 0:return ef(t=c(c({},ec),t)),n=(r=X(e))[0],s=r[1],i=(l=er(e,a=ee(t.internalResolution,this.baseModel.outputStride,[n,s]))).resized,u=l.padding,m=(p=(0,o.tidy)(function(){var e,r,l,p,c=N.predictForMultiPersonInstanceSegmentationAndPart(i),d=c.segmentLogits,f=c.longOffsets,m=c.heatmapScores,h=c.offsets,g=c.displacementFwd,x=c.displacementBwd,v=c.partHeatmaps,y=et(d,[n,s],a,[[u.top,u.bottom],[u.left,u.right]],!0),b=et(v,[n,s],a,[[u.top,u.bottom],[u.left,u.right]],!0);return{segmentation:k((0,o.squeeze)(y),t.segmentationThreshold),longOffsets:f,heatmapScoresRaw:m,offsetsRaw:h,displacementFwdRaw:g,displacementBwdRaw:x,partSegmentation:(r=(e=b.shape)[0],l=e[1],p=e[2],(0,o.tidy)(function(){var e=_(b),t=(0,o.expandDims)((0,o.range)(0,p,1,"int32"),1),n=(0,o.cast)((0,o.matMul)(e,t),"int32");return(0,o.reshape)(n,[r,l])}))}})).segmentation,h=p.longOffsets,g=p.heatmapScoresRaw,x=p.offsetsRaw,v=p.displacementFwdRaw,y=p.displacementBwdRaw,b=p.partSegmentation,[4,en([g,x,v,y])];case 1:return w=(j=E.sent())[0],I=j[1],T=es(T=G(w,I,j[2],j[3],this.baseModel.outputStride,t.maxDetections,t.scoreThreshold,t.nmsRadius),[n,s],a,u,!1),[4,function(e,t,r,n,s,a,l,i,u,p,c,m,h){var g=i[0],x=i[1];return void 0===p&&(p=.2),void 0===c&&(c=8),void 0===m&&(m=.3),void 0===h&&(h=10),d(this,void 0,void 0,function(){var i,d,v,y,b,_;return f(this,function(f){switch(f.label){case 0:return i=n.filter(function(e){return e.score>=p}),D()?[4,Promise.all((v=(0,o.tidy)(function(){var n=P(e,t,i,s,a,l,[g,x],u,c,m,h),p=(0,o.engine)().makeTensorFromDataId(n.dataId,n.shape,n.dtype);return i.map(function(e,t){return(0,o.tidy)(function(){return(0,o.sub)((0,o.mul)((0,o.cast)((0,o.equal)(p,(0,o.scalar)(t)),"int32"),(0,o.add)(r,1)),1)})})})).map(function(e){return e.data()}))]:[3,2];case 1:return d=f.sent(),v.forEach(function(e){return e.dispose()}),[3,6];case 2:return[4,e.data()];case 3:return y=f.sent(),[4,t.data()];case 4:return b=f.sent(),[4,r.data()];case 5:_=f.sent(),d=function(e,t,r,n,s,a,o,l,i,u,p){var c=l[0],d=l[1];void 0===p&&(p=5);for(var f=n.map(function(e){return new Int32Array(s*a).fill(-1)}),m=i.top,h=i.left,g=S([s,a],[c,d],i),x=g[0],v=g[1],y=R([c,d],o)[0],b=0;b=0&&(f[j][k]=r[k])}}return f}(y,b,_,i,s,a,l,[g,x],u,c),f.label=6;case 6:return[2,d.map(function(e,t){return{pose:i[t],data:e,height:s,width:a}})]}})})}(m,h,b,T,n,s,this.baseModel.outputStride,a,u,t.scoreThreshold,t.refineSteps,t.minKeypointScore,t.maxDetections)];case 2:return C=E.sent(),i.dispose(),m.dispose(),h.dispose(),g.dispose(),x.dispose(),v.dispose(),y.dispose(),b.dispose(),[2,C]}})})},e.prototype.dispose=function(){this.baseModel.dispose()},e}(),eh=["left_face","right_face","left_upper_arm_front","left_upper_arm_back","right_upper_arm_front","right_upper_arm_back","left_lower_arm_front","left_lower_arm_back","right_lower_arm_front","right_lower_arm_back","left_hand","right_hand","torso_front","torso_back","left_upper_leg_front","left_upper_leg_back","right_upper_leg_front","right_upper_leg_back","left_lower_leg_front","left_lower_leg_back","right_lower_leg_front","right_lower_leg_back","left_feet","right_feet"],eg=function(){function e(e){this.mask=e}return e.prototype.toCanvasImageSource=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,h(this.mask)]})})},e.prototype.toImageData=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.mask]})})},e.prototype.toTensor=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,x(this.mask)]})})},e.prototype.getUnderlyingType=function(){return"imagedata"},e}();function ex(e){if(v(e),255!==e)throw Error("Foreground id must be 255 but got "+e);return"person"}function ev(e){if(v(e),e>=eh.length)throw Error("Invalid body part value "+e);return eh[e]}var ey=function(){function e(e){this.bodyPixModel=e}return e.prototype.segmentPeople=function(e,t){return d(this,void 0,void 0,function(){var r,n,s,a;return f(this,function(o){switch(o.label){case 0:return e instanceof ImageBitmap&&((r=document.createElement("canvas")).getContext("2d").drawImage(e,0,0),e=r),t.segmentBodyParts?t.multiSegmentation?[4,this.bodyPixModel.segmentMultiPersonParts(e,t)]:[3,2]:[3,5];case 1:return s=o.sent(),[3,4];case 2:return[4,this.bodyPixModel.segmentPersonParts(e,t)];case 3:s=[o.sent()],o.label=4;case 4:return n=s.map(function(e){var t=e.data,r=e.width,n=e.height,s=new Uint8ClampedArray(r*n*4).fill(0);return t.forEach(function(e,t){-1===e?(s[4*t]=eh.length,s[4*t+3]=0):(s[4*t]=e,s[4*t+3]=255)}),{maskValueToLabel:ev,mask:new eg(new ImageData(s,r,n))}}),[3,10];case 5:return t.multiSegmentation?[4,this.bodyPixModel.segmentMultiPerson(e,t)]:[3,7];case 6:return a=o.sent(),[3,9];case 7:return[4,this.bodyPixModel.segmentPerson(e,t)];case 8:a=[o.sent()],o.label=9;case 9:n=a.map(function(e){var t=e.data,r=e.width,n=e.height,s=new Uint8ClampedArray(r*n*4).fill(0);return t.forEach(function(e,t){0===e?(s[4*t]=0,s[4*t+3]=0):(s[4*t]=255,s[4*t+3]=255)}),{maskValueToLabel:ex,mask:new eg(new ImageData(s,r,n))}}),o.label=10;case 10:return[2,n]}})})},e.prototype.dispose=function(){this.bodyPixModel.dispose()},e.prototype.reset=function(){},e}(),eb={runtime:"mediapipe",modelType:"general"},e_=function(){function e(e){this.mask=e}return e.prototype.toCanvasImageSource=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.mask]})})},e.prototype.toImageData=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,g(this.mask)]})})},e.prototype.toTensor=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,x(this.mask)]})})},e.prototype.getUnderlyingType=function(){return"canvasimagesource"},e}();function ek(e){return v(e),"person"}var ej=function(){function e(e){var t,r,n=this;this.selfieMode=!1,t=+(this.selfieSegmentationSolution=new(0,i.SelfieSegmentation)({locateFile:null!=(r=e.locateFile)?r:function(t,r){return e.solutionPath?e.solutionPath.replace(/\/+$/,"")+"/"+t:r+"/"+t}}),"landscape"===e.modelType),this.selfieSegmentationSolution.setOptions({modelSelection:t,selfieMode:this.selfieMode}),this.selfieSegmentationSolution.onResults(function(e){n.segmentation=[{maskValueToLabel:ek,mask:new e_(e.segmentationMask)}]})}return e.prototype.segmentPeople=function(e,t){return d(this,void 0,void 0,function(){var r,n;return f(this,function(s){switch(s.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.selfieSegmentationSolution.setOptions({selfieMode:this.selfieMode})),e instanceof o.Tensor?(n=ImageData.bind,[4,o.browser.toPixels(e)]):[3,2];case 1:return r=new(n.apply(ImageData,[void 0,s.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:r=e,s.label=3;case 3:return e=r,[4,this.selfieSegmentationSolution.send({image:e})];case 4:return s.sent(),[2,this.segmentation]}})})},e.prototype.dispose=function(){this.selfieSegmentationSolution.close()},e.prototype.reset=function(){this.selfieSegmentationSolution.reset(),this.segmentation=null,this.selfieMode=!1},e.prototype.initialize=function(){return this.selfieSegmentationSolution.initialize()},e}();function ew(e){return e instanceof o.Tensor?{height:e.shape[0],width:e.shape[1]}:{height:e.height,width:e.width}}function eI(e,t){o.util.assert(0!==e.width,function(){return t+" width cannot be 0."}),o.util.assert(0!==e.height,function(){return t+" height cannot be 0."})}var eT={runtime:"tfjs",modelType:"general",modelUrl:"https://tfhub.dev/mediapipe/tfjs-model/selfie_segmentation/general/1"},eC={flipHorizontal:!1},eS={outputTensorSize:{width:256,height:256},keepAspectRatio:!1,borderMode:"zero",outputTensorFloatRange:[0,1]},eN={outputTensorSize:{width:256,height:144},keepAspectRatio:!1,borderMode:"zero",outputTensorFloatRange:[0,1]},eE={activation:"none"},eF=function(){function e(e){this.mask=e}return e.prototype.toCanvasImageSource=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,h(this.mask)]})})},e.prototype.toImageData=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,g(this.mask)]})})},e.prototype.toTensor=function(){return d(this,void 0,void 0,function(){return f(this,function(e){return[2,this.mask]})})},e.prototype.getUnderlyingType=function(){return"tensor"},e}();function eA(e){return v(e),"person"}var eR,eP=function(){function e(e,t){this.modelType=e,this.model=t}return e.prototype.segmentPeople=function(e,t){return d(this,void 0,void 0,function(){var r=this;return f(this,function(n){return t=function(e){if(null==e)return c({},eC);var t=c({},e);return null==t.flipHorizontal&&(t.flipHorizontal=eC.flipHorizontal),t}(t),null==e?(this.reset(),[2,[]]):[2,[{maskValueToLabel:eA,mask:new eF((0,o.tidy)(function(){var t,n,s,a,l,i,u,p,c,d,f,m,h,g,x,v,y,b,_,k,j,w,I=(x=(t="general"===r.modelType?eS:eN).outputTensorSize,v=t.keepAspectRatio,y=t.borderMode,b=t.outputTensorFloatRange,j=function(e,t,r){if(void 0===r&&(r=!1),!r)return{top:0,left:0,right:0,bottom:0};var n=t.height,s=t.width;eI(t,"targetSize"),eI(e,"roi");var a,o,l=n/s,i=e.height/e.width,u=0,p=0;return l>i?(a=e.width,o=e.width*l,p=(1-i/l)/2):(a=e.height/l,o=e.height,u=(1-l/i)/2),e.width=a,e.height=o,{top:p,left:u,right:u,bottom:p}}((n=_=ew(e),k={xCenter:.5*n.width,yCenter:.5*n.height,width:n.width,height:n.height,rotation:0}),x,v),s=_.width,a=_.height,l=k.width,i=k.height,u=1,p=Math.cos(k.rotation),c=Math.sin(k.rotation),d=k.xCenter,f=k.yCenter,m=1/s,h=1/a,(g=Array(16))[0]=l*p*u*m,g[1]=-i*c*m,g[2]=0,g[3]=(-.5*l*p*u+.5*i*c+d)*m,g[4]=l*c*u*h,g[5]=i*p*h,g[6]=0,g[7]=(-.5*i*p-.5*l*c*u+f)*h,g[8]=0,g[9]=0,g[10]=l*m,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,w=function(e){if(16!==e.length)throw Error("Array length must be 16 but got "+e.length);return[[e[0],e[1],e[2],e[3]],[e[4],e[5],e[6],e[7]],[e[8],e[9],e[10],e[11]],[e[12],e[13],e[14],e[15]]]}(g),{imageTensor:(0,o.tidy)(function(){var t,r=e instanceof o.Tensor?e:o.browser.fromPixels(e),n=(0,o.tensor2d)((eI(x,"inputResolution"),[1/x.width*w[0][0]*_.width,1/x.height*w[0][1]*_.width,w[0][3]*_.width,1/x.width*w[1][0]*_.height,1/x.height*w[1][1]*_.height,w[1][3]*_.height,0,0]),[1,8]),s=o.image.transform((0,o.expandDims)((0,o.cast)(r,"float32")),n,"bilinear","zero"===y?"constant":"nearest",0,[x.height,x.width]);return null!=b?(t=function(e,t,r,n){!1;var s=(n-r)/255;return{scale:s,offset:r-e*s}}(0,0,b[0],b[1]),(0,o.tidy)(function(){return(0,o.add)((0,o.mul)(s,t.scale),t.offset)})):s}),padding:j,transformationMatrix:w}).imageTensor,T=(0,o.slice)(r.model.predict(I),[0,0,0,1],-1),C=ew(e),S=(0,o.tidy)(function(){var e=(0,o.squeeze)(T,[0]),t=e.shape[2];if(1===t){var r=e;switch(eE.activation){case"none":break;case"sigmoid":r=(0,o.sigmoid)(r);break;case"softmax":throw Error("Softmax activation requires two channels.");default:throw Error("Activation not supported ("+eE.activation+")")}var n=C?o.image.resizeBilinear(r,[C.height,C.width]):r;return(0,o.squeeze)(n,[2])}throw Error("Unsupported number of tensor channels "+t)}),N=(0,o.expandDims)(S,2),E=(0,o.pad)(N,[[0,0],[0,0],[0,1]]);return(0,o.mirrorPad)(E,[[0,0],[0,0],[0,2]],"symmetric")}))}]]})})},e.prototype.dispose=function(){this.model.dispose()},e.prototype.reset=function(){},e}();function eD(e,t){return d(this,void 0,void 0,function(){var r,n;return f(this,function(s){switch(e){case eR.MediaPipeSelfieSegmentation:if(r=void 0,null!=(n=t)){if("tfjs"===n.runtime)return[2,function(e){return d(this,void 0,void 0,function(){var t,r,n;return f(this,function(s){switch(s.label){case 0:return r="string"==typeof(t=function(e){if(null==e)return c({},eT);var t=c({},e);if(t.runtime="tfjs",null==t.modelType&&(t.modelType=eT.modelType),"general"!==t.modelType&&"landscape"!==t.modelType)throw Error("Model type must be one of general or landscape, but got "+t.modelType);return null==t.modelUrl&&("general"===t.modelType?t.modelUrl="https://tfhub.dev/mediapipe/tfjs-model/selfie_segmentation/general/1":t.modelUrl="https://tfhub.dev/mediapipe/tfjs-model/selfie_segmentation/landscape/1"),t}(e)).modelUrl&&t.modelUrl.indexOf("https://tfhub.dev")>-1,[4,(0,l.loadGraphModel)(t.modelUrl,{fromTFHub:r})];case 1:return n=s.sent(),[2,new eP(t.modelType,n)]}})})}(n)];if("mediapipe"===n.runtime)return[2,function(e){return d(this,void 0,void 0,function(){var t;return f(this,function(r){switch(r.label){case 0:return[4,(t=new ej(function(e){if(null==e)return c({},eb);var t=c({},e);return t.runtime="mediapipe",null==t.modelType&&(t.modelType=eb.modelType),t}(e))).initialize()];case 1:return r.sent(),[2,t]}})})}(n)];r=n.runtime}throw Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got "+r);case eR.BodyPix:return[2,function(e){return d(this,void 0,void 0,function(){return f(this,function(t){return[2,(function(e){return void 0===e&&(e=ea),d(this,void 0,void 0,function(){return f(this,function(t){return"ResNet50"===(e=function(e){if(null==(e=e||ea).architecture&&(e.architecture="MobileNetV1"),0>eo.indexOf(e.architecture))throw Error("Invalid architecture "+e.architecture+". Should be one of "+eo);if(null==e.outputStride&&(e.outputStride=16),0>el[e.architecture].indexOf(e.outputStride))throw Error("Invalid outputStride "+e.outputStride+". Should be one of "+el[e.architecture]+" for architecture "+e.architecture+".");if(null==e.multiplier&&(e.multiplier=1),0>ei[e.architecture].indexOf(e.multiplier))throw Error("Invalid multiplier "+e.multiplier+". Should be one of "+ei[e.architecture]+" for architecture "+e.architecture+".");if(null==e.quantBytes&&(e.quantBytes=4),0>eu.indexOf(e.quantBytes))throw Error("Invalid quantBytes "+e.quantBytes+". Should be one of "+eu+" for architecture "+e.architecture+".");return e}(e)).architecture?[2,function(e){return d(this,void 0,void 0,function(){var t,r,n;return f(this,function(s){switch(s.label){case 0:var a;if(t=e.outputStride,r=e.quantBytes,null==o)throw Error("Cannot find TensorFlow.js. If you are using a + \ No newline at end of file diff --git a/docs/document/advanced/built-in.html b/docs/document/advanced/built-in.html index 01cf3ed88..07cf0935f 100644 --- a/docs/document/advanced/built-in.html +++ b/docs/document/advanced/built-in.html @@ -206,7 +206,7 @@ art.on('ready', () => { art.plugins.add(myPlugin); }); - + \ No newline at end of file diff --git a/docs/document/advanced/class.html b/docs/document/advanced/class.html index 06ce8bba9..31d549326 100644 --- a/docs/document/advanced/class.html +++ b/docs/document/advanced/class.html @@ -31,7 +31,7 @@ }); console.info([...Artplayer.instances]);

version ​

返回播放器的版本信息

▶ Run Code
js
console.info(Artplayer.version);

env ​

返回播放器的环境变量

▶ Run Code
js
console.info(Artplayer.env);

build ​

返回播放器的打包时间

▶ Run Code
js
console.info(Artplayer.build);

config ​

返回视频的默认配置

▶ Run Code
js
console.info(Artplayer.config);

utils ​

返回播放器的工具函数集合

▶ Run Code
js
console.info(Artplayer.utils);

全部工具函数请参考以下地址:

artplayer/types/utils.d.ts

scheme ​

返回播放器选项的校验方案

▶ Run Code
js
console.info(Artplayer.scheme);

Emitter ​

返回事件分发器的构造函数

▶ Run Code
js
console.info(Artplayer.Emitter);

validator ​

返回选项的校验函数

▶ Run Code
js
console.info(Artplayer.validator);

kindOf ​

返回类型检测的函数工具

▶ Run Code
js
console.info(Artplayer.kindOf);

html ​

返回播放器所需的 html 字符串

▶ Run Code
js
console.info(Artplayer.html);

option ​

返回播放器的默认选项

▶ Run Code
js
console.info(Artplayer.option);
- + \ No newline at end of file diff --git a/docs/document/advanced/event.html b/docs/document/advanced/event.html index f5295a178..4f596d49f 100644 --- a/docs/document/advanced/event.html +++ b/docs/document/advanced/event.html @@ -385,7 +385,7 @@ art.on('keydown', (event) => { console.log(event.code); });

video:canplay ​

浏览器可以播放媒体文件了,但估计没有足够的数据来支撑播放到结束,不必停下来进一步缓冲内容

video:canplaythrough ​

浏览器估计它可以在不停止内容缓冲的情况下播放媒体直到结束

video:complete ​

OfflineAudioContext 渲染完成

video:durationchange ​

duration 属性的值改变时触发

video:emptied ​

媒体内容变为空;例如,当这个 media 已经加载完成(或者部分加载完成),则发送此事件,并调用 load() 方法重新加载它

video:ended ​

视频停止播放,因为 media 已经到达结束点

video:error ​

获取媒体数据时出错,或者资源类型不是受支持的媒体格式

video:loadeddata ​

media 中的首帧已经完成加载

video:loadedmetadata ​

已加载元数据

video:pause ​

播放已暂停

video:play ​

播放已开始

video:playing ​

由于缺乏数据而暂停或延迟后,播放准备开始

video:progress ​

在浏览器加载资源时周期性触发

video:ratechange ​

播放速率发生变化

video:seeked ​

跳帧(seek)操作完成

video:seeking ​

跳帧(seek)操作开始

video:stalled ​

用户代理(user agent)正在尝试获取媒体数据,但数据意外未出现

video:suspend ​

媒体数据加载已暂停

video:timeupdate ​

currentTime 属性指定的时间发生变化

video:volumechange ​

音量发生变化

video:waiting ​

由于暂时缺少数据,播放已停止

- + \ No newline at end of file diff --git a/docs/document/advanced/global.html b/docs/document/advanced/global.html index 6d49fd063..d95e0f418 100644 --- a/docs/document/advanced/global.html +++ b/docs/document/advanced/global.html @@ -240,7 +240,7 @@ url: '/assets/sample/video.mp4', miniProgressBar: true, }); - + \ No newline at end of file diff --git a/docs/document/advanced/plugin.html b/docs/document/advanced/plugin.html index c73b282e2..0df2b2fc7 100644 --- a/docs/document/advanced/plugin.html +++ b/docs/document/advanced/plugin.html @@ -122,7 +122,7 @@ }) ], }); - + \ No newline at end of file diff --git a/docs/document/advanced/property.html b/docs/document/advanced/property.html index 23984244f..6333e76c5 100644 --- a/docs/document/advanced/property.html +++ b/docs/document/advanced/property.html @@ -427,7 +427,7 @@ art.on('ready', () => { art.subtitleOffset = 1; }); - + \ No newline at end of file diff --git a/docs/document/assets/en_index.md.CVTkjvLi.js b/docs/document/assets/en_index.md.BoUDo3iv.js similarity index 98% rename from docs/document/assets/en_index.md.CVTkjvLi.js rename to docs/document/assets/en_index.md.BoUDo3iv.js index 6311495f0..fa553290d 100644 --- a/docs/document/assets/en_index.md.CVTkjvLi.js +++ b/docs/document/assets/en_index.md.BoUDo3iv.js @@ -1,4 +1,4 @@ -import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g=JSON.parse('{"title":"Installation and Usage","description":"","frontmatter":{},"headers":[],"relativePath":"en/index.md","filePath":"en/index.md","lastUpdated":1754013470000}'),p={name:"en/index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`

Installation and Usage ​

Installation ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

Usage ​

html
<html>
+import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g=JSON.parse('{"title":"Installation and Usage","description":"","frontmatter":{},"headers":[],"relativePath":"en/index.md","filePath":"en/index.md","lastUpdated":1754013470000}'),p={name:"en/index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`

Installation and Usage ​

Installation ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

Usage ​

html
<html>
     <head>
         <title>ArtPlayer Demo</title>
         <meta charset="UTF-8" />
@@ -19,7 +19,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
           });
         </script>
     </body>
-</html>

Warning

The player's size depends on the size of the container container, so your container container must have a size.

You can find more usage examples at the link below

/packages/artplayer-template

Vue.js ​

vue
<template>
+</html>

Warning

The player's size depends on the size of the container container, so your container container must have a size.

You can find more usage examples at the link below

/packages/artplayer-template

Vue.js ​

vue
<template>
   <div ref="artRef"></div>
 </template>
 
@@ -83,7 +83,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
     },
   },
 };
-</script>

Artplayer Not Responsive:

Modifying option directly in Vue.js will not change the player

React.js ​

jsx
import { useEffect, useRef } from 'react';
+</script>

Artplayer Not Responsive:

Modifying option directly in Vue.js will not change the player

React.js ​

jsx
import { useEffect, useRef } from 'react';
 import Artplayer from 'artplayer';
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -171,7 +171,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
 
 option.volume = 0.5;
 
-const art8 = new Artplayer(option);

Ancient Browsers ​

The production build of artplayer.js is only compatible with the latest major version of Chrome: last 1 Chrome version

For ancient browsers, you can use the artplayer.legacy.js file, which is compatible up to: IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

If you need to support even older browsers, please modify the following configuration and then build it yourself:

Build configuration: scripts/build.js

Refer to documentation: browserslist

ECMAScript Module ​

Starting from 5.2.4, artplayer and all plugins will also provide an ESM version of js, such as:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
+const art8 = new Artplayer(option);

Ancient Browsers ​

The production build of artplayer.js is only compatible with the latest major version of Chrome: last 1 Chrome version

For ancient browsers, you can use the artplayer.legacy.js file, which is compatible up to: IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

If you need to support even older browsers, please modify the following configuration and then build it yourself:

Build configuration: scripts/build.js

Refer to documentation: browserslist

ECMAScript Module ​

Starting from 5.2.4, artplayer and all plugins will also provide an ESM version of js, such as:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
diff --git a/docs/document/assets/en_index.md.CVTkjvLi.lean.js b/docs/document/assets/en_index.md.BoUDo3iv.lean.js
similarity index 100%
rename from docs/document/assets/en_index.md.CVTkjvLi.lean.js
rename to docs/document/assets/en_index.md.BoUDo3iv.lean.js
diff --git a/docs/document/assets/en_start_i18n.md.BsPhEMUT.js b/docs/document/assets/en_start_i18n.md.DAQP9Wc-.js
similarity index 98%
rename from docs/document/assets/en_start_i18n.md.BsPhEMUT.js
rename to docs/document/assets/en_start_i18n.md.DAQP9Wc-.js
index 4d9d7c77b..262adca4f 100644
--- a/docs/document/assets/en_start_i18n.md.BsPhEMUT.js
+++ b/docs/document/assets/en_start_i18n.md.DAQP9Wc-.js
@@ -2,7 +2,7 @@ import{_ as a,c as i,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
     container: '.artplayer-app',
     url: '/assets/sample/video.mp4',
     lang: 'zh-cn', // or 'en'
-});

Importing Languages ​

Language files before packaging are located in: artplayer/src/i18n/*.js. You are welcome to add your language. Packaged language files are located at: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
+});

Importing Languages ​

Language files before packaging are located in: artplayer/src/i18n/*.js. You are welcome to add your language. Packaged language files are located at: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
 import zhTw from 'artplayer/dist/i18n/zh-tw.js';
 
 var art = new Artplayer({
diff --git a/docs/document/assets/en_start_i18n.md.BsPhEMUT.lean.js b/docs/document/assets/en_start_i18n.md.DAQP9Wc-.lean.js
similarity index 100%
rename from docs/document/assets/en_start_i18n.md.BsPhEMUT.lean.js
rename to docs/document/assets/en_start_i18n.md.DAQP9Wc-.lean.js
diff --git a/docs/document/assets/index.md.B7z5s1WD.js b/docs/document/assets/index.md.Ct-mw3b5.js
similarity index 98%
rename from docs/document/assets/index.md.B7z5s1WD.js
rename to docs/document/assets/index.md.Ct-mw3b5.js
index a11d68249..3a7587a83 100644
--- a/docs/document/assets/index.md.B7z5s1WD.js
+++ b/docs/document/assets/index.md.Ct-mw3b5.js
@@ -1,4 +1,4 @@
-import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g=JSON.parse('{"title":"安装使用","description":"","frontmatter":{},"headers":[],"relativePath":"index.md","filePath":"index.md","lastUpdated":1754013470000}'),p={name:"index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`

安装使用 ​

安装 ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

使用 ​

html
<html>
+import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g=JSON.parse('{"title":"安装使用","description":"","frontmatter":{},"headers":[],"relativePath":"index.md","filePath":"index.md","lastUpdated":1754013470000}'),p={name:"index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`

安装使用 ​

安装 ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

使用 ​

html
<html>
     <head>
         <title>ArtPlayer Demo</title>
         <meta charset="UTF-8" />
@@ -19,7 +19,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
           });
         </script>
     </body>
-</html>

提示

播放器的尺寸依赖于容器 container 的尺寸,所以你的容器 container 必须是有尺寸的

以下链接可以看到更多的使用例子

/packages/artplayer-template

Vue.js ​

vue
<template>
+</html>

提示

播放器的尺寸依赖于容器 container 的尺寸,所以你的容器 container 必须是有尺寸的

以下链接可以看到更多的使用例子

/packages/artplayer-template

Vue.js ​

vue
<template>
   <div ref="artRef"></div>
 </template>
 
@@ -83,7 +83,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
     },
   },
 };
-</script>

Artplayer 非响应式:

在 Vue.js 里直接修改 option 是不会改变播放器的

React.js ​

jsx
import { useEffect, useRef } from 'react';
+</script>

Artplayer 非响应式:

在 Vue.js 里直接修改 option 是不会改变播放器的

React.js ​

jsx
import { useEffect, useRef } from 'react';
 import Artplayer from 'artplayer';
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -171,7 +171,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
 
 option.volume = 0.5;
 
-const art8 = new Artplayer(option);

古老的浏览器 ​

生产构建的 artplayer.js 只兼容最新一个主版本的 Chrome:last 1 Chrome version

对于古老的浏览器,可以使用 artplayer.legacy.js 文件,可以兼容到:IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

假如你要兼容更古老的浏览器时,请修改以下配置然后自行构建:

构建配置:scripts/build.js

参考文档:browserslist

ECMAScript Module ​

从 5.2.4 开始,artplayer和所有插件还会提供一个ESM版本的js,如:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
+const art8 = new Artplayer(option);

古老的浏览器 ​

生产构建的 artplayer.js 只兼容最新一个主版本的 Chrome:last 1 Chrome version

对于古老的浏览器,可以使用 artplayer.legacy.js 文件,可以兼容到:IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

假如你要兼容更古老的浏览器时,请修改以下配置然后自行构建:

构建配置:scripts/build.js

参考文档:browserslist

ECMAScript Module ​

从 5.2.4 开始,artplayer和所有插件还会提供一个ESM版本的js,如:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
diff --git a/docs/document/assets/index.md.B7z5s1WD.lean.js b/docs/document/assets/index.md.Ct-mw3b5.lean.js
similarity index 100%
rename from docs/document/assets/index.md.B7z5s1WD.lean.js
rename to docs/document/assets/index.md.Ct-mw3b5.lean.js
diff --git a/docs/document/assets/plugin_danmuku.md.DGwdwoB_.js b/docs/document/assets/plugin_danmuku.md.4zCywahu.js
similarity index 99%
rename from docs/document/assets/plugin_danmuku.md.DGwdwoB_.js
rename to docs/document/assets/plugin_danmuku.md.4zCywahu.js
index ff1bfb813..c32906980 100644
--- a/docs/document/assets/plugin_danmuku.md.DGwdwoB_.js
+++ b/docs/document/assets/plugin_danmuku.md.4zCywahu.js
@@ -1,4 +1,4 @@
-import{_ as n,c as l,o as p,ak as s,j as i}from"./chunks/framework.xxfEszSJ.js";const y=JSON.parse('{"title":"弹幕库","description":"","frontmatter":{},"headers":[],"relativePath":"plugin/danmuku.md","filePath":"plugin/danmuku.md","lastUpdated":1734270991000}'),h={name:"plugin/danmuku.md"};function e(k,a,t,r,E,d){return p(),l("div",null,a[0]||(a[0]=[s(`

弹幕库 ​

演示 ​

👉 查看完整演示

安装 ​

bash
npm install artplayer-plugin-danmuku
bash
yarn add artplayer-plugin-danmuku
bash
pnpm add artplayer-plugin-danmuku
html
<script src="path/to/artplayer-plugin-danmuku.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js
bash
https://unpkg.com/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js

弹幕结构 ​

每一个弹幕是一个对象,多个弹幕组成的数组就是弹幕库,通常只需要text就可以发送一个弹幕,其余都是非必要参数

js
{
+import{_ as n,c as l,o as p,ak as s,j as i}from"./chunks/framework.xxfEszSJ.js";const y=JSON.parse('{"title":"弹幕库","description":"","frontmatter":{},"headers":[],"relativePath":"plugin/danmuku.md","filePath":"plugin/danmuku.md","lastUpdated":1734270991000}'),h={name:"plugin/danmuku.md"};function e(k,a,t,r,E,d){return p(),l("div",null,a[0]||(a[0]=[s(`

弹幕库 ​

演示 ​

👉 查看完整演示

安装 ​

bash
npm install artplayer-plugin-danmuku
bash
yarn add artplayer-plugin-danmuku
bash
pnpm add artplayer-plugin-danmuku
html
<script src="path/to/artplayer-plugin-danmuku.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js
bash
https://unpkg.com/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js

弹幕结构 ​

每一个弹幕是一个对象,多个弹幕组成的数组就是弹幕库,通常只需要text就可以发送一个弹幕,其余都是非必要参数

js
{
     text: '', // 弹幕文本
     time: 10, // 弹幕时间, 默认为当前播放器时间
     mode: 0, // 弹幕模式: 0: 滚动(默认),1: 顶部,2: 底部
diff --git a/docs/document/assets/plugin_danmuku.md.DGwdwoB_.lean.js b/docs/document/assets/plugin_danmuku.md.4zCywahu.lean.js
similarity index 100%
rename from docs/document/assets/plugin_danmuku.md.DGwdwoB_.lean.js
rename to docs/document/assets/plugin_danmuku.md.4zCywahu.lean.js
diff --git a/docs/document/assets/start_i18n.md.DkqeV9gh.js b/docs/document/assets/start_i18n.md.B_Jqm0vZ.js
similarity index 98%
rename from docs/document/assets/start_i18n.md.DkqeV9gh.js
rename to docs/document/assets/start_i18n.md.B_Jqm0vZ.js
index da1b36093..08774080c 100644
--- a/docs/document/assets/start_i18n.md.DkqeV9gh.js
+++ b/docs/document/assets/start_i18n.md.B_Jqm0vZ.js
@@ -2,7 +2,7 @@ import{_ as a,c as i,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const c
     container: '.artplayer-app',
     url: '/assets/sample/video.mp4',
     lang: 'zh-cn', // or 'en'
-});

导入语言 ​

打包前的语言文件存放于: artplayer/src/i18n/*.js, 欢迎来添加你的语言

打包后的语言文件存放于: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
+});

导入语言 ​

打包前的语言文件存放于: artplayer/src/i18n/*.js, 欢迎来添加你的语言

打包后的语言文件存放于: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
 import zhTw from 'artplayer/dist/i18n/zh-tw.js';
 
 var art = new Artplayer({
diff --git a/docs/document/assets/start_i18n.md.DkqeV9gh.lean.js b/docs/document/assets/start_i18n.md.B_Jqm0vZ.lean.js
similarity index 100%
rename from docs/document/assets/start_i18n.md.DkqeV9gh.lean.js
rename to docs/document/assets/start_i18n.md.B_Jqm0vZ.lean.js
diff --git a/docs/document/component/contextmenu.html b/docs/document/component/contextmenu.html
index 52be15dc5..1ce3da556 100644
--- a/docs/document/component/contextmenu.html
+++ b/docs/document/component/contextmenu.html
@@ -106,7 +106,7 @@
         })
     }, 3000);
 });
- + \ No newline at end of file diff --git a/docs/document/component/controls.html b/docs/document/component/controls.html index 34c48b5ec..c376b011a 100644 --- a/docs/document/component/controls.html +++ b/docs/document/component/controls.html @@ -153,7 +153,7 @@ }); }, 3000); });
- + \ No newline at end of file diff --git a/docs/document/component/layers.html b/docs/document/component/layers.html index 29ca7eb9d..9865bc9ad 100644 --- a/docs/document/component/layers.html +++ b/docs/document/component/layers.html @@ -125,7 +125,7 @@ }); }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/component/setting.html b/docs/document/component/setting.html index eb7e0fe35..0ac454dc0 100644 --- a/docs/document/component/setting.html +++ b/docs/document/component/setting.html @@ -245,7 +245,7 @@ }); }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/en/advanced/built-in.html b/docs/document/en/advanced/built-in.html index b7bf8176d..f9317ba17 100644 --- a/docs/document/en/advanced/built-in.html +++ b/docs/document/en/advanced/built-in.html @@ -206,7 +206,7 @@ art.on('ready', () => { art.plugins.add(myPlugin); }); - + \ No newline at end of file diff --git a/docs/document/en/advanced/class.html b/docs/document/en/advanced/class.html index cc6f7cc02..2558a9bd3 100644 --- a/docs/document/en/advanced/class.html +++ b/docs/document/en/advanced/class.html @@ -31,7 +31,7 @@ }); console.info([...Artplayer.instances]);

version ​

Returns the version information of the player.

▶ Run Code
js
console.info(Artplayer.version);

env ​

Returns the environment variables of the player.

▶ Run Code
js
console.info(Artplayer.env);

build ​

Returns the build time of the player

▶ Run Code
js
console.info(Artplayer.build);

config ​

Returns the default configuration of the video

▶ Run Code
js
console.info(Artplayer.config);

utils ​

Returns a collection of utility functions for the player

▶ Run Code
js
console.info(Artplayer.utils);

For the full list of utility functions, please refer to the following address:

artplayer/types/utils.d.ts

scheme ​

Returns the validation scheme for the player options

▶ Run Code
js
console.info(Artplayer.scheme);

Emitter ​

Returns the constructor for the event dispatcher

▶ Run Code
js
console.info(Artplayer.Emitter);

validator ​

Returns the validation function for options

▶ Run Code
js
console.info(Artplayer.validator);

kindOf ​

Returns the function tool for type checking

▶ Run Code
js
console.info(Artplayer.kindOf);

html ​

Returns the html string required for the player

▶ Run Code
js
console.info(Artplayer.html);

option ​

Returns the player's default options

▶ Run Code
js
console.info(Artplayer.option);
- + \ No newline at end of file diff --git a/docs/document/en/advanced/event.html b/docs/document/en/advanced/event.html index 7f0ca1834..44b668c90 100644 --- a/docs/document/en/advanced/event.html +++ b/docs/document/en/advanced/event.html @@ -385,7 +385,7 @@ art.on('keydown', (event) => { console.log(event.code); });

video:canplay ​

The browser can play the media file, but estimates there is not enough data to play through to the end without having to stop for further buffering

video:canplaythrough ​

The browser estimates it can play the media through to the end without stopping for content buffering

video:complete ​

OfflineAudioContext rendering is complete

video:durationchange ​

Triggered when the value of the duration property changes

video:emptied ​

The media content becomes empty; for example, when this media has been completely loaded (or partially loaded), this event is sent and the load() method is called to reload it

video:ended ​

The video has stopped because the media reached the end point

video:error ​

An error occurred while fetching media data, or the resource type is not a supported media format

video:loadeddata ​

The first frame of the media has finished loading

video:loadedmetadata ​

Metadata has been loaded

video:pause ​

Playback has been paused

video:play ​

Playback has started

video:playing ​

Playback is ready to start following a pause or delay due to lack of data

video:progress ​

Periodically triggered while the browser is loading resources

video:ratechange ​

The playback rate has changed

video:seeked ​

A seek (frame skipping) operation has completed

video:seeking ​

A seek (frame skipping) operation has started

video:stalled ​

The user agent is trying to fetch media data, but the data unexpectedly has not appeared

video:suspend ​

Media data loading has been suspended

video:timeupdate ​

The time specified by the currentTime attribute has changed

video:volumechange ​

Volume changed

video:waiting ​

Playback has stopped due to temporarily missing data

- + \ No newline at end of file diff --git a/docs/document/en/advanced/global.html b/docs/document/en/advanced/global.html index 15be384b7..08805a7da 100644 --- a/docs/document/en/advanced/global.html +++ b/docs/document/en/advanced/global.html @@ -245,7 +245,7 @@ url: '/assets/sample/video.mp4', miniProgressBar: true, }); - + \ No newline at end of file diff --git a/docs/document/en/advanced/plugin.html b/docs/document/en/advanced/plugin.html index b52407ef4..06d09dbdb 100644 --- a/docs/document/en/advanced/plugin.html +++ b/docs/document/en/advanced/plugin.html @@ -122,7 +122,7 @@ }) ], }); - + \ No newline at end of file diff --git a/docs/document/en/advanced/property.html b/docs/document/en/advanced/property.html index 48f41be30..698aeb553 100644 --- a/docs/document/en/advanced/property.html +++ b/docs/document/en/advanced/property.html @@ -428,7 +428,7 @@ art.on('ready', () => { art.subtitleOffset = 1; }); - + \ No newline at end of file diff --git a/docs/document/en/component/contextmenu.html b/docs/document/en/component/contextmenu.html index 4ae5117aa..df8831945 100644 --- a/docs/document/en/component/contextmenu.html +++ b/docs/document/en/component/contextmenu.html @@ -106,7 +106,7 @@ }) }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/en/component/controls.html b/docs/document/en/component/controls.html index ed053d3d1..179810c88 100644 --- a/docs/document/en/component/controls.html +++ b/docs/document/en/component/controls.html @@ -153,7 +153,7 @@ }); }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/en/component/layers.html b/docs/document/en/component/layers.html index 943851e8b..ffa4b7c36 100644 --- a/docs/document/en/component/layers.html +++ b/docs/document/en/component/layers.html @@ -125,7 +125,7 @@ }); }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/en/component/setting.html b/docs/document/en/component/setting.html index 73c4e7855..dc7a2cbd8 100644 --- a/docs/document/en/component/setting.html +++ b/docs/document/en/component/setting.html @@ -245,7 +245,7 @@ }); }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/en/index.html b/docs/document/en/index.html index 1c1b9fef0..2ad89ab4e 100644 --- a/docs/document/en/index.html +++ b/docs/document/en/index.html @@ -13,7 +13,7 @@ - + @@ -23,7 +23,7 @@ -
Skip to content

Installation and Usage ​

Installation ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

Usage ​

html
<html>
+    
Skip to content

Installation and Usage ​

Installation ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

Usage ​

html
<html>
     <head>
         <title>ArtPlayer Demo</title>
         <meta charset="UTF-8" />
@@ -44,7 +44,7 @@
           });
         </script>
     </body>
-</html>

Warning

The player's size depends on the size of the container container, so your container container must have a size.

You can find more usage examples at the link below

/packages/artplayer-template

Vue.js ​

vue
<template>
+</html>

Warning

The player's size depends on the size of the container container, so your container container must have a size.

You can find more usage examples at the link below

/packages/artplayer-template

Vue.js ​

vue
<template>
   <div ref="artRef"></div>
 </template>
 
@@ -108,7 +108,7 @@
     },
   },
 };
-</script>

Artplayer Not Responsive:

Modifying option directly in Vue.js will not change the player

React.js ​

jsx
import { useEffect, useRef } from 'react';
+</script>

Artplayer Not Responsive:

Modifying option directly in Vue.js will not change the player

React.js ​

jsx
import { useEffect, useRef } from 'react';
 import Artplayer from 'artplayer';
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -196,7 +196,7 @@
 
 option.volume = 0.5;
 
-const art8 = new Artplayer(option);

Ancient Browsers ​

The production build of artplayer.js is only compatible with the latest major version of Chrome: last 1 Chrome version

For ancient browsers, you can use the artplayer.legacy.js file, which is compatible up to: IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

If you need to support even older browsers, please modify the following configuration and then build it yourself:

Build configuration: scripts/build.js

Refer to documentation: browserslist

ECMAScript Module ​

Starting from 5.2.4, artplayer and all plugins will also provide an ESM version of js, such as:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
+const art8 = new Artplayer(option);

Ancient Browsers ​

The production build of artplayer.js is only compatible with the latest major version of Chrome: last 1 Chrome version

For ancient browsers, you can use the artplayer.legacy.js file, which is compatible up to: IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

If you need to support even older browsers, please modify the following configuration and then build it yourself:

Build configuration: scripts/build.js

Refer to documentation: browserslist

ECMAScript Module ​

Starting from 5.2.4, artplayer and all plugins will also provide an ESM version of js, such as:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
@@ -254,7 +254,7 @@
         </script>
     </body>
 </html>

Warning

You need to modify it before import the Artplayer for it to take effect

- + \ No newline at end of file diff --git a/docs/document/en/start/i18n.html b/docs/document/en/start/i18n.html index 5228c334d..02fff9512 100644 --- a/docs/document/en/start/i18n.html +++ b/docs/document/en/start/i18n.html @@ -13,7 +13,7 @@ - + @@ -27,7 +27,7 @@ container: '.artplayer-app', url: '/assets/sample/video.mp4', lang: 'zh-cn', // or 'en' -});

Importing Languages ​

Language files before packaging are located in: artplayer/src/i18n/*.js. You are welcome to add your language. Packaged language files are located at: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
+});

Importing Languages ​

Language files before packaging are located in: artplayer/src/i18n/*.js. You are welcome to add your language. Packaged language files are located at: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
 import zhTw from 'artplayer/dist/i18n/zh-tw.js';
 
 var art = new Artplayer({
@@ -75,7 +75,7 @@
         },
     },
 });
- + \ No newline at end of file diff --git a/docs/document/en/start/option.html b/docs/document/en/start/option.html index d1775b414..2601b8de0 100644 --- a/docs/document/en/start/option.html +++ b/docs/document/en/start/option.html @@ -411,7 +411,7 @@ url: '/assets/sample/video.mp4', proxy: () => document.createElement('video') }); - + \ No newline at end of file diff --git a/docs/document/hashmap.json b/docs/document/hashmap.json index d46c21d90..887629529 100644 --- a/docs/document/hashmap.json +++ b/docs/document/hashmap.json @@ -1 +1 @@ -{"advanced_built-in.md":"B5ccy6gK","advanced_class.md":"Da3aE0pP","advanced_event.md":"mrsB0MsK","advanced_global.md":"C-56tmUD","advanced_plugin.md":"B3Pobmcq","advanced_property.md":"D59FnDH1","component_contextmenu.md":"ClKmcIKr","component_controls.md":"Cl62yW1F","component_layers.md":"Cys52VMi","component_setting.md":"BP5674ir","en_advanced_built-in.md":"CY71IZlq","en_advanced_class.md":"C3V-LDO3","en_advanced_event.md":"D5Yv5LYW","en_advanced_global.md":"BbhNIAMt","en_advanced_plugin.md":"hspsx5uD","en_advanced_property.md":"COS94_z7","en_component_contextmenu.md":"DgD64wIy","en_component_controls.md":"Bj2oItzY","en_component_layers.md":"BNGRBNoB","en_component_setting.md":"Dqvlpr4j","en_index.md":"CVTkjvLi","en_start_i18n.md":"BsPhEMUT","en_start_option.md":"6JX4hU8Q","index.md":"B7z5s1WD","plugin_danmuku.md":"DGwdwoB_","start_i18n.md":"DkqeV9gh","start_option.md":"B5CHO-We"} +{"advanced_built-in.md":"B5ccy6gK","advanced_class.md":"Da3aE0pP","advanced_event.md":"mrsB0MsK","advanced_global.md":"C-56tmUD","advanced_plugin.md":"B3Pobmcq","advanced_property.md":"D59FnDH1","component_contextmenu.md":"ClKmcIKr","component_controls.md":"Cl62yW1F","component_layers.md":"Cys52VMi","component_setting.md":"BP5674ir","en_advanced_built-in.md":"CY71IZlq","en_advanced_class.md":"C3V-LDO3","en_advanced_event.md":"D5Yv5LYW","en_advanced_global.md":"BbhNIAMt","en_advanced_plugin.md":"hspsx5uD","en_advanced_property.md":"COS94_z7","en_component_contextmenu.md":"DgD64wIy","en_component_controls.md":"Bj2oItzY","en_component_layers.md":"BNGRBNoB","en_component_setting.md":"Dqvlpr4j","en_index.md":"BoUDo3iv","en_start_i18n.md":"DAQP9Wc-","en_start_option.md":"6JX4hU8Q","index.md":"Ct-mw3b5","plugin_danmuku.md":"4zCywahu","start_i18n.md":"B_Jqm0vZ","start_option.md":"B5CHO-We"} diff --git a/docs/document/index.html b/docs/document/index.html index fe5f978e1..4de14f5b5 100644 --- a/docs/document/index.html +++ b/docs/document/index.html @@ -13,7 +13,7 @@ - + @@ -23,7 +23,7 @@ -
Skip to content

安装使用 ​

安装 ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

使用 ​

html
<html>
+    
Skip to content

安装使用 ​

安装 ​

bash
npm install artplayer
bash
yarn add artplayer
bash
pnpm add artplayer
html
<script src="path/to/artplayer.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js
bash
https://unpkg.com/artplayer/dist/artplayer.js

使用 ​

html
<html>
     <head>
         <title>ArtPlayer Demo</title>
         <meta charset="UTF-8" />
@@ -44,7 +44,7 @@
           });
         </script>
     </body>
-</html>

提示

播放器的尺寸依赖于容器 container 的尺寸,所以你的容器 container 必须是有尺寸的

以下链接可以看到更多的使用例子

/packages/artplayer-template

Vue.js ​

vue
<template>
+</html>

提示

播放器的尺寸依赖于容器 container 的尺寸,所以你的容器 container 必须是有尺寸的

以下链接可以看到更多的使用例子

/packages/artplayer-template

Vue.js ​

vue
<template>
   <div ref="artRef"></div>
 </template>
 
@@ -108,7 +108,7 @@
     },
   },
 };
-</script>

Artplayer 非响应式:

在 Vue.js 里直接修改 option 是不会改变播放器的

React.js ​

jsx
import { useEffect, useRef } from 'react';
+</script>

Artplayer 非响应式:

在 Vue.js 里直接修改 option 是不会改变播放器的

React.js ​

jsx
import { useEffect, useRef } from 'react';
 import Artplayer from 'artplayer';
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -196,7 +196,7 @@
 
 option.volume = 0.5;
 
-const art8 = new Artplayer(option);

古老的浏览器 ​

生产构建的 artplayer.js 只兼容最新一个主版本的 Chrome:last 1 Chrome version

对于古老的浏览器,可以使用 artplayer.legacy.js 文件,可以兼容到:IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

假如你要兼容更古老的浏览器时,请修改以下配置然后自行构建:

构建配置:scripts/build.js

参考文档:browserslist

ECMAScript Module ​

从 5.2.4 开始,artplayer和所有插件还会提供一个ESM版本的js,如:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
+const art8 = new Artplayer(option);

古老的浏览器 ​

生产构建的 artplayer.js 只兼容最新一个主版本的 Chrome:last 1 Chrome version

对于古老的浏览器,可以使用 artplayer.legacy.js 文件,可以兼容到:IE 11

js
import Artplayer from 'artplayer/dist/artplayer.legacy.js';
bash
https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.legacy.js
bash
https://unpkg.com/artplayer/dist/artplayer.legacy.js

假如你要兼容更古老的浏览器时,请修改以下配置然后自行构建:

构建配置:scripts/build.js

参考文档:browserslist

ECMAScript Module ​

从 5.2.4 开始,artplayer和所有插件还会提供一个ESM版本的js,如:

  • artplayer/dist/artplayer.esm.js
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
@@ -254,7 +254,7 @@
         </script>
     </body>
 </html>

提示

你需要在引入 Artplayer 依赖前来修改它才会生效

- + \ No newline at end of file diff --git a/docs/document/plugin/danmuku.html b/docs/document/plugin/danmuku.html index 2e7f20f06..06a064321 100644 --- a/docs/document/plugin/danmuku.html +++ b/docs/document/plugin/danmuku.html @@ -13,7 +13,7 @@ - + @@ -23,7 +23,7 @@ -
Skip to content

弹幕库 ​

演示 ​

👉 查看完整演示

安装 ​

bash
npm install artplayer-plugin-danmuku
bash
yarn add artplayer-plugin-danmuku
bash
pnpm add artplayer-plugin-danmuku
html
<script src="path/to/artplayer-plugin-danmuku.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js
bash
https://unpkg.com/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js

弹幕结构 ​

每一个弹幕是一个对象,多个弹幕组成的数组就是弹幕库,通常只需要text就可以发送一个弹幕,其余都是非必要参数

js
{
+    
Skip to content

弹幕库 ​

演示 ​

👉 查看完整演示

安装 ​

bash
npm install artplayer-plugin-danmuku
bash
yarn add artplayer-plugin-danmuku
bash
pnpm add artplayer-plugin-danmuku
html
<script src="path/to/artplayer-plugin-danmuku.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js
bash
https://unpkg.com/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js

弹幕结构 ​

每一个弹幕是一个对象,多个弹幕组成的数组就是弹幕库,通常只需要text就可以发送一个弹幕,其余都是非必要参数

js
{
     text: '', // 弹幕文本
     time: 10, // 弹幕时间, 默认为当前播放器时间
     mode: 0, // 弹幕模式: 0: 滚动(默认),1: 顶部,2: 底部
@@ -367,7 +367,7 @@
 art.on('artplayerPluginDanmuku:destroy', () => {
     console.info('弹幕销毁');
 });
- + \ No newline at end of file diff --git a/docs/document/start/i18n.html b/docs/document/start/i18n.html index db3ca5d5f..cf1983e0a 100644 --- a/docs/document/start/i18n.html +++ b/docs/document/start/i18n.html @@ -13,7 +13,7 @@ - + @@ -27,7 +27,7 @@ container: '.artplayer-app', url: '/assets/sample/video.mp4', lang: 'zh-cn', // or 'en' -});

导入语言 ​

打包前的语言文件存放于: artplayer/src/i18n/*.js, 欢迎来添加你的语言

打包后的语言文件存放于: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
+});

导入语言 ​

打包前的语言文件存放于: artplayer/src/i18n/*.js, 欢迎来添加你的语言

打包后的语言文件存放于: artplayer/dist/i18n/*.js

js
import id from 'artplayer/dist/i18n/id.js';
 import zhTw from 'artplayer/dist/i18n/zh-tw.js';
 
 var art = new Artplayer({
@@ -75,7 +75,7 @@
         },
     },
 });
- + \ No newline at end of file diff --git a/docs/document/start/option.html b/docs/document/start/option.html index e151e68cd..526d47156 100644 --- a/docs/document/start/option.html +++ b/docs/document/start/option.html @@ -411,7 +411,7 @@ url: '/assets/sample/video.mp4', proxy: () => document.createElement('video') });
- + \ No newline at end of file diff --git a/docs/esm.html b/docs/esm.html index 915de19d0..83ba767b7 100644 --- a/docs/esm.html +++ b/docs/esm.html @@ -15,8 +15,8 @@ diff --git a/packages/artplayer-plugin-ads/package.json b/packages/artplayer-plugin-ads/package.json index 21e112881..243648bbb 100644 --- a/packages/artplayer-plugin-ads/package.json +++ b/packages/artplayer-plugin-ads/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-ads.esm.js", - "require": "./dist/artplayer-plugin-ads.js", - "default": "./dist/artplayer-plugin-ads.js" + ".": { + "import": "./dist/artplayer-plugin-ads.mjs", + "require": "./dist/artplayer-plugin-ads.js" + } }, - "main": "dist/artplayer-plugin-ads.js", - "legacy": "dist/artplayer-plugin-ads.legacy.js", - "module": "dist/artplayer-plugin-ads.esm.js", - "types": "types/artplayer-plugin-ads.d.ts", + "main": "./dist/artplayer-plugin-ads.js", + "module": "./dist/artplayer-plugin-ads.mjs", + "types": "./types/artplayer-plugin-ads.d.ts", + "legacy": "./dist/artplayer-plugin-ads.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-ambilight/package.json b/packages/artplayer-plugin-ambilight/package.json index f4b5405b3..3d95cfbea 100644 --- a/packages/artplayer-plugin-ambilight/package.json +++ b/packages/artplayer-plugin-ambilight/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-ambilight.esm.js", - "require": "./dist/artplayer-plugin-ambilight.js", - "default": "./dist/artplayer-plugin-ambilight.js" + ".": { + "import": "./dist/artplayer-plugin-ambilight.mjs", + "require": "./dist/artplayer-plugin-ambilight.js" + } }, - "main": "dist/artplayer-plugin-ambilight.js", - "legacy": "dist/artplayer-plugin-ambilight.legacy.js", - "module": "dist/artplayer-plugin-ambilight.esm.js", - "types": "types/artplayer-plugin-ambilight.d.ts", + "main": "./dist/artplayer-plugin-ambilight.js", + "module": "./dist/artplayer-plugin-ambilight.mjs", + "types": "./types/artplayer-plugin-ambilight.d.ts", + "legacy": "./dist/artplayer-plugin-ambilight.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-asr/package.json b/packages/artplayer-plugin-asr/package.json index 0b6b8e914..2ac8e21f7 100644 --- a/packages/artplayer-plugin-asr/package.json +++ b/packages/artplayer-plugin-asr/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-asr.esm.js", - "require": "./dist/artplayer-plugin-asr.js", - "default": "./dist/artplayer-plugin-asr.js" + ".": { + "import": "./dist/artplayer-plugin-asr.mjs", + "require": "./dist/artplayer-plugin-asr.js" + } }, - "main": "dist/artplayer-plugin-asr.js", - "legacy": "dist/artplayer-plugin-asr.legacy.js", - "module": "dist/artplayer-plugin-asr.esm.js", - "types": "types/artplayer-plugin-asr.d.ts", + "main": "./dist/artplayer-plugin-asr.js", + "module": "./dist/artplayer-plugin-asr.mjs", + "types": "./types/artplayer-plugin-asr.d.ts", + "legacy": "./dist/artplayer-plugin-asr.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-auto-thumbnail/package.json b/packages/artplayer-plugin-auto-thumbnail/package.json index ea8cdd153..90e8212be 100644 --- a/packages/artplayer-plugin-auto-thumbnail/package.json +++ b/packages/artplayer-plugin-auto-thumbnail/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-auto-thumbnail.esm.js", - "require": "./dist/artplayer-plugin-auto-thumbnail.js", - "default": "./dist/artplayer-plugin-auto-thumbnail.js" + ".": { + "import": "./dist/artplayer-plugin-auto-thumbnail.mjs", + "require": "./dist/artplayer-plugin-auto-thumbnail.js" + } }, - "main": "dist/artplayer-plugin-auto-thumbnail.js", - "legacy": "dist/artplayer-plugin-auto-thumbnail.legacy.js", - "module": "dist/artplayer-plugin-auto-thumbnail.esm.js", - "types": "types/artplayer-plugin-auto-thumbnail.d.ts", + "main": "./dist/artplayer-plugin-auto-thumbnail.js", + "module": "./dist/artplayer-plugin-auto-thumbnail.mjs", + "types": "./types/artplayer-plugin-auto-thumbnail.d.ts", + "legacy": "./dist/artplayer-plugin-auto-thumbnail.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-chapter/package.json b/packages/artplayer-plugin-chapter/package.json index ef587b2bf..e36e0d0fe 100644 --- a/packages/artplayer-plugin-chapter/package.json +++ b/packages/artplayer-plugin-chapter/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-chapter.esm.js", - "require": "./dist/artplayer-plugin-chapter.js", - "default": "./dist/artplayer-plugin-chapter.js" + ".": { + "import": "./dist/artplayer-plugin-chapter.mjs", + "require": "./dist/artplayer-plugin-chapter.js" + } }, - "main": "dist/artplayer-plugin-chapter.js", - "legacy": "dist/artplayer-plugin-chapter.legacy.js", - "module": "dist/artplayer-plugin-chapter.esm.js", - "types": "types/artplayer-plugin-chapter.d.ts", + "main": "./dist/artplayer-plugin-chapter.js", + "module": "./dist/artplayer-plugin-chapter.mjs", + "types": "./types/artplayer-plugin-chapter.d.ts", + "legacy": "./dist/artplayer-plugin-chapter.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-chromecast/package.json b/packages/artplayer-plugin-chromecast/package.json index 62fcabd54..bcf072479 100644 --- a/packages/artplayer-plugin-chromecast/package.json +++ b/packages/artplayer-plugin-chromecast/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-chromecast.esm.js", - "require": "./dist/artplayer-plugin-chromecast.js", - "default": "./dist/artplayer-plugin-chromecast.js" + ".": { + "import": "./dist/artplayer-plugin-chromecast.mjs", + "require": "./dist/artplayer-plugin-chromecast.js" + } }, - "main": "dist/artplayer-plugin-chromecast.js", - "legacy": "dist/artplayer-plugin-chromecast.legacy.js", - "module": "dist/artplayer-plugin-chromecast.esm.js", - "types": "types/artplayer-plugin-chromecast.d.ts", + "main": "./dist/artplayer-plugin-chromecast.js", + "module": "./dist/artplayer-plugin-chromecast.mjs", + "types": "./types/artplayer-plugin-chromecast.d.ts", + "legacy": "./dist/artplayer-plugin-chromecast.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-danmuku-mask/package.json b/packages/artplayer-plugin-danmuku-mask/package.json index e08e575f4..54c59a3b9 100644 --- a/packages/artplayer-plugin-danmuku-mask/package.json +++ b/packages/artplayer-plugin-danmuku-mask/package.json @@ -18,14 +18,15 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-danmuku-mask.esm.js", - "require": "./dist/artplayer-plugin-danmuku-mask.js", - "default": "./dist/artplayer-plugin-danmuku-mask.js" + ".": { + "import": "./dist/artplayer-plugin-danmuku-mask.mjs", + "require": "./dist/artplayer-plugin-danmuku-mask.js" + } }, - "main": "dist/artplayer-plugin-danmuku-mask.js", - "legacy": "dist/artplayer-plugin-danmuku-mask.legacy.js", - "module": "dist/artplayer-plugin-danmuku-mask.esm.js", - "types": "types/artplayer-plugin-danmuku-mask.d.ts", + "main": "./dist/artplayer-plugin-danmuku-mask.js", + "module": "./dist/artplayer-plugin-danmuku-mask.mjs", + "types": "./types/artplayer-plugin-danmuku-mask.d.ts", + "legacy": "./dist/artplayer-plugin-danmuku-mask.legacy.js", "browserslist": "last 1 Chrome version", "dependencies": { "@mediapipe/selfie_segmentation": "^0.1.1675465747", diff --git a/packages/artplayer-plugin-danmuku/package.json b/packages/artplayer-plugin-danmuku/package.json index 5f6fb303d..cd0360f6a 100644 --- a/packages/artplayer-plugin-danmuku/package.json +++ b/packages/artplayer-plugin-danmuku/package.json @@ -17,8 +17,15 @@ "video", "player" ], - "main": "dist/artplayer-plugin-danmuku.js", - "types": "types/artplayer-plugin-danmuku.d.ts", - "legacy": "dist/artplayer-plugin-danmuku.legacy.js", + "exports": { + ".": { + "import": "./dist/artplayer-plugin-danmuku.mjs", + "require": "./dist/artplayer-plugin-danmuku.js" + } + }, + "main": "./dist/artplayer-plugin-danmuku.js", + "module": "./dist/artplayer-plugin-danmuku.mjs", + "types": "./types/artplayer-plugin-danmuku.d.ts", + "legacy": "./dist/artplayer-plugin-danmuku.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-dash-control/package.json b/packages/artplayer-plugin-dash-control/package.json index e3d5f2f2a..dbc1e844f 100644 --- a/packages/artplayer-plugin-dash-control/package.json +++ b/packages/artplayer-plugin-dash-control/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-dash-control.esm.js", - "require": "./dist/artplayer-plugin-dash-control.js", - "default": "./dist/artplayer-plugin-dash-control.js" + ".": { + "import": "./dist/artplayer-plugin-dash-control.mjs", + "require": "./dist/artplayer-plugin-dash-control.js" + } }, - "main": "dist/artplayer-plugin-dash-control.js", - "legacy": "dist/artplayer-plugin-dash-control.legacy.js", - "module": "dist/artplayer-plugin-dash-control.esm.js", - "types": "types/artplayer-plugin-dash-control.d.ts", + "main": "./dist/artplayer-plugin-dash-control.js", + "module": "./dist/artplayer-plugin-dash-control.mjs", + "types": "./types/artplayer-plugin-dash-control.d.ts", + "legacy": "./dist/artplayer-plugin-dash-control.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-document-pip/package.json b/packages/artplayer-plugin-document-pip/package.json index eb345fd6e..d71922ab7 100644 --- a/packages/artplayer-plugin-document-pip/package.json +++ b/packages/artplayer-plugin-document-pip/package.json @@ -17,8 +17,15 @@ "video", "player" ], - "main": "dist/artplayer-plugin-document-pip.js", - "types": "types/artplayer-plugin-document-pip.d.ts", - "legacy": "dist/artplayer-plugin-document-pip.legacy.js", + "exports": { + ".": { + "import": "./dist/artplayer-plugin-document-pip.mjs", + "require": "./dist/artplayer-plugin-document-pip.js" + } + }, + "main": "./dist/artplayer-plugin-document-pip.js", + "module": "./dist/artplayer-plugin-document-pip.mjs", + "types": "./types/artplayer-plugin-document-pip.d.ts", + "legacy": "./dist/artplayer-plugin-document-pip.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-hls-control/package.json b/packages/artplayer-plugin-hls-control/package.json index 81c6fc3d2..a17fcdbce 100644 --- a/packages/artplayer-plugin-hls-control/package.json +++ b/packages/artplayer-plugin-hls-control/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-hls-control.esm.js", - "require": "./dist/artplayer-plugin-hls-control.js", - "default": "./dist/artplayer-plugin-hls-control.js" + ".": { + "import": "./dist/artplayer-plugin-hls-control.mjs", + "require": "./dist/artplayer-plugin-hls-control.js" + } }, - "main": "dist/artplayer-plugin-hls-control.js", - "legacy": "dist/artplayer-plugin-hls-control.legacy.js", - "module": "dist/artplayer-plugin-hls-control.esm.js", - "types": "types/artplayer-plugin-hls-control.d.ts", + "main": "./dist/artplayer-plugin-hls-control.js", + "module": "./dist/artplayer-plugin-hls-control.mjs", + "types": "./types/artplayer-plugin-hls-control.d.ts", + "legacy": "./dist/artplayer-plugin-hls-control.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-iframe/package.json b/packages/artplayer-plugin-iframe/package.json index bc912c771..06b9dac14 100644 --- a/packages/artplayer-plugin-iframe/package.json +++ b/packages/artplayer-plugin-iframe/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-iframe.esm.js", - "require": "./dist/artplayer-plugin-iframe.js", - "default": "./dist/artplayer-plugin-iframe.js" + ".": { + "import": "./dist/artplayer-plugin-iframe.mjs", + "require": "./dist/artplayer-plugin-iframe.js" + } }, - "main": "dist/artplayer-plugin-iframe.js", - "legacy": "dist/artplayer-plugin-iframe.legacy.js", - "module": "dist/artplayer-plugin-iframe.esm.js", - "types": "types/artplayer-plugin-iframe.d.ts", + "main": "./dist/artplayer-plugin-iframe.js", + "module": "./dist/artplayer-plugin-iframe.mjs", + "types": "./types/artplayer-plugin-iframe.d.ts", + "legacy": "./dist/artplayer-plugin-iframe.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-libass/package.json b/packages/artplayer-plugin-libass/package.json index d674da831..67faafd6d 100644 --- a/packages/artplayer-plugin-libass/package.json +++ b/packages/artplayer-plugin-libass/package.json @@ -18,14 +18,15 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-libass.esm.js", - "require": "./dist/artplayer-plugin-libass.js", - "default": "./dist/artplayer-plugin-libass.js" + ".": { + "import": "./dist/artplayer-plugin-libass.mjs", + "require": "./dist/artplayer-plugin-libass.js" + } }, - "main": "dist/artplayer-plugin-libass.js", - "legacy": "dist/artplayer-plugin-libass.legacy.js", - "module": "dist/artplayer-plugin-libass.esm.js", - "types": "types/artplayer-plugin-libass.d.ts", + "main": "./dist/artplayer-plugin-libass.js", + "module": "./dist/artplayer-plugin-libass.mjs", + "types": "./types/artplayer-plugin-libass.d.ts", + "legacy": "./dist/artplayer-plugin-libass.legacy.js", "browserslist": "last 1 Chrome version", "dependencies": { "libass-wasm": "^4.1.0" diff --git a/packages/artplayer-plugin-multiple-subtitles/package.json b/packages/artplayer-plugin-multiple-subtitles/package.json index 4a1757453..1c5c576c2 100644 --- a/packages/artplayer-plugin-multiple-subtitles/package.json +++ b/packages/artplayer-plugin-multiple-subtitles/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-multiple-subtitles.esm.js", - "require": "./dist/artplayer-plugin-multiple-subtitles.js", - "default": "./dist/artplayer-plugin-multiple-subtitles.js" + ".": { + "import": "./dist/artplayer-plugin-multiple-subtitles.mjs", + "require": "./dist/artplayer-plugin-multiple-subtitles.js" + } }, - "main": "dist/artplayer-plugin-multiple-subtitles.js", - "legacy": "dist/artplayer-plugin-multiple-subtitles.legacy.js", - "module": "dist/artplayer-plugin-multiple-subtitles.esm.js", - "types": "types/artplayer-plugin-multiple-subtitles.d.ts", + "main": "./dist/artplayer-plugin-multiple-subtitles.js", + "module": "./dist/artplayer-plugin-multiple-subtitles.mjs", + "types": "./types/artplayer-plugin-multiple-subtitles.d.ts", + "legacy": "./dist/artplayer-plugin-multiple-subtitles.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-plugin-vast/package.json b/packages/artplayer-plugin-vast/package.json index bd143b394..a8b370c7e 100644 --- a/packages/artplayer-plugin-vast/package.json +++ b/packages/artplayer-plugin-vast/package.json @@ -18,14 +18,15 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-vast.esm.js", - "require": "./dist/artplayer-plugin-vast.js", - "default": "./dist/artplayer-plugin-vast.js" + ".": { + "import": "./dist/artplayer-plugin-vast.mjs", + "require": "./dist/artplayer-plugin-vast.js" + } }, - "main": "dist/artplayer-plugin-vast.js", - "legacy": "dist/artplayer-plugin-vast.legacy.js", - "module": "dist/artplayer-plugin-vast.esm.js", - "types": "types/artplayer-plugin-vast.d.ts", + "main": "./dist/artplayer-plugin-vast.js", + "module": "./dist/artplayer-plugin-vast.mjs", + "types": "./types/artplayer-plugin-vast.d.ts", + "legacy": "./dist/artplayer-plugin-vast.legacy.js", "browserslist": "last 1 Chrome version", "dependencies": { "@glomex/vast-ima-player": "^1.21.0" diff --git a/packages/artplayer-plugin-vtt-thumbnail/package.json b/packages/artplayer-plugin-vtt-thumbnail/package.json index 1d127daaa..2daf0d944 100644 --- a/packages/artplayer-plugin-vtt-thumbnail/package.json +++ b/packages/artplayer-plugin-vtt-thumbnail/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-plugin-vtt-thumbnail.esm.js", - "require": "./dist/artplayer-plugin-vtt-thumbnail.js", - "default": "./dist/artplayer-plugin-vtt-thumbnail.js" + ".": { + "import": "./dist/artplayer-plugin-vtt-thumbnail.mjs", + "require": "./dist/artplayer-plugin-vtt-thumbnail.js" + } }, - "main": "dist/artplayer-plugin-vtt-thumbnail.js", - "legacy": "dist/artplayer-plugin-vtt-thumbnail.legacy.js", - "module": "dist/artplayer-plugin-vtt-thumbnail.esm.js", - "types": "types/artplayer-plugin-vtt-thumbnail.d.ts", + "main": "./dist/artplayer-plugin-vtt-thumbnail.js", + "module": "./dist/artplayer-plugin-vtt-thumbnail.mjs", + "types": "./types/artplayer-plugin-vtt-thumbnail.d.ts", + "legacy": "./dist/artplayer-plugin-vtt-thumbnail.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-proxy-canvas/package.json b/packages/artplayer-proxy-canvas/package.json index 00cf93dad..be665c352 100644 --- a/packages/artplayer-proxy-canvas/package.json +++ b/packages/artplayer-proxy-canvas/package.json @@ -18,13 +18,14 @@ "player" ], "exports": { - "import": "./dist/artplayer-proxy-canvas.esm.js", - "require": "./dist/artplayer-proxy-canvas.js", - "default": "./dist/artplayer-proxy-canvas.js" + ".": { + "import": "./dist/artplayer-proxy-canvas.mjs", + "require": "./dist/artplayer-proxy-canvas.js" + } }, - "main": "dist/artplayer-proxy-canvas.js", - "legacy": "dist/artplayer-proxy-canvas.legacy.js", - "module": "dist/artplayer-proxy-canvas.esm.js", - "types": "types/artplayer-proxy-canvas.d.ts", + "main": "./dist/artplayer-proxy-canvas.js", + "module": "./dist/artplayer-proxy-canvas.mjs", + "types": "./types/artplayer-proxy-canvas.d.ts", + "legacy": "./dist/artplayer-proxy-canvas.legacy.js", "browserslist": "last 1 Chrome version" } diff --git a/packages/artplayer-vitepress/docs/en/index.md b/packages/artplayer-vitepress/docs/en/index.md index bc6279f57..a8d55bb73 100644 --- a/packages/artplayer-vitepress/docs/en/index.md +++ b/packages/artplayer-vitepress/docs/en/index.md @@ -83,75 +83,75 @@ The player's size depends on the size of the container `container`, so your cont ::: code-group ```vue [Artplayer.vue] - - + + ``` ```vue [app.vue] - - + + ``` ::: @@ -166,56 +166,56 @@ Modifying `option` directly in `Vue.js` will not change the player ::: code-group ```jsx [Artplayer.jsx] -import { useEffect, useRef } from 'react'; -import Artplayer from 'artplayer'; +import Artplayer from 'artplayer' +import { useEffect, useRef } from 'react' export default function Player({ option, getInstance, ...rest }) { - const artRef = useRef(); + const artRef = useRef() - useEffect(() => { - const art = new Artplayer({ - ...option, - container: artRef.current, - }); + useEffect(() => { + const art = new Artplayer({ + ...option, + container: artRef.current, + }) - if (getInstance && typeof getInstance === 'function') { - getInstance(art); - } + if (getInstance && typeof getInstance === 'function') { + getInstance(art) + } - return () => { - if (art && art.destroy) { - art.destroy(false); - } - }; - }, []); + return () => { + if (art && art.destroy) { + art.destroy(false) + } + } + }, []) - return
; + return
} ``` ```jsx [app.jsx] -import React from 'react'; -import Artplayer from './ArtPlayer.jsx'; +import React from 'react' +import Artplayer from './ArtPlayer.jsx' function App() { - return ( -
- console.info(art)} - /> -
- ); + return ( +
+ console.info(art)} + /> +
+ ) } -export default App; +export default App ``` ::: @@ -331,7 +331,7 @@ The production build of `artplayer.js` is only compatible with the latest major For ancient browsers, you can use the `artplayer.legacy.js` file, which is compatible up to: `IE 11` ```js -import Artplayer from 'artplayer/dist/artplayer.legacy.js'; +import Artplayer from 'artplayer/dist/artplayer.legacy.js' ``` ::: code-group @@ -362,10 +362,10 @@ Refer to documentation: [browserslist](https://github.com/browserslist/browsersl ::: -Starting from `5.2.4`, `artplayer` and all plugins will also provide an `ESM` version of `js`, such as: +Starting from `5.2.6`, `artplayer` and all plugins will also provide an `ESM` version of `mjs`, such as: -- `artplayer/dist/artplayer.esm.js` -- `artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js` +- `artplayer/dist/artplayer.mjs` +- `artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs` ```html @@ -385,7 +385,7 @@ Starting from `5.2.4`, `artplayer` and all plugins will also provide an `ESM` ve @@ -440,4 +440,4 @@ Currently, the determination of mobile devices is not accurate. Sometimes, you m You need to modify it before import the `Artplayer` for it to take effect -::: \ No newline at end of file +::: diff --git a/packages/artplayer-vitepress/docs/index.md b/packages/artplayer-vitepress/docs/index.md index 19136944d..1bebb359f 100644 --- a/packages/artplayer-vitepress/docs/index.md +++ b/packages/artplayer-vitepress/docs/index.md @@ -65,7 +65,7 @@ https://unpkg.com/artplayer/dist/artplayer.js ``` -::: +::: ::: warning 提示 @@ -84,75 +84,75 @@ https://unpkg.com/artplayer/dist/artplayer.js ::: code-group ```vue [Artplayer.vue] - - + + ``` ```vue [app.vue] - - + + ``` ::: @@ -168,56 +168,56 @@ export default { ::: code-group ```jsx [Artplayer.jsx] -import { useEffect, useRef } from 'react'; -import Artplayer from 'artplayer'; +import Artplayer from 'artplayer' +import { useEffect, useRef } from 'react' export default function Player({ option, getInstance, ...rest }) { - const artRef = useRef(); + const artRef = useRef() - useEffect(() => { - const art = new Artplayer({ - ...option, - container: artRef.current, - }); + useEffect(() => { + const art = new Artplayer({ + ...option, + container: artRef.current, + }) - if (getInstance && typeof getInstance === 'function') { - getInstance(art); - } + if (getInstance && typeof getInstance === 'function') { + getInstance(art) + } - return () => { - if (art && art.destroy) { - art.destroy(false); - } - }; - }, []); + return () => { + if (art && art.destroy) { + art.destroy(false) + } + } + }, []) - return
; + return
} ``` ```jsx [app.jsx] -import React from 'react'; -import Artplayer from './ArtPlayer.jsx'; +import React from 'react' +import Artplayer from './ArtPlayer.jsx' function App() { - return ( -
- console.info(art)} - /> -
- ); + return ( +
+ console.info(art)} + /> +
+ ) } -export default App; +export default App ``` ::: @@ -275,7 +275,7 @@ const art = new Artplayer(option); ## JavaScript -有时你的 `js` 文件会丢失 `TypeScript` 的类型提示,这时候你可以手动导入类型 +有时你的 `js` 文件会丢失 `TypeScript` 的类型提示,这时候你可以手动导入类型 变量: @@ -336,7 +336,7 @@ const art8 = new Artplayer(option); 对于古老的浏览器,可以使用 `artplayer.legacy.js` 文件,可以兼容到:`IE 11` ```js -import Artplayer from 'artplayer/dist/artplayer.legacy.js'; +import Artplayer from 'artplayer/dist/artplayer.legacy.js' ``` ::: code-group @@ -367,10 +367,10 @@ https://unpkg.com/artplayer/dist/artplayer.legacy.js ::: -从 `5.2.4` 开始,`artplayer`和所有插件还会提供一个`ESM`版本的`js`,如: +从 `5.2.6` 开始,`artplayer` 和所有插件还会提供一个 `ESM` 版本的 `mjs`,如: -- `artplayer/dist/artplayer.esm.js` -- `artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.esm.js` +- `artplayer/dist/artplayer.mjs` +- `artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs` ```html @@ -445,4 +445,4 @@ https://unpkg.com/artplayer/dist/artplayer.legacy.js 你需要在引入 `Artplayer` 依赖前来修改它才会生效 -::: \ No newline at end of file +::: diff --git a/scripts/build.js b/scripts/build.js index b55026da2..58c07fae4 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -17,16 +17,24 @@ function compressString(input) { .trim() } -async function build(name, targetName) { +async function build(name, targetName, clean = false) { const projectPackageJson = path.join(projects[name], 'package.json') const { version } = JSON.parse(fs.readFileSync(projectPackageJson, 'utf-8')) process.chdir(projects[name]) + const distDir = path.join(projects[name], 'dist') + + // 👇 构建前清空 dist,只执行一次 + if (clean && fs.existsSync(distDir)) { + fs.rmSync(distDir, { recursive: true, force: true }) + console.log(`🗑️ Cleaned ${distDir}`) + } + const targets = { main: { context: 'browser', - distDir: path.join(projects[name], 'dist'), + distDir, sourceMap: false, outputFormat: 'global', isLibrary: true, @@ -36,7 +44,7 @@ async function build(name, targetName) { }, legacy: { context: 'browser', - distDir: path.join(projects[name], 'dist'), + distDir, sourceMap: false, outputFormat: 'global', isLibrary: true, @@ -46,7 +54,7 @@ async function build(name, targetName) { }, esm: { context: 'browser', - distDir: path.join(projects[name], 'dist'), + distDir, sourceMap: true, outputFormat: 'esmodule', isLibrary: true, @@ -57,9 +65,9 @@ async function build(name, targetName) { } const names = { - main: name, - legacy: `${name}.legacy`, - esm: `${name}.esm`, + main: `${name}.js`, // ✅ 保留 .js 后缀 + legacy: `${name}.legacy.js`, // ✅ 保留 .js 后缀 + esm: `${name}.mjs`, // ✅ ESM 用 .mjs } const entryFile = path.join(projects[name], 'src/index.js') @@ -88,8 +96,8 @@ async function build(name, targetName) { const { bundleGraph, buildTime } = await bundler.run() const bundles = bundleGraph.getBundles() - const filePath = path.join(projects[name], 'dist/index.js') - const newFilePath = path.join(projects[name], `dist/${names[targetName]}.js`) + const filePath = path.join(distDir, 'index.js') + const newFilePath = path.join(distDir, names[targetName]) const code = fs.readFileSync(filePath, 'utf-8') fs.writeFileSync(filePath, banner + compressString(code)) @@ -98,21 +106,24 @@ async function build(name, targetName) { await cpy(newFilePath, compiledPath) if (targetName === 'esm') { - const jsFile = path.join(projects[name], `dist/${names.esm}.js`) + const jsFile = newFilePath const oldMapName = 'index.js.map' - const newMapName = `${names.esm}.js.map` + const newMapName = `${names.esm}.map` - const oldMapPath = path.join(projects[name], 'dist', oldMapName) - const newMapPath = path.join(projects[name], 'dist', newMapName) + const oldMapPath = path.join(distDir, oldMapName) + const newMapPath = path.join(distDir, newMapName) if (fs.existsSync(oldMapPath)) { fs.renameSync(oldMapPath, newMapPath) } let jsContent = fs.readFileSync(jsFile, 'utf8') - jsContent = jsContent.replace(/\/\/# sourceMappingURL=.*\.js\.map/, `\n//# sourceMappingURL=${newMapName}`) + jsContent = jsContent.replace( + /\/\/# sourceMappingURL=.*\.js\.map/, + `\n//# sourceMappingURL=${path.basename(newMapName)}`, + ) fs.writeFileSync(jsFile, jsContent) await cpy(newMapPath, compiledPath) - await cpy(newFilePath, compiledPath) + await cpy(jsFile, compiledPath) } console.log( @@ -126,7 +137,7 @@ async function build(name, targetName) { async function runBuild() { if (process.argv.pop() === 'all') { const bundles = Object.keys(projects).map(name => async () => { - await build(name, 'main') + await build(name, 'main', true) // 👈 第一次清理 await build(name, 'legacy') await build(name, 'esm') }) @@ -147,7 +158,7 @@ async function runBuild() { }) if (response.value) { - await build(response.value, 'main') + await build(response.value, 'main', true) // 👈 只清一次 await build(response.value, 'legacy') await build(response.value, 'esm') } diff --git a/test/esm.test.js b/test/esm.test.js new file mode 100644 index 000000000..a8c8449bc --- /dev/null +++ b/test/esm.test.js @@ -0,0 +1,3 @@ +import artplayerPluginDanmuku from 'artplayer-plugin-danmuku' + +console.log(typeof artplayerPluginDanmuku)