diff --git a/docs/compiled/artplayer-plugin-ads.mjs b/docs/compiled/artplayer-plugin-ads.mjs index 07063a412..bb12bd16c 100644 --- a/docs/compiled/artplayer-plugin-ads.mjs +++ b/docs/compiled/artplayer-plugin-ads.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,n,l,t,i,a,r,o){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},p="function"==typeof d[t]&&d[t],s=p.i||{},u=p.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function y(n,l){if(!u[n]){if(!e[n]){if(i[n])return i[n];var a="function"==typeof d[t]&&d[t];if(!l&&a)return a(n,!0);if(p)return p(n,!0);if(c&&"string"==typeof n)return c(n);var r=Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}s.resolve=function(l){var t=e[n][1][l];return null!=t?t:l},s.cache={};var o=u[n]=new y.Module(n);e[n][0].call(o.exports,s,o,o.exports,d)}return u[n].exports;function s(e){var n=s.resolve(e);return!1===n?{}:y(n)}}y.isParcelRequire=!0,y.Module=function(e){this.id=e,this.bundle=y,this.require=c,this.exports={}},y.modules=e,y.cache=u,y.parent=p,y.distDir=void 0,y.publicUrl=void 0,y.devServer=void 0,y.i=s,y.register=function(n,l){e[n]=[function(e,n){n.exports=l},{}]},Object.defineProperty(y,"root",{get:function(){return d[t]}}),d[t]=y;for(var f=0;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.mjs.map \ No newline at end of file +!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 O(e,n){return n.replace("%s",e)}function A(){P=!0,n.play(),e.video&&m.pause(),g(n.template.$ads,"display","none"),n.emit("artplayerPluginAds:skip",e)}function M(){P||(j=setTimeout(()=>{D+=1;let n=e.playDuration-D;n>=1?x.innerHTML=O(n,e.i18n.canBeClosed):(x.innerHTML=e.i18n.close,k||(k=!0)),h.innerHTML=O(e.totalDuration-D,e.i18n.countdown),D>=e.totalDuration?A():M()},1e3))}function _(){P||clearTimeout(j)}function q(){$||($=!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:O(e.playDuration,e.i18n.canBeClosed)}
${O(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&&A()});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",A),n.proxy(m,"loadedmetadata",()=>{M(),m.play(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")})):(M(),g(v,"display","flex"),g(b,"display","flex"),g(w,"display","none")),n.on("document:visibilitychange",()=>{document.hidden?_():M()}))}return n.on("ready",()=>{n.once("play",q),n.once("video:playing",q)}),{name:"artplayerPluginAds",skip:A,pause:_,play:M}}}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":"5d7x0","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"5d7x0":[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}"},{}],loqXi:[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})}},{}]},["fZ8n3"],"fZ8n3","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("fZ8n3");export{e as default}; \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-ads.mjs.map b/docs/compiled/artplayer-plugin-ads.mjs.map deleted file mode 100644 index 9db957c7a..000000000 --- a/docs/compiled/artplayer-plugin-ads.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,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EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-ads/src/index.js","node_modules/@parcel/runtime-js/lib/bundles/runtime-8bdb8791472ee09f.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"2Uydo\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginAds);\nvar _styleLess = require(\"bundle-text:./style.less\");\nvar _styleLessDefault = parcelHelpers.interopDefault(_styleLess);\nfunction checkVersion(art) {\n const { version, utils: { errorHandle } } = art.constructor;\n const arr = version.split('.').map(Number);\n const major = arr[0];\n const minor = arr[1] / 100;\n errorHandle(major + minor >= 5, `Artplayer.js@${version} is not compatible the artplayerPluginAds@${artplayerPluginAds.version}. Please update it to version Artplayer.js@5.x.x`);\n}\nfunction artplayerPluginAds(option) {\n return (art)=>{\n checkVersion(art);\n const { template: { $player }, icons: { volume, volumeClose, fullscreenOn, fullscreenOff, loading }, constructor: { validator, utils: { query, append, setStyle } } } = art;\n option = validator({\n html: '',\n video: '',\n url: '',\n playDuration: 5,\n totalDuration: 10,\n muted: false,\n i18n: {\n close: \"\\u5173\\u95ED\\u5E7F\\u544A\",\n countdown: \"%s\\u79D2\",\n detail: \"\\u67E5\\u770B\\u8BE6\\u60C5\",\n canBeClosed: \"%s\\u79D2\\u540E\\u53EF\\u5173\\u95ED\\u5E7F\\u544A\"\n },\n ...option\n }, {\n html: '?string',\n video: '?string',\n url: '?string',\n playDuration: 'number',\n totalDuration: 'number',\n muted: '?boolean',\n i18n: {\n close: 'string',\n countdown: 'string',\n detail: 'string',\n canBeClosed: 'string'\n }\n });\n let $ads = null;\n let $timer = null;\n let $close = null;\n let $countdown = null;\n let $control = null;\n let $loading = null;\n let time = 0;\n let timer = null;\n let isEnd = false;\n let isInit = false;\n let isCanClose = false;\n function getI18n(val, str) {\n return str.replace('%s', val);\n }\n function skip() {\n isEnd = true;\n art.play();\n if (option.video) $ads.pause();\n setStyle(art.template.$ads, 'display', 'none');\n art.emit('artplayerPluginAds:skip', option);\n }\n function play() {\n if (isEnd) return;\n timer = setTimeout(()=>{\n time += 1;\n const playDuration = option.playDuration - time;\n if (playDuration >= 1) $close.innerHTML = getI18n(playDuration, option.i18n.canBeClosed);\n else {\n $close.innerHTML = option.i18n.close;\n if (!isCanClose) isCanClose = true;\n }\n $countdown.innerHTML = getI18n(option.totalDuration - time, option.i18n.countdown);\n if (time >= option.totalDuration) skip();\n else play();\n }, 1000);\n }\n function pause() {\n if (isEnd) return;\n clearTimeout(timer);\n }\n function show() {\n art.template.$ads = append($player, '
');\n $ads = append(art.template.$ads, option.video ? `` : `
${option.html}
`);\n $loading = append(art.template.$ads, '
');\n append($loading, loading);\n $timer = append(art.template.$ads, `
\n
${option.playDuration <= 0 ? option.i18n.close : getI18n(option.playDuration, option.i18n.canBeClosed)}
\n
${getI18n(option.totalDuration, option.i18n.countdown)}
\n
`);\n $close = query('.artplayer-plugin-ads-close', $timer);\n $countdown = query('.artplayer-plugin-ads-countdown', $timer);\n if (option.playDuration >= option.totalDuration) setStyle($close, 'display', 'none');\n art.proxy($close, 'click', ()=>{\n if (isCanClose) skip();\n });\n $control = append(art.template.$ads, `
\n
${option.i18n.detail}
\n
\n
\n
`);\n const $detail = query('.artplayer-plugin-ads-detail', $control);\n const $muted = query('.artplayer-plugin-ads-muted', $control);\n const $fullscreen = query('.artplayer-plugin-ads-fullscreen', $control);\n if (option.url) art.proxy($detail, 'click', ()=>{\n window.open(option.url);\n art.emit('artplayerPluginAds:click', option);\n });\n else setStyle($detail, 'display', 'none');\n if (option.video) {\n const $volume = append($muted, volume);\n const $volumeClose = append($muted, volumeClose);\n setStyle($volumeClose, 'display', 'none');\n // If the ad was set to muted initially, match the icon\n if (option.muted) {\n $ads.muted = true;\n setStyle($volume, 'display', 'none');\n setStyle($volumeClose, 'display', 'inline-flex');\n }\n art.proxy($muted, 'click', ()=>{\n $ads.muted = !$ads.muted;\n if ($ads.muted) {\n setStyle($volume, 'display', 'none');\n setStyle($volumeClose, 'display', 'inline-flex');\n } else {\n setStyle($volume, 'display', 'inline-flex');\n setStyle($volumeClose, 'display', 'none');\n }\n });\n } else setStyle($muted, 'display', 'none');\n const $fullscreenOn = append($fullscreen, fullscreenOn);\n const $fullscreenOff = append($fullscreen, fullscreenOff);\n setStyle($fullscreenOff, 'display', 'none');\n art.proxy($fullscreen, 'click', ()=>{\n art.fullscreen = !art.fullscreen;\n if (art.fullscreen) {\n setStyle($fullscreenOn, 'display', 'inline-flex');\n setStyle($fullscreenOff, 'display', 'none');\n } else {\n setStyle($fullscreenOn, 'display', 'none');\n setStyle($fullscreenOff, 'display', 'inline-flex');\n }\n });\n art.proxy($ads, 'click', ()=>{\n if (option.url) window.open(option.url);\n art.emit('artplayerPluginAds:click', option);\n });\n }\n function init() {\n if (isInit) return;\n isInit = true;\n show();\n art.pause();\n if (option.video) {\n art.proxy($ads, 'error', skip);\n art.proxy($ads, 'loadedmetadata', ()=>{\n play();\n $ads.play();\n setStyle($timer, 'display', 'flex');\n setStyle($control, 'display', 'flex');\n setStyle($loading, 'display', 'none');\n });\n } else {\n play();\n setStyle($timer, 'display', 'flex');\n setStyle($control, 'display', 'flex');\n setStyle($loading, 'display', 'none');\n }\n art.on('document:visibilitychange', ()=>{\n if (document.hidden) pause();\n else play();\n });\n }\n art.on('ready', ()=>{\n art.once('play', init);\n art.once('video:playing', init);\n });\n return {\n name: 'artplayerPluginAds',\n skip,\n pause,\n play\n };\n };\n}\nif (typeof document !== 'undefined') {\n if (!document.getElementById('artplayer-plugin-ads')) {\n const $style = document.createElement('style');\n $style.id = 'artplayer-plugin-ads';\n $style.textContent = (0, _styleLessDefault.default);\n document.head.appendChild($style);\n }\n}\nif (typeof window !== 'undefined') window.artplayerPluginAds = artplayerPluginAds;\n\n},{\"bundle-text:./style.less\":\"1GXMH\",\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"1GXMH\":[function(require,module,exports,__globalThis) {\nmodule.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}\";\n\n},{}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"2Uydo\"], \"2Uydo\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"2Uydo\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","import style from 'bundle-text:./style.less'\n\nfunction checkVersion(art) {\n const {\n version,\n utils: { errorHandle },\n } = art.constructor\n const arr = version.split('.').map(Number)\n const major = arr[0]\n const minor = arr[1] / 100\n errorHandle(\n major + minor >= 5,\n `Artplayer.js@${version} is not compatible the artplayerPluginAds@${artplayerPluginAds.version}. Please update it to version Artplayer.js@5.x.x`,\n )\n}\n\nexport default function artplayerPluginAds(option) {\n return (art) => {\n checkVersion(art)\n\n const {\n template: { $player },\n icons: { volume, volumeClose, fullscreenOn, fullscreenOff, loading },\n constructor: {\n validator,\n utils: { query, append, setStyle },\n },\n } = art\n\n option = validator(\n {\n html: '',\n video: '',\n url: '',\n playDuration: 5,\n totalDuration: 10,\n muted: false,\n i18n: {\n close: '关闭广告',\n countdown: '%s秒',\n detail: '查看详情',\n canBeClosed: '%s秒后可关闭广告',\n },\n ...option,\n },\n {\n html: '?string',\n video: '?string',\n url: '?string',\n playDuration: 'number',\n totalDuration: 'number',\n muted: '?boolean',\n i18n: {\n close: 'string',\n countdown: 'string',\n detail: 'string',\n canBeClosed: 'string',\n },\n },\n )\n\n let $ads = null\n let $timer = null\n let $close = null\n let $countdown = null\n let $control = null\n let $loading = null\n\n let time = 0\n let timer = null\n let isEnd = false\n let isInit = false\n let isCanClose = false\n\n function getI18n(val, str) {\n return str.replace('%s', val)\n }\n\n function skip() {\n isEnd = true\n art.play()\n if (option.video)\n $ads.pause()\n setStyle(art.template.$ads, 'display', 'none')\n art.emit('artplayerPluginAds:skip', option)\n }\n\n function play() {\n if (isEnd)\n return\n\n timer = setTimeout(() => {\n time += 1\n\n const playDuration = option.playDuration - time\n if (playDuration >= 1) {\n $close.innerHTML = getI18n(playDuration, option.i18n.canBeClosed)\n }\n else {\n $close.innerHTML = option.i18n.close\n if (!isCanClose) {\n isCanClose = true\n }\n }\n\n $countdown.innerHTML = getI18n(option.totalDuration - time, option.i18n.countdown)\n\n if (time >= option.totalDuration) {\n skip()\n }\n else {\n play()\n }\n }, 1000)\n }\n\n function pause() {\n if (isEnd)\n return\n clearTimeout(timer)\n }\n\n function show() {\n art.template.$ads = append($player, '
')\n\n $ads = append(\n art.template.$ads,\n option.video\n ? ``\n : `
${option.html}
`,\n )\n\n $loading = append(art.template.$ads, '
')\n append($loading, loading)\n\n $timer = append(\n art.template.$ads,\n `
\n
${\n option.playDuration <= 0\n ? option.i18n.close\n : getI18n(option.playDuration, option.i18n.canBeClosed)\n }
\n
${getI18n(\n option.totalDuration,\n option.i18n.countdown,\n )}
\n
`,\n )\n\n $close = query('.artplayer-plugin-ads-close', $timer)\n $countdown = query('.artplayer-plugin-ads-countdown', $timer)\n\n if (option.playDuration >= option.totalDuration) {\n setStyle($close, 'display', 'none')\n }\n\n art.proxy($close, 'click', () => {\n if (isCanClose) {\n skip()\n }\n })\n\n $control = append(\n art.template.$ads,\n `
\n
${option.i18n.detail}
\n
\n
\n
`,\n )\n\n const $detail = query('.artplayer-plugin-ads-detail', $control)\n const $muted = query('.artplayer-plugin-ads-muted', $control)\n const $fullscreen = query('.artplayer-plugin-ads-fullscreen', $control)\n\n if (option.url) {\n art.proxy($detail, 'click', () => {\n window.open(option.url)\n art.emit('artplayerPluginAds:click', option)\n })\n }\n else {\n setStyle($detail, 'display', 'none')\n }\n\n if (option.video) {\n const $volume = append($muted, volume)\n const $volumeClose = append($muted, volumeClose)\n setStyle($volumeClose, 'display', 'none')\n\n // If the ad was set to muted initially, match the icon\n if (option.muted) {\n $ads.muted = true\n setStyle($volume, 'display', 'none')\n setStyle($volumeClose, 'display', 'inline-flex')\n }\n\n art.proxy($muted, 'click', () => {\n $ads.muted = !$ads.muted\n if ($ads.muted) {\n setStyle($volume, 'display', 'none')\n setStyle($volumeClose, 'display', 'inline-flex')\n }\n else {\n setStyle($volume, 'display', 'inline-flex')\n setStyle($volumeClose, 'display', 'none')\n }\n })\n }\n else {\n setStyle($muted, 'display', 'none')\n }\n\n const $fullscreenOn = append($fullscreen, fullscreenOn)\n const $fullscreenOff = append($fullscreen, fullscreenOff)\n setStyle($fullscreenOff, 'display', 'none')\n\n art.proxy($fullscreen, 'click', () => {\n art.fullscreen = !art.fullscreen\n if (art.fullscreen) {\n setStyle($fullscreenOn, 'display', 'inline-flex')\n setStyle($fullscreenOff, 'display', 'none')\n }\n else {\n setStyle($fullscreenOn, 'display', 'none')\n setStyle($fullscreenOff, 'display', 'inline-flex')\n }\n })\n\n art.proxy($ads, 'click', () => {\n if (option.url)\n window.open(option.url)\n art.emit('artplayerPluginAds:click', option)\n })\n }\n\n function init() {\n if (isInit)\n return\n isInit = true\n\n show()\n art.pause()\n\n if (option.video) {\n art.proxy($ads, 'error', skip)\n art.proxy($ads, 'loadedmetadata', () => {\n play()\n $ads.play()\n setStyle($timer, 'display', 'flex')\n setStyle($control, 'display', 'flex')\n setStyle($loading, 'display', 'none')\n })\n }\n else {\n play()\n setStyle($timer, 'display', 'flex')\n setStyle($control, 'display', 'flex')\n setStyle($loading, 'display', 'none')\n }\n\n art.on('document:visibilitychange', () => {\n if (document.hidden) {\n pause()\n }\n else {\n play()\n }\n })\n }\n\n art.on('ready', () => {\n art.once('play', init)\n art.once('video:playing', init)\n })\n\n return {\n name: 'artplayerPluginAds',\n skip,\n pause,\n play,\n }\n }\n}\n\nif (typeof document !== 'undefined') {\n if (!document.getElementById('artplayer-plugin-ads')) {\n const $style = document.createElement('style')\n $style.id = 'artplayer-plugin-ads'\n $style.textContent = style\n document.head.appendChild($style)\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginAds = artplayerPluginAds\n}\n","module.exports = \"e140a0ba961ecae5\";","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","defineInteropFlag","export","artplayerPluginAds","_styleLess","_styleLessDefault","interopDefault","option","art","version","utils","errorHandle","arr","split","map","Number","major","template","$player","icons","volume","volumeClose","fullscreenOn","fullscreenOff","loading","validator","query","append","setStyle","html","video","url","playDuration","totalDuration","muted","i18n","close","countdown","detail","canBeClosed","$ads","$timer","$close","$countdown","$control","$loading","time","timer","isEnd","isInit","isCanClose","getI18n","val","str","replace","skip","play","pause","emit","setTimeout","innerHTML","clearTimeout","init","show","proxy","$detail","$muted","$fullscreen","open","$volume","$volumeClose","$fullscreenOn","$fullscreenOff","fullscreen","on","document","hidden","once","getElementById","$style","createElement","textContent","default","head","appendChild","a","__esModule","value","exportAll","source","dest","keys","forEach","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-ambilight.mjs b/docs/compiled/artplayer-plugin-ambilight.mjs index 7cb8a2201..5df8029fc 100644 --- a/docs/compiled/artplayer-plugin-ambilight.mjs +++ b/docs/compiled/artplayer-plugin-ambilight.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * 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.mjs.map \ No newline at end of file +!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||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(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(p&&"string"==typeof r)return p(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 s.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?{}:s(r)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=p,this.exports={}},s.modules=e,s.cache=c,s.parent=a,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=d,s.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(s,"root",{get:function(){return f[n]}}),f[n]=s;for(var m=0;m{var t,n,o,i,l,u,f;let{$video:a}=r.template,{createElement:d,addClass:c,setStyles:p}=r.constructor.utils,{blur:s="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),p(n,{position:"absolute",top:0,left:0,zIndex:9,inset:0,display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gridTemplateRows:"1fr 1fr 1fr"}),i=b,l=s,u=m,f=y,i.forEach(e=>{p(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":"loqXi"}],loqXi:[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})}},{}]},["4BFTD"],"4BFTD","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("4BFTD");export{e as default}; \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-ambilight.mjs.map b/docs/compiled/artplayer-plugin-ambilight.mjs.map deleted file mode 100644 index 1ca2790c7..000000000 --- a/docs/compiled/artplayer-plugin-ambilight.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,C,I,E,M,C,G,C,C,E,C,E,C,I,C,E,O,C,E,E,E,O,C,E,C,O,C,C,E,C,O,C,S,E,C,E,I,E,E,O,C,G,M,A,C,I,E,C,E,E,E,C,C,E,e,C,C,E,E,M,C,S,C,E,I,C,E,C,E,I,C,M,C,E,I,C,O,C,E,I,C,O,C,C,C,E,E,O,C,E,E,K,C,E,E,M,C,E,E,O,C,K,E,E,S,C,K,E,E,S,C,K,E,E,C,C,E,E,Q,C,S,C,C,C,E,C,C,E,C,C,S,C,C,C,E,E,O,C,C,E,C,E,A,E,O,c,C,E,O,C,I,W,O,C,C,E,A,C,G,C,C,E,C,E,I,I,E,E,E,E,M,C,I,E,C,C,E,E,G,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EAAE,CAAC,QAAS,GAChB,EAAI,EAAE,CAAC,UAAW,GAEX,CACL,KAAM,2BACN,MAAA,EACA,KAAA,CACF,CA6EF,CACF,C,E,iB,C,GAlHwB,EAAA,MAAA,CAAA,EAAA,UAAA,IAAA,GAoHpB,AAAkB,aAAlB,OAAO,QACT,CAAA,OAAO,wBAAwB,CAAG,CADpC,C,E,C,iD,O,E,C,Q,C,S,C,C,C,C,C,C,C,ECpHA,EAAQ,cAAc,CAAG,SAAU,CAAC,EAClC,OAAO,GAAK,EAAE,UAAU,CAAG,EAAI,CAAC,QAAS,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-ambilight/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"9P7rs\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginAmbilight);\nfunction artplayerPluginAmbilight(option = {}) {\n return (art)=>{\n const { $video } = art.template;\n const { createElement, addClass, setStyles } = art.constructor.utils;\n const { blur = '50px', opacity = 0.5, frequency = 10, duration = 0.3 } = option;\n const $ambilight = createElement('div');\n const gridItems = createGridItems($ambilight);\n setupAmbilight($ambilight, $video);\n setupGridItems(gridItems, blur, opacity, duration);\n const updateColors = createColorUpdater($video, gridItems, frequency);\n let animationFrameId = null;\n function start() {\n if (!animationFrameId) updateColors();\n }\n function stop() {\n if (animationFrameId) {\n cancelAnimationFrame(animationFrameId);\n animationFrameId = null;\n }\n }\n art.on('ready', start);\n art.on('destroy', stop);\n return {\n name: 'artplayerPluginAmbilight',\n start,\n stop\n };\n function createGridItems($ambilight) {\n $ambilight.innerHTML = Array.from({\n length: 9\n }).fill('
').join('');\n return Array.from($ambilight.children);\n }\n function setupAmbilight($ambilight, $video) {\n addClass($ambilight, 'artplayer-plugin-ambilight');\n $video.parentNode.insertBefore($ambilight, $video);\n setStyles($ambilight, {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 9,\n inset: 0,\n display: 'grid',\n gridTemplateColumns: '1fr 1fr 1fr',\n gridTemplateRows: '1fr 1fr 1fr'\n });\n }\n function setupGridItems(gridItems, blur, opacity, duration) {\n gridItems.forEach(($item)=>{\n setStyles($item, {\n opacity,\n filter: `blur(${blur})`,\n transition: `background-color ${duration}s ease`\n });\n });\n }\n function createColorUpdater($video, gridItems, frequency) {\n const canvas = createElement('canvas');\n const ctx = canvas.getContext('2d');\n canvas.width = 3;\n canvas.height = 3;\n function getAverageColor(x, y, w, h) {\n ctx.drawImage($video, x, y, w, h, 0, 0, 1, 1);\n const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;\n return `rgb(${r}, ${g}, ${b})`;\n }\n let lastUpdateTime = 0;\n return function updateColors() {\n const now = performance.now();\n if (now - lastUpdateTime < 1000 / frequency || !art.playing) {\n animationFrameId = requestAnimationFrame(updateColors);\n return;\n }\n lastUpdateTime = now;\n const w = $video.videoWidth / 3;\n const h = $video.videoHeight / 3;\n const colors = [\n [\n 0,\n 0\n ],\n [\n w,\n 0\n ],\n [\n 2 * w,\n 0\n ],\n [\n 0,\n h\n ],\n [\n w,\n h\n ],\n [\n 2 * w,\n h\n ],\n [\n 0,\n 2 * h\n ],\n [\n w,\n 2 * h\n ],\n [\n 2 * w,\n 2 * h\n ]\n ].map(([x, y])=>getAverageColor(x, y, w, h));\n gridItems.forEach(($item, index)=>{\n $item.style.backgroundColor = colors[index];\n });\n animationFrameId = requestAnimationFrame(updateColors);\n };\n }\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginAmbilight = artplayerPluginAmbilight;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"9P7rs\"], \"9P7rs\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"9P7rs\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","export default function artplayerPluginAmbilight(option = {}) {\n return (art) => {\n const { $video } = art.template\n const { createElement, addClass, setStyles } = art.constructor.utils\n const { blur = '50px', opacity = 0.5, frequency = 10, duration = 0.3 } = option\n\n const $ambilight = createElement('div')\n const gridItems = createGridItems($ambilight)\n\n setupAmbilight($ambilight, $video)\n setupGridItems(gridItems, blur, opacity, duration)\n\n const updateColors = createColorUpdater($video, gridItems, frequency)\n\n let animationFrameId = null\n\n function start() {\n if (!animationFrameId) {\n updateColors()\n }\n }\n\n function stop() {\n if (animationFrameId) {\n cancelAnimationFrame(animationFrameId)\n animationFrameId = null\n }\n }\n\n art.on('ready', start)\n art.on('destroy', stop)\n\n return {\n name: 'artplayerPluginAmbilight',\n start,\n stop,\n }\n\n function createGridItems($ambilight) {\n $ambilight.innerHTML = Array.from({ length: 9 }).fill('
').join('')\n return Array.from($ambilight.children)\n }\n\n function setupAmbilight($ambilight, $video) {\n addClass($ambilight, 'artplayer-plugin-ambilight')\n $video.parentNode.insertBefore($ambilight, $video)\n setStyles($ambilight, {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 9,\n inset: 0,\n display: 'grid',\n gridTemplateColumns: '1fr 1fr 1fr',\n gridTemplateRows: '1fr 1fr 1fr',\n })\n }\n\n function setupGridItems(gridItems, blur, opacity, duration) {\n gridItems.forEach(($item) => {\n setStyles($item, {\n opacity,\n filter: `blur(${blur})`,\n transition: `background-color ${duration}s ease`,\n })\n })\n }\n\n function createColorUpdater($video, gridItems, frequency) {\n const canvas = createElement('canvas')\n const ctx = canvas.getContext('2d')\n canvas.width = 3\n canvas.height = 3\n\n function getAverageColor(x, y, w, h) {\n ctx.drawImage($video, x, y, w, h, 0, 0, 1, 1)\n const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data\n return `rgb(${r}, ${g}, ${b})`\n }\n\n let lastUpdateTime = 0\n\n return function updateColors() {\n const now = performance.now()\n if (now - lastUpdateTime < 1000 / frequency || !art.playing) {\n animationFrameId = requestAnimationFrame(updateColors)\n return\n }\n\n lastUpdateTime = now\n\n const w = $video.videoWidth / 3\n const h = $video.videoHeight / 3\n\n const colors = [\n [0, 0],\n [w, 0],\n [2 * w, 0],\n [0, h],\n [w, h],\n [2 * w, h],\n [0, 2 * h],\n [w, 2 * h],\n [2 * w, 2 * h],\n ].map(([x, y]) => getAverageColor(x, y, w, h))\n\n gridItems.forEach(($item, index) => {\n $item.style.backgroundColor = colors[index]\n })\n\n animationFrameId = requestAnimationFrame(updateColors)\n }\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginAmbilight = artplayerPluginAmbilight\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginAmbilight","option","art","$ambilight","$video","gridItems","blur","opacity","duration","template","createElement","addClass","setStyles","utils","frequency","innerHTML","Array","from","fill","join","children","parentNode","insertBefore","position","top","left","zIndex","inset","display","gridTemplateColumns","gridTemplateRows","forEach","$item","filter","transition","updateColors","createColorUpdater","canvas","ctx","getContext","width","height","lastUpdateTime","now","performance","playing","animationFrameId","requestAnimationFrame","w","videoWidth","h","videoHeight","colors","map","y","getAverageColor","drawImage","r","g","b","getImageData","data","index","style","backgroundColor","start","stop","cancelAnimationFrame","on","defineInteropFlag","export","interopDefault","a","__esModule","default","value","exportAll","source","dest","keys","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-asr.mjs b/docs/compiled/artplayer-plugin-asr.mjs index 5630ef3ff..4d03fdcce 100644 --- a/docs/compiled/artplayer-plugin-asr.mjs +++ b/docs/compiled/artplayer-plugin-asr.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * 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.mjs.map \ No newline at end of file +!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 j(){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 A(e.video)),m)return b=l.createMediaStreamSource(m)}catch(e){console.warn("[artplayerPluginAsr] MediaStream fallback failed:",e)}return null}async function A(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 U(){if(!i)try{await x();let e=await j();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",U),e.on("pause",P),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":"8jqel","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],"8jqel":[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))}"},{}],loqXi:[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})}},{}]},["ejGkt"],"ejGkt","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("ejGkt");export{e as default}; \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-asr.mjs.map b/docs/compiled/artplayer-plugin-asr.mjs.map deleted file mode 100644 index 880c51ee1..000000000 --- a/docs/compiled/artplayer-plugin-asr.mjs.map +++ /dev/null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D,IAAM,EAAS,SAAS,aAAa,CAAC,QACtC,CAAA,EAAO,EAAE,CAAG,uBACZ,EAAO,WAAW,CAAG,EAAA,OAAK,CAC1B,SAAS,IAAI,CAAC,WAAW,CAAC,EAC5B,CAGE,AAAkB,aAAlB,OAAO,QACT,CAAA,OAAO,kBAAkB,CAAG,CAD9B,C,E,C,2B,Q,iD,O,E,C,M,C,S,C,C,C,C,C,C,C,EC5SA,EAAO,OAAO,CAAG,qvB,E,C,E,C,Q,C,S,C,C,C,C,C,C,C,ECAjB,EAAQ,cAAc,CAAG,SAAU,CAAC,EAClC,OAAO,GAAK,EAAE,UAAU,CAAG,EAAI,CAAC,QAAS,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-asr/src/index.js","node_modules/@parcel/runtime-js/lib/bundles/runtime-8d01a8f56d551fc8.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"40eeC\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginAsr);\nvar _styleLess = require(\"bundle-text:./style.less\");\nvar _styleLessDefault = parcelHelpers.interopDefault(_styleLess);\nfunction artplayerPluginAsr(option = {}) {\n const { length = 3, interval = 100, sampleRate = 16000, autoHideTimeout = 10000, onAudioChunk = ()=>null } = option;\n return (art)=>{\n let started = false;\n let audioCtx = null;\n let sourceNode = null;\n let recorderNode = null;\n let gainNode = null;\n let bufferChunks = [];\n let timer = null;\n let workletLoaded = false;\n let hideTimer = null;\n let mediaStream = null;\n let mediaStreamSource = null;\n const $asr = art.layers.add({\n name: 'asr',\n html: ''\n });\n function splitByPunctuation(text) {\n return text.split(/(?<=[、。!?!?.])\\s*/u).map((s)=>s.trim()).filter(Boolean).slice(-length);\n }\n function hide() {\n $asr.style.display = 'none';\n }\n function append(subtitle) {\n if (typeof subtitle !== 'string') return;\n clearTimeout(hideTimer);\n hideTimer = setTimeout(hide, autoHideTimeout);\n $asr.style.display = '';\n $asr.innerHTML = splitByPunctuation(subtitle).map((line)=>`
${line}
`).join('');\n }\n const recorderProcessorCode = `\n class RecorderProcessor extends AudioWorkletProcessor {\n process(inputs) {\n const input = inputs[0];\n if (input && input[0]) {\n this.port.postMessage(input[0]);\n }\n return true;\n }\n }\n registerProcessor('recorder-processor', RecorderProcessor);\n `;\n const createWorkletBlobUrl = ()=>{\n const blob = new Blob([\n recorderProcessorCode\n ], {\n type: 'application/javascript'\n });\n return URL.createObjectURL(blob);\n };\n function floatTo16BitPCM(float32Array) {\n const len = float32Array.length;\n const buffer = new ArrayBuffer(len * 2);\n const view = new DataView(buffer);\n for(let i = 0; i < len; i++){\n const s = Math.max(-1, Math.min(1, float32Array[i]));\n view.setInt16(i * 2, s < 0 ? s * 0x8000 : s * 0x7FFF, true);\n }\n return buffer;\n }\n function pcmToWav(pcmBuffer, sampleRate) {\n const pcmLength = pcmBuffer.byteLength;\n const wavBuffer = new ArrayBuffer(44 + pcmLength);\n const view = new DataView(wavBuffer);\n const writeString = (offset, str)=>{\n for(let i = 0; i < str.length; i++)view.setUint8(offset + i, str.charCodeAt(i));\n };\n writeString(0, 'RIFF');\n view.setUint32(4, 36 + pcmLength, true);\n writeString(8, 'WAVE');\n writeString(12, 'fmt ');\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true);\n view.setUint16(22, 1, true);\n view.setUint32(24, sampleRate, true);\n view.setUint32(28, sampleRate * 2, true);\n view.setUint16(32, 2, true);\n view.setUint16(34, 16, true);\n writeString(36, 'data');\n view.setUint32(40, pcmLength, true);\n new Uint8Array(wavBuffer).set(new Uint8Array(pcmBuffer), 44);\n return wavBuffer;\n }\n async function setupAudioContext() {\n if (audioCtx) return audioCtx;\n audioCtx = new (window.AudioContext || window.webkitAudioContext)({\n sampleRate\n });\n if (audioCtx.state === 'suspended') await audioCtx.resume();\n return audioCtx;\n }\n async function setupAudioSource() {\n if (!sourceNode && art.video) try {\n sourceNode = audioCtx.createMediaElementSource(art.video);\n return sourceNode;\n } catch (err) {\n console.warn('[artplayerPluginAsr] Direct connection failed:', err);\n }\n try {\n if (!mediaStream) mediaStream = await captureAudioFromVideo(art.video);\n if (mediaStream) {\n mediaStreamSource = audioCtx.createMediaStreamSource(mediaStream);\n return mediaStreamSource;\n }\n } catch (err) {\n console.warn('[artplayerPluginAsr] MediaStream fallback failed:', err);\n }\n return null;\n }\n async function captureAudioFromVideo(videoElement) {\n try {\n if (videoElement.captureStream) return videoElement.captureStream();\n if (videoElement.mozCaptureStream) return videoElement.mozCaptureStream();\n console.warn('[artplayerPluginAsr] captureStream not supported');\n return null;\n } catch (err) {\n console.warn('[artplayerPluginAsr] Error capturing stream:', err);\n return null;\n }\n }\n async function startCapture() {\n if (started) return;\n try {\n await setupAudioContext();\n const audioSource = await setupAudioSource();\n if (!audioSource) throw new Error('Could not establish audio source');\n if (!workletLoaded) {\n const blobUrl = createWorkletBlobUrl();\n await audioCtx.audioWorklet.addModule(blobUrl);\n URL.revokeObjectURL(blobUrl);\n workletLoaded = true;\n }\n gainNode = audioCtx.createGain();\n gainNode.gain.value = 1;\n recorderNode = new AudioWorkletNode(audioCtx, 'recorder-processor');\n recorderNode.port.onmessage = (event)=>{\n bufferChunks.push(new Float32Array(event.data));\n };\n audioSource.connect(recorderNode);\n audioSource.connect(gainNode);\n gainNode.connect(audioCtx.destination);\n const CHUNK_SAMPLES = sampleRate * (interval / 1000);\n timer = setInterval(async ()=>{\n if (bufferChunks.length === 0) return;\n let accumulated = new Float32Array(0);\n while(accumulated.length < CHUNK_SAMPLES && bufferChunks.length){\n const next = bufferChunks.shift();\n const tmp = new Float32Array(accumulated.length + next.length);\n tmp.set(accumulated, 0);\n tmp.set(next, accumulated.length);\n accumulated = tmp;\n }\n if (accumulated.length < CHUNK_SAMPLES) return;\n const chunkToSend = accumulated.slice(0, CHUNK_SAMPLES);\n const pcm = floatTo16BitPCM(chunkToSend);\n const wav = pcmToWav(pcm, sampleRate);\n const subtitle = await onAudioChunk({\n pcm,\n wav\n });\n append(subtitle);\n }, interval);\n started = true;\n } catch (err) {\n console.error('[artplayerPluginAsr] Initialization failed:', err);\n await stopCapture();\n }\n }\n async function stopCapture() {\n if (!started) return;\n started = false;\n clearInterval(timer);\n timer = null;\n if (recorderNode) {\n recorderNode.disconnect();\n recorderNode.port.onmessage = null;\n recorderNode = null;\n }\n if (gainNode) {\n gainNode.disconnect();\n gainNode = null;\n }\n bufferChunks = [];\n }\n async function destroy() {\n await stopCapture();\n if (mediaStreamSource) {\n mediaStreamSource.disconnect();\n mediaStreamSource = null;\n }\n if (sourceNode) {\n sourceNode.disconnect();\n sourceNode = null;\n }\n if (mediaStream) {\n mediaStream.getTracks().forEach((track)=>track.stop());\n mediaStream = null;\n }\n if (audioCtx) {\n await audioCtx.close();\n audioCtx = null;\n }\n workletLoaded = false;\n }\n art.on('video:volumechange', ()=>{\n if (gainNode) gainNode.gain.value = art.volume;\n });\n art.on('play', startCapture);\n art.on('pause', stopCapture);\n art.on('destroy', destroy);\n return {\n name: 'artplayerPluginAsr',\n stop: destroy,\n hide,\n append\n };\n };\n}\nif (typeof document !== 'undefined') {\n if (!document.getElementById('artplayer-plugin-asr')) {\n const $style = document.createElement('style');\n $style.id = 'artplayer-plugin-asr';\n $style.textContent = (0, _styleLessDefault.default);\n document.head.appendChild($style);\n }\n}\nif (typeof window !== 'undefined') window.artplayerPluginAsr = artplayerPluginAsr;\n\n},{\"bundle-text:./style.less\":\"dKHY3\",\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"dKHY3\":[function(require,module,exports,__globalThis) {\nmodule.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))}\";\n\n},{}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"40eeC\"], \"40eeC\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"40eeC\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","import style from 'bundle-text:./style.less'\n\nexport default function artplayerPluginAsr(option = {}) {\n const {\n length = 3,\n interval = 100,\n sampleRate = 16000,\n autoHideTimeout = 10000,\n onAudioChunk = () => null,\n } = option\n\n return (art) => {\n let started = false\n let audioCtx = null\n let sourceNode = null\n let recorderNode = null\n let gainNode = null\n let bufferChunks = []\n let timer = null\n let workletLoaded = false\n let hideTimer = null\n let mediaStream = null\n let mediaStreamSource = null\n\n const $asr = art.layers.add({\n name: 'asr',\n html: '',\n })\n\n function splitByPunctuation(text) {\n return (\n text\n\n .split(/(?<=[、。!?!?.])\\s*/u)\n .map(s => s.trim())\n .filter(Boolean)\n .slice(-length)\n )\n }\n\n function hide() {\n $asr.style.display = 'none'\n }\n\n function append(subtitle) {\n if (typeof subtitle !== 'string')\n return\n clearTimeout(hideTimer)\n hideTimer = setTimeout(hide, autoHideTimeout)\n $asr.style.display = ''\n $asr.innerHTML = splitByPunctuation(subtitle)\n .map(line => `
${line}
`)\n .join('')\n }\n\n const recorderProcessorCode = `\n class RecorderProcessor extends AudioWorkletProcessor {\n process(inputs) {\n const input = inputs[0];\n if (input && input[0]) {\n this.port.postMessage(input[0]);\n }\n return true;\n }\n }\n registerProcessor('recorder-processor', RecorderProcessor);\n `\n\n const createWorkletBlobUrl = () => {\n const blob = new Blob([recorderProcessorCode], { type: 'application/javascript' })\n return URL.createObjectURL(blob)\n }\n\n function floatTo16BitPCM(float32Array) {\n const len = float32Array.length\n const buffer = new ArrayBuffer(len * 2)\n const view = new DataView(buffer)\n for (let i = 0; i < len; i++) {\n const s = Math.max(-1, Math.min(1, float32Array[i]))\n view.setInt16(i * 2, s < 0 ? s * 0x8000 : s * 0x7FFF, true)\n }\n return buffer\n }\n\n function pcmToWav(pcmBuffer, sampleRate) {\n const pcmLength = pcmBuffer.byteLength\n const wavBuffer = new ArrayBuffer(44 + pcmLength)\n const view = new DataView(wavBuffer)\n\n const writeString = (offset, str) => {\n for (let i = 0; i < str.length; i++) {\n view.setUint8(offset + i, str.charCodeAt(i))\n }\n }\n\n writeString(0, 'RIFF')\n view.setUint32(4, 36 + pcmLength, true)\n writeString(8, 'WAVE')\n writeString(12, 'fmt ')\n view.setUint32(16, 16, true)\n view.setUint16(20, 1, true)\n view.setUint16(22, 1, true)\n view.setUint32(24, sampleRate, true)\n view.setUint32(28, sampleRate * 2, true)\n view.setUint16(32, 2, true)\n view.setUint16(34, 16, true)\n writeString(36, 'data')\n view.setUint32(40, pcmLength, true)\n\n new Uint8Array(wavBuffer).set(new Uint8Array(pcmBuffer), 44)\n\n return wavBuffer\n }\n\n async function setupAudioContext() {\n if (audioCtx)\n return audioCtx\n audioCtx = new (window.AudioContext || window.webkitAudioContext)({ sampleRate })\n if (audioCtx.state === 'suspended')\n await audioCtx.resume()\n return audioCtx\n }\n\n async function setupAudioSource() {\n if (!sourceNode && art.video) {\n try {\n sourceNode = audioCtx.createMediaElementSource(art.video)\n return sourceNode\n }\n catch (err) {\n console.warn('[artplayerPluginAsr] Direct connection failed:', err)\n }\n }\n\n try {\n if (!mediaStream) {\n mediaStream = await captureAudioFromVideo(art.video)\n }\n if (mediaStream) {\n mediaStreamSource = audioCtx.createMediaStreamSource(mediaStream)\n return mediaStreamSource\n }\n }\n catch (err) {\n console.warn('[artplayerPluginAsr] MediaStream fallback failed:', err)\n }\n\n return null\n }\n\n async function captureAudioFromVideo(videoElement) {\n try {\n if (videoElement.captureStream)\n return videoElement.captureStream()\n if (videoElement.mozCaptureStream)\n return videoElement.mozCaptureStream()\n console.warn('[artplayerPluginAsr] captureStream not supported')\n return null\n }\n catch (err) {\n console.warn('[artplayerPluginAsr] Error capturing stream:', err)\n return null\n }\n }\n\n async function startCapture() {\n if (started)\n return\n\n try {\n await setupAudioContext()\n const audioSource = await setupAudioSource()\n if (!audioSource)\n throw new Error('Could not establish audio source')\n\n if (!workletLoaded) {\n const blobUrl = createWorkletBlobUrl()\n await audioCtx.audioWorklet.addModule(blobUrl)\n URL.revokeObjectURL(blobUrl)\n workletLoaded = true\n }\n\n gainNode = audioCtx.createGain()\n gainNode.gain.value = 1\n recorderNode = new AudioWorkletNode(audioCtx, 'recorder-processor')\n recorderNode.port.onmessage = (event) => {\n bufferChunks.push(new Float32Array(event.data))\n }\n audioSource.connect(recorderNode)\n audioSource.connect(gainNode)\n gainNode.connect(audioCtx.destination)\n\n const CHUNK_SAMPLES = sampleRate * (interval / 1000)\n timer = setInterval(async () => {\n if (bufferChunks.length === 0)\n return\n\n let accumulated = new Float32Array(0)\n while (accumulated.length < CHUNK_SAMPLES && bufferChunks.length) {\n const next = bufferChunks.shift()\n const tmp = new Float32Array(accumulated.length + next.length)\n tmp.set(accumulated, 0)\n tmp.set(next, accumulated.length)\n accumulated = tmp\n }\n\n if (accumulated.length < CHUNK_SAMPLES)\n return\n\n const chunkToSend = accumulated.slice(0, CHUNK_SAMPLES)\n const pcm = floatTo16BitPCM(chunkToSend)\n const wav = pcmToWav(pcm, sampleRate)\n const subtitle = await onAudioChunk({ pcm, wav })\n append(subtitle)\n }, interval)\n\n started = true\n }\n catch (err) {\n console.error('[artplayerPluginAsr] Initialization failed:', err)\n await stopCapture()\n }\n }\n\n async function stopCapture() {\n if (!started)\n return\n started = false\n\n clearInterval(timer)\n timer = null\n\n if (recorderNode) {\n recorderNode.disconnect()\n recorderNode.port.onmessage = null\n recorderNode = null\n }\n\n if (gainNode) {\n gainNode.disconnect()\n gainNode = null\n }\n\n bufferChunks = []\n }\n\n async function destroy() {\n await stopCapture()\n\n if (mediaStreamSource) {\n mediaStreamSource.disconnect()\n mediaStreamSource = null\n }\n\n if (sourceNode) {\n sourceNode.disconnect()\n sourceNode = null\n }\n\n if (mediaStream) {\n mediaStream.getTracks().forEach(track => track.stop())\n mediaStream = null\n }\n\n if (audioCtx) {\n await audioCtx.close()\n audioCtx = null\n }\n\n workletLoaded = false\n }\n\n art.on('video:volumechange', () => {\n if (gainNode) {\n gainNode.gain.value = art.volume\n }\n })\n\n art.on('play', startCapture)\n art.on('pause', stopCapture)\n art.on('destroy', destroy)\n\n return {\n name: 'artplayerPluginAsr',\n stop: destroy,\n hide,\n append,\n }\n }\n}\n\nif (typeof document !== 'undefined') {\n if (!document.getElementById('artplayer-plugin-asr')) {\n const $style = document.createElement('style')\n $style.id = 'artplayer-plugin-asr'\n $style.textContent = style\n document.head.appendChild($style)\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginAsr = artplayerPluginAsr\n}\n","module.exports = \"704cf673cb407483\";","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","defineInteropFlag","export","artplayerPluginAsr","_styleLess","_styleLessDefault","interopDefault","option","interval","sampleRate","autoHideTimeout","onAudioChunk","art","started","audioCtx","sourceNode","recorderNode","gainNode","bufferChunks","timer","workletLoaded","hideTimer","mediaStream","mediaStreamSource","$asr","layers","add","html","hide","style","display","append","subtitle","clearTimeout","setTimeout","innerHTML","splitByPunctuation","text","split","map","s","trim","filter","Boolean","slice","line","join","recorderProcessorCode","setupAudioContext","AudioContext","webkitAudioContext","state","resume","setupAudioSource","video","createMediaElementSource","console","warn","captureAudioFromVideo","createMediaStreamSource","videoElement","captureStream","mozCaptureStream","startCapture","audioSource","blobUrl","createWorkletBlobUrl","blob","Blob","type","URL","createObjectURL","audioWorklet","addModule","revokeObjectURL","createGain","gain","value","AudioWorkletNode","port","onmessage","event","push","Float32Array","data","connect","destination","CHUNK_SAMPLES","setInterval","accumulated","next","shift","tmp","set","chunkToSend","pcm","floatTo16BitPCM","float32Array","len","buffer","ArrayBuffer","view","DataView","Math","max","min","setInt16","wav","pcmToWav","pcmBuffer","pcmLength","byteLength","wavBuffer","writeString","offset","str","setUint8","charCodeAt","setUint32","setUint16","Uint8Array","error","stopCapture","clearInterval","disconnect","destroy","getTracks","forEach","track","stop","close","on","volume","document","getElementById","$style","createElement","textContent","default","head","appendChild","a","__esModule","exportAll","source","dest","keys","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-auto-thumbnail.mjs b/docs/compiled/artplayer-plugin-auto-thumbnail.mjs index 09336870d..15201c510 100644 --- a/docs/compiled/artplayer-plugin-auto-thumbnail.mjs +++ b/docs/compiled/artplayer-plugin-auto-thumbnail.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * 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.mjs.map \ No newline at end of file +!function(e,t,n,r,o,i,u,l){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},f="function"==typeof d[r]&&d[r],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(o[t])return o[t];var i="function"==typeof d[r]&&d[r];if(!n&&i)return i(t,!0);if(f)return f(t,!0);if(s&&"string"==typeof t)return s(t);var u=Error("Cannot find module '"+t+"'");throw u.code="MODULE_NOT_FOUND",u}a.resolve=function(n){var r=e[t][1][n];return null!=r?r: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[r]}}),d[r]=p;for(var m=0;m(t.on("video:loadedmetadata",()=>{let n=e.url||t.option.url,r=e.width||160,o=e.number||100,i=e.scale||1;!function({url:e,width:t,number:n},r){let o=document.createElement("video");o.crossOrigin="anonymous",o.src=e,o.onloadedmetadata=()=>{let e=o.duration,i=document.createElement("canvas"),u=i.getContext("2d"),l=Math.floor(t*o.videoHeight/o.videoWidth);i.width=10*t,i.height=l*Math.ceil(n/10);let d=null;!function f(a){i.toBlob(e=>{URL.revokeObjectURL(d),r({url:d=URL.createObjectURL(e),height:l})},"image/jpeg"),a>=n||(o.currentTime=e*a/n,o.onseeked=()=>{u.drawImage(o,a%10*t,Math.floor(a/10)*l,t,l),f(a+1)})}(0)}}({url:n,width:r,number:o},e=>{t.thumbnails={...e,column:10,number:o,width:r,scale:i}})}),{name:"artplayerPluginAutoThumbnail"})}o.defineInteropFlag(n),o.export(n,"default",()=>i),"undefined"!=typeof window&&(window.artplayerPluginAutoThumbnail=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],loqXi:[function(e,t,n,r){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})}},{}]},["lry5Y"],"lry5Y","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("lry5Y");export{e as default}; \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-auto-thumbnail.mjs.map b/docs/compiled/artplayer-plugin-auto-thumbnail.mjs.map deleted file mode 100644 index 8745d1e8f..000000000 --- a/docs/compiled/artplayer-plugin-auto-thumbnail.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,C,I,E,M,C,G,C,C,E,C,E,C,I,C,E,O,C,E,E,E,O,C,E,C,O,C,C,E,C,O,C,S,E,C,E,I,E,E,O,C,G,M,A,C,I,E,C,E,E,E,C,C,E,e,C,C,E,E,M,C,S,C,E,I,C,E,C,E,I,C,M,C,E,I,C,O,C,E,I,C,O,C,C,C,E,E,O,C,E,E,K,C,E,E,M,C,E,E,O,C,K,E,E,S,C,K,E,E,S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B,K,O","sources":["","packages/artplayer-plugin-auto-thumbnail/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"guSFC\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginAutoThumbnail);\nfunction create({ url, width, number }, callback) {\n const video = document.createElement('video');\n video.crossOrigin = 'anonymous';\n video.src = url;\n video.onloadedmetadata = ()=>{\n const duration = video.duration;\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const height = Math.floor(width * video.videoHeight / video.videoWidth);\n canvas.width = width * 10;\n canvas.height = height * Math.ceil(number / 10);\n let blobUrl = null;\n function seekAndDraw(index) {\n canvas.toBlob((blob)=>{\n URL.revokeObjectURL(blobUrl);\n blobUrl = URL.createObjectURL(blob);\n callback({\n url: blobUrl,\n height\n });\n }, 'image/jpeg');\n if (index >= number) return;\n video.currentTime = duration * index / number;\n video.onseeked = ()=>{\n ctx.drawImage(video, index % 10 * width, Math.floor(index / 10) * height, width, height);\n seekAndDraw(index + 1);\n };\n }\n seekAndDraw(0);\n };\n}\nfunction artplayerPluginAutoThumbnail(option) {\n return async (art)=>{\n art.on('video:loadedmetadata', ()=>{\n const url = option.url || art.option.url;\n const width = option.width || 160;\n const number = option.number || 100;\n const scale = option.scale || 1;\n create({\n url,\n width,\n number\n }, (config)=>{\n art.thumbnails = {\n ...config,\n column: 10,\n number,\n width,\n scale\n };\n });\n });\n return {\n name: 'artplayerPluginAutoThumbnail'\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginAutoThumbnail = artplayerPluginAutoThumbnail;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"guSFC\"], \"guSFC\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"guSFC\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","function create({ url, width, number }, callback) {\n const video = document.createElement('video')\n video.crossOrigin = 'anonymous'\n video.src = url\n\n video.onloadedmetadata = () => {\n const duration = video.duration\n const canvas = document.createElement('canvas')\n const ctx = canvas.getContext('2d')\n const height = Math.floor((width * video.videoHeight) / video.videoWidth)\n\n canvas.width = width * 10\n canvas.height = height * Math.ceil(number / 10)\n\n let blobUrl = null\n\n function seekAndDraw(index) {\n canvas.toBlob((blob) => {\n URL.revokeObjectURL(blobUrl)\n blobUrl = URL.createObjectURL(blob)\n\n callback({\n url: blobUrl,\n height,\n })\n }, 'image/jpeg')\n\n if (index >= number)\n return\n video.currentTime = (duration * index) / number\n\n video.onseeked = () => {\n ctx.drawImage(video, (index % 10) * width, Math.floor(index / 10) * height, width, height)\n seekAndDraw(index + 1)\n }\n }\n\n seekAndDraw(0)\n }\n}\n\nexport default function artplayerPluginAutoThumbnail(option) {\n return async (art) => {\n art.on('video:loadedmetadata', () => {\n const url = option.url || art.option.url\n const width = option.width || 160\n const number = option.number || 100\n const scale = option.scale || 1\n create({ url, width, number }, (config) => {\n art.thumbnails = {\n ...config,\n column: 10,\n number,\n width,\n scale,\n }\n })\n })\n\n return {\n name: 'artplayerPluginAutoThumbnail',\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginAutoThumbnail = artplayerPluginAutoThumbnail\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginAutoThumbnail","option","art","on","url","width","number","scale","create","callback","video","document","createElement","crossOrigin","src","onloadedmetadata","duration","canvas","ctx","getContext","height","Math","floor","videoHeight","videoWidth","ceil","blobUrl","seekAndDraw","index","toBlob","blob","URL","revokeObjectURL","createObjectURL","currentTime","onseeked","drawImage","config","thumbnails","column","defineInteropFlag","export","interopDefault","a","__esModule","default","value","exportAll","source","dest","keys","forEach","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-chapter.mjs b/docs/compiled/artplayer-plugin-chapter.mjs index e3a4200e3..a0af2da1e 100644 --- a/docs/compiled/artplayer-plugin-chapter.mjs +++ b/docs/compiled/artplayer-plugin-chapter.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * 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.mjs.map \ No newline at end of file +!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":"cGJtg","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],cGJtg:[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}"},{}],loqXi:[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})}},{}]},["fwWaD"],"fwWaD","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("fwWaD");export{e as default}; \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-chapter.mjs.map b/docs/compiled/artplayer-plugin-chapter.mjs.map deleted file mode 100644 index 6a110cd74..000000000 --- a/docs/compiled/artplayer-plugin-chapter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AG,EAAI,CAAC,QAAS,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-chapter/src/index.js","node_modules/@parcel/runtime-js/lib/bundles/runtime-3d3e8628bac64a11.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"1LLzi\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginChapter);\nvar _styleLess = require(\"bundle-text:./style.less\");\nvar _styleLessDefault = parcelHelpers.interopDefault(_styleLess);\nfunction artplayerPluginChapter(option = {}) {\n return (art)=>{\n const { $player } = art.template;\n const { setStyle, append, clamp, query, isMobile, addClass, removeClass } = art.constructor.utils;\n const html = `\n
\n
\n
\n
\n
\n
\n
\n `;\n let titleTimer = null;\n let $chapters = [];\n const $progress = art.query('.art-control-progress');\n const $inner = art.query('.art-control-progress-inner');\n const $control = append($inner, '
');\n const $title = append($inner, '
');\n function showTitle({ $chapter, width }) {\n const title = $chapter.dataset.title.trim();\n if (title) {\n setStyle($title, 'display', 'flex');\n $title.textContent = title;\n const titleWidth = $title.clientWidth;\n if (width <= titleWidth / 2) setStyle($title, 'left', 0);\n else if (width > $inner.clientWidth - titleWidth / 2) setStyle($title, 'left', `${$inner.clientWidth - titleWidth}px`);\n else setStyle($title, 'left', `${width - titleWidth / 2}px`);\n } else setStyle($title, 'display', 'none');\n }\n function update(chapters = []) {\n $chapters = [];\n $control.textContent = '';\n removeClass($player, 'artplayer-plugin-chapter');\n if (!Array.isArray(chapters)) return;\n if (!chapters.length) return;\n if (!art.duration) return;\n chapters = chapters.sort((a, b)=>a.start - b.start);\n for(let i = 0; i < chapters.length; i++){\n const chapter = chapters[i];\n const nextChapter = chapters[i + 1];\n if (chapter.end === Infinity) chapter.end = art.duration;\n if (typeof chapter.start !== 'number' || typeof chapter.end !== 'number' || typeof chapter.title !== 'string') throw new TypeError('Illegal chapter data type');\n if (chapter.start < 0 || chapter.end > art.duration || chapter.start >= chapter.end) throw new Error('Illegal chapter time point');\n if (nextChapter && chapter.end > nextChapter.start) throw new Error('Illegal chapter time point');\n }\n if (chapters[0].start > 0) chapters.unshift({\n start: 0,\n end: chapters[0].start,\n title: ''\n });\n if (chapters[chapters.length - 1].end < art.duration) chapters.push({\n start: chapters[chapters.length - 1].end,\n end: art.duration,\n title: ''\n });\n for(let i = 0; i < chapters.length - 1; i++)if (chapters[i].end !== chapters[i + 1].start) chapters.splice(i + 1, 0, {\n start: chapters[i].end,\n end: chapters[i + 1].start,\n title: ''\n });\n $chapters = chapters.map((chapter)=>{\n const $chapter = append($control, html);\n const start = clamp(chapter.start, 0, art.duration);\n const end = clamp(chapter.end, 0, art.duration);\n const duration = end - start;\n const percentage = duration / art.duration;\n $chapter.dataset.start = start;\n $chapter.dataset.end = end;\n $chapter.dataset.duration = duration;\n $chapter.dataset.title = chapter.title.trim();\n $chapter.style.width = `${percentage * 100}%`;\n return {\n $chapter,\n $hover: query('.art-progress-hover', $chapter),\n $loaded: query('.art-progress-loaded', $chapter),\n $played: query('.art-progress-played', $chapter)\n };\n });\n addClass($player, 'artplayer-plugin-chapter');\n art.emit('setBar', 'loaded', art.loaded || 0);\n }\n art.on('setBar', (type, percentage, event)=>{\n if (!$chapters.length) return;\n for(let i = 0; i < $chapters.length; i++){\n const { $chapter, $loaded, $played, $hover } = $chapters[i];\n const $target = {\n hover: $hover,\n loaded: $loaded,\n played: $played\n }[type];\n if (!$target) return;\n const width = $control.clientWidth * percentage;\n const currentTime = art.duration * percentage;\n const duration = Number.parseFloat($chapter.dataset.duration);\n const start = Number.parseFloat($chapter.dataset.start);\n const end = Number.parseFloat($chapter.dataset.end);\n if (currentTime < start) setStyle($target, 'width', 0);\n if (currentTime > end) setStyle($target, 'width', '100%');\n if (currentTime >= start && currentTime <= end) {\n const percentage = (currentTime - start) / duration;\n setStyle($target, 'width', `${percentage * 100}%`);\n if (isMobile) {\n if (type === 'played' && event) {\n showTitle({\n $chapter,\n width\n });\n clearTimeout(titleTimer);\n titleTimer = setTimeout(()=>{\n setStyle($title, 'display', 'none');\n }, 500);\n }\n } else if (type === 'hover') showTitle({\n $chapter,\n width\n });\n }\n }\n });\n if (!isMobile) art.proxy($progress, 'mouseleave', ()=>{\n if (!$chapters.length) return;\n setStyle($title, 'display', 'none');\n });\n art.once('video:loadedmetadata', ()=>update(option.chapters));\n return {\n name: 'artplayerPluginChapter',\n update: ({ chapters })=>update(chapters)\n };\n };\n}\nif (typeof document !== 'undefined') {\n const id = 'artplayer-plugin-chapter';\n let $style = document.getElementById(id);\n if (!$style) {\n $style = document.createElement('style');\n $style.id = id;\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', ()=>{\n document.head.appendChild($style);\n });\n else (document.head || document.documentElement).appendChild($style);\n }\n $style.textContent = (0, _styleLessDefault.default);\n}\nif (typeof window !== 'undefined') window.artplayerPluginChapter = artplayerPluginChapter;\n\n},{\"bundle-text:./style.less\":\"e5E4m\",\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"e5E4m\":[function(require,module,exports,__globalThis) {\nmodule.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}\";\n\n},{}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"1LLzi\"], \"1LLzi\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"1LLzi\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","import style from 'bundle-text:./style.less'\n\nexport default function artplayerPluginChapter(option = {}) {\n return (art) => {\n const { $player } = art.template\n const { setStyle, append, clamp, query, isMobile, addClass, removeClass } = art.constructor.utils\n\n const html = `\n
\n
\n
\n
\n
\n
\n
\n `\n\n let titleTimer = null\n let $chapters = []\n\n const $progress = art.query('.art-control-progress')\n const $inner = art.query('.art-control-progress-inner')\n const $control = append($inner, '
')\n const $title = append($inner, '
')\n\n function showTitle({ $chapter, width }) {\n const title = $chapter.dataset.title.trim()\n if (title) {\n setStyle($title, 'display', 'flex')\n $title.textContent = title\n const titleWidth = $title.clientWidth\n if (width <= titleWidth / 2) {\n setStyle($title, 'left', 0)\n }\n else if (width > $inner.clientWidth - titleWidth / 2) {\n setStyle($title, 'left', `${$inner.clientWidth - titleWidth}px`)\n }\n else {\n setStyle($title, 'left', `${width - titleWidth / 2}px`)\n }\n }\n else {\n setStyle($title, 'display', 'none')\n }\n }\n\n function update(chapters = []) {\n $chapters = []\n $control.textContent = ''\n removeClass($player, 'artplayer-plugin-chapter')\n\n if (!Array.isArray(chapters))\n return\n if (!chapters.length)\n return\n if (!art.duration)\n return\n\n chapters = chapters.sort((a, b) => a.start - b.start)\n\n for (let i = 0; i < chapters.length; i++) {\n const chapter = chapters[i]\n const nextChapter = chapters[i + 1]\n\n if (chapter.end === Infinity) {\n chapter.end = art.duration\n }\n\n if (\n typeof chapter.start !== 'number'\n || typeof chapter.end !== 'number'\n || typeof chapter.title !== 'string'\n ) {\n throw new TypeError('Illegal chapter data type')\n }\n\n if (chapter.start < 0 || chapter.end > art.duration || chapter.start >= chapter.end) {\n throw new Error('Illegal chapter time point')\n }\n\n if (nextChapter && chapter.end > nextChapter.start) {\n throw new Error('Illegal chapter time point')\n }\n }\n\n if (chapters[0].start > 0) {\n chapters.unshift({ start: 0, end: chapters[0].start, title: '' })\n }\n\n if (chapters[chapters.length - 1].end < art.duration) {\n chapters.push({ start: chapters[chapters.length - 1].end, end: art.duration, title: '' })\n }\n\n for (let i = 0; i < chapters.length - 1; i++) {\n if (chapters[i].end !== chapters[i + 1].start) {\n chapters.splice(i + 1, 0, {\n start: chapters[i].end,\n end: chapters[i + 1].start,\n title: '',\n })\n }\n }\n\n $chapters = chapters.map((chapter) => {\n const $chapter = append($control, html)\n const start = clamp(chapter.start, 0, art.duration)\n const end = clamp(chapter.end, 0, art.duration)\n const duration = end - start\n const percentage = duration / art.duration\n $chapter.dataset.start = start\n $chapter.dataset.end = end\n $chapter.dataset.duration = duration\n $chapter.dataset.title = chapter.title.trim()\n $chapter.style.width = `${percentage * 100}%`\n\n return {\n $chapter,\n $hover: query('.art-progress-hover', $chapter),\n $loaded: query('.art-progress-loaded', $chapter),\n $played: query('.art-progress-played', $chapter),\n }\n })\n\n addClass($player, 'artplayer-plugin-chapter')\n art.emit('setBar', 'loaded', art.loaded || 0)\n }\n\n art.on('setBar', (type, percentage, event) => {\n if (!$chapters.length)\n return\n\n for (let i = 0; i < $chapters.length; i++) {\n const { $chapter, $loaded, $played, $hover } = $chapters[i]\n\n const $target = {\n hover: $hover,\n loaded: $loaded,\n played: $played,\n }[type]\n\n if (!$target)\n return\n\n const width = $control.clientWidth * percentage\n const currentTime = art.duration * percentage\n const duration = Number.parseFloat($chapter.dataset.duration)\n const start = Number.parseFloat($chapter.dataset.start)\n const end = Number.parseFloat($chapter.dataset.end)\n\n if (currentTime < start) {\n setStyle($target, 'width', 0)\n }\n\n if (currentTime > end) {\n setStyle($target, 'width', '100%')\n }\n\n if (currentTime >= start && currentTime <= end) {\n const percentage = (currentTime - start) / duration\n setStyle($target, 'width', `${percentage * 100}%`)\n\n if (isMobile) {\n if (type === 'played' && event) {\n showTitle({ $chapter, width })\n clearTimeout(titleTimer)\n titleTimer = setTimeout(() => {\n setStyle($title, 'display', 'none')\n }, 500)\n }\n }\n else {\n if (type === 'hover') {\n showTitle({ $chapter, width })\n }\n }\n }\n }\n })\n\n if (!isMobile) {\n art.proxy($progress, 'mouseleave', () => {\n if (!$chapters.length)\n return\n setStyle($title, 'display', 'none')\n })\n }\n\n art.once('video:loadedmetadata', () => update(option.chapters))\n\n return {\n name: 'artplayerPluginChapter',\n update: ({ chapters }) => update(chapters),\n }\n }\n}\n\nif (typeof document !== 'undefined') {\n const id = 'artplayer-plugin-chapter'\n let $style = document.getElementById(id)\n if (!$style) {\n $style = document.createElement('style')\n $style.id = id\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => {\n document.head.appendChild($style)\n })\n }\n else {\n (document.head || document.documentElement).appendChild($style)\n }\n }\n $style.textContent = style\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginChapter = artplayerPluginChapter\n}\n","module.exports = \"78c751325fe725df\";","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","defineInteropFlag","export","artplayerPluginChapter","_styleLess","_styleLessDefault","interopDefault","option","art","$player","template","setStyle","append","clamp","query","isMobile","addClass","removeClass","utils","html","titleTimer","$chapters","$progress","$inner","$control","$title","showTitle","$chapter","width","title","dataset","trim","textContent","titleWidth","clientWidth","update","chapters","Array","isArray","duration","sort","a","b","start","chapter","nextChapter","end","Infinity","TypeError","unshift","push","splice","map","percentage","style","$hover","$loaded","$played","emit","loaded","on","type","event","$target","hover","played","currentTime","Number","parseFloat","clearTimeout","setTimeout","proxy","once","document","$style","getElementById","createElement","readyState","addEventListener","head","appendChild","documentElement","default","__esModule","value","exportAll","source","dest","keys","forEach","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-chromecast.mjs b/docs/compiled/artplayer-plugin-chromecast.mjs index a2993d56d..7b7db3fcc 100644 --- a/docs/compiled/artplayer-plugin-chromecast.mjs +++ b/docs/compiled/artplayer-plugin-chromecast.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * 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.mjs.map \ No newline at end of file +!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":"loqXi"}],loqXi:[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})}},{}]},["2IQmJ"],"2IQmJ","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("2IQmJ");export{e as default}; \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-chromecast.mjs.map b/docs/compiled/artplayer-plugin-chromecast.mjs.map deleted file mode 100644 index 79d3bd7f2..000000000 --- a/docs/compiled/artplayer-plugin-chromecast.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C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S,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-chromecast/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"cv67D\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginChromecast);\nfunction loadScript(src) {\n return new Promise((resolve, reject)=>{\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.body.appendChild(script);\n });\n}\nfunction getMimeType(url) {\n const extension = url.split('?')[0].split('#')[0].split('.').pop().toLowerCase();\n const mimeTypes = {\n mp4: 'video/mp4',\n webm: 'video/webm',\n ogg: 'video/ogg',\n ogv: 'video/ogg',\n mp3: 'audio/mp3',\n wav: 'audio/wav',\n flv: 'video/x-flv',\n mov: 'video/quicktime',\n avi: 'video/x-msvideo',\n wmv: 'video/x-ms-wmv',\n mpd: 'application/dash+xml',\n m3u8: 'application/x-mpegURL'\n };\n return mimeTypes[extension] || 'application/octet-stream';\n}\nfunction artplayerPluginChromecast(option) {\n const DEFAULT_ICON = ``;\n const DEFAULT_SDK = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1';\n let isCastInitialized = false;\n let castSession = null;\n let castState = null;\n const updateCastButton = (state)=>{\n const button = document.querySelector('.art-icon-cast');\n if (button) switch(state){\n case 'connected':\n button.style.color = 'red';\n break;\n case 'connecting':\n case 'disconnecting':\n button.style.color = 'orange';\n break;\n case 'disconnected':\n default:\n button.style.color = 'white';\n break;\n }\n };\n const initializeCastApi = ()=>{\n return new Promise((resolve, reject)=>{\n window.__onGCastApiAvailable = (isAvailable)=>{\n if (isAvailable) {\n const context = window.cast.framework.CastContext.getInstance();\n context.setOptions({\n receiverApplicationId: window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,\n autoJoinPolicy: window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED\n });\n // Listen for session state changes\n context.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED, (event)=>{\n const SessionState = window.cast.framework.SessionState;\n castState = event.sessionState;\n castSession = event.session;\n switch(event.sessionState){\n case SessionState.NO_SESSION:\n option.onStateChange?.('disconnected');\n updateCastButton('disconnected');\n break;\n case SessionState.SESSION_STARTING:\n option.onStateChange?.('connecting');\n updateCastButton('connecting');\n break;\n case SessionState.SESSION_STARTED:\n option.onStateChange?.('connected');\n updateCastButton('connected');\n break;\n case SessionState.SESSION_ENDING:\n option.onStateChange?.('disconnecting');\n updateCastButton('disconnecting');\n break;\n case SessionState.SESSION_RESUMED:\n option.onStateChange?.('connected');\n updateCastButton('connected');\n break;\n }\n });\n // Listen for cast state changes\n context.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED, (event)=>{\n const CastState = window.cast.framework.CastState;\n switch(event.castState){\n case CastState.NO_DEVICES_AVAILABLE:\n option.onCastAvailable?.(false);\n break;\n case CastState.NOT_CONNECTED:\n option.onCastAvailable?.(true);\n break;\n case CastState.CONNECTING:\n case CastState.CONNECTED:\n option.onCastAvailable?.(true);\n break;\n }\n });\n isCastInitialized = true;\n resolve();\n } else reject(new Error('Cast API is not available'));\n };\n if (!window.chrome || !window.chrome.cast) loadScript(option.sdk || DEFAULT_SDK).catch(reject);\n });\n };\n const castVideo = (art, session)=>{\n const url = option.url || art.option.url;\n const mediaInfo = new window.chrome.cast.media.MediaInfo(url, option.mimeType || getMimeType(url));\n const request = new window.chrome.cast.media.LoadRequest(mediaInfo);\n session.loadMedia(request).then(()=>{\n art.notice.show = 'Casting started';\n option.onCastStart?.();\n }).catch((error)=>{\n art.notice.show = 'Error casting media';\n option.onError?.(error);\n throw error;\n });\n };\n return async (art)=>{\n art.controls.add({\n name: 'chromecast',\n position: 'right',\n tooltip: 'Chromecast',\n html: `${option.icon || DEFAULT_ICON}`,\n click: async ()=>{\n if (!isCastInitialized) try {\n await initializeCastApi();\n } catch (error) {\n art.notice.show = 'Failed to initialize Cast API';\n option.onError?.(error);\n throw error;\n }\n const context = window.cast.framework.CastContext.getInstance();\n if (castSession) castVideo(art, castSession);\n else try {\n const session = await context.requestSession();\n castVideo(art, session);\n } catch (error) {\n art.notice.show = 'Error connecting to cast session';\n option.onError?.(error);\n throw error;\n }\n }\n });\n return {\n name: 'artplayerPluginChromecast',\n getCastState: ()=>castState,\n isCasting: ()=>castSession !== null\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginChromecast = artplayerPluginChromecast;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"cv67D\"], \"cv67D\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"cv67D\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","function loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script')\n script.src = src\n script.onload = resolve\n script.onerror = reject\n document.body.appendChild(script)\n })\n}\n\nfunction getMimeType(url) {\n const extension = url.split('?')[0].split('#')[0].split('.').pop().toLowerCase()\n const mimeTypes = {\n mp4: 'video/mp4',\n webm: 'video/webm',\n ogg: 'video/ogg',\n ogv: 'video/ogg',\n mp3: 'audio/mp3',\n wav: 'audio/wav',\n flv: 'video/x-flv',\n mov: 'video/quicktime',\n avi: 'video/x-msvideo',\n wmv: 'video/x-ms-wmv',\n mpd: 'application/dash+xml',\n m3u8: 'application/x-mpegURL',\n }\n return mimeTypes[extension] || 'application/octet-stream'\n}\n\nexport default function artplayerPluginChromecast(option) {\n const DEFAULT_ICON = ``\n const DEFAULT_SDK = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1'\n\n let isCastInitialized = false\n let castSession = null\n let castState = null\n\n const updateCastButton = (state) => {\n const button = document.querySelector('.art-icon-cast')\n if (button) {\n switch (state) {\n case 'connected':\n button.style.color = 'red'\n break\n case 'connecting':\n case 'disconnecting':\n button.style.color = 'orange'\n break\n case 'disconnected':\n default:\n button.style.color = 'white'\n break\n }\n }\n }\n\n const initializeCastApi = () => {\n return new Promise((resolve, reject) => {\n window.__onGCastApiAvailable = (isAvailable) => {\n if (isAvailable) {\n const context = window.cast.framework.CastContext.getInstance()\n context.setOptions({\n receiverApplicationId: window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,\n autoJoinPolicy: window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,\n })\n\n // Listen for session state changes\n context.addEventListener(\n window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,\n (event) => {\n const SessionState = window.cast.framework.SessionState\n castState = event.sessionState\n castSession = event.session\n\n switch (event.sessionState) {\n case SessionState.NO_SESSION:\n option.onStateChange?.('disconnected')\n updateCastButton('disconnected')\n break\n case SessionState.SESSION_STARTING:\n option.onStateChange?.('connecting')\n updateCastButton('connecting')\n break\n case SessionState.SESSION_STARTED:\n option.onStateChange?.('connected')\n updateCastButton('connected')\n break\n case SessionState.SESSION_ENDING:\n option.onStateChange?.('disconnecting')\n updateCastButton('disconnecting')\n break\n case SessionState.SESSION_RESUMED:\n option.onStateChange?.('connected')\n updateCastButton('connected')\n break\n }\n },\n )\n\n // Listen for cast state changes\n context.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED, (event) => {\n const CastState = window.cast.framework.CastState\n switch (event.castState) {\n case CastState.NO_DEVICES_AVAILABLE:\n option.onCastAvailable?.(false)\n break\n case CastState.NOT_CONNECTED:\n option.onCastAvailable?.(true)\n break\n case CastState.CONNECTING:\n case CastState.CONNECTED:\n option.onCastAvailable?.(true)\n break\n }\n })\n\n isCastInitialized = true\n resolve()\n }\n else {\n reject(new Error('Cast API is not available'))\n }\n }\n if (!window.chrome || !window.chrome.cast) {\n loadScript(option.sdk || DEFAULT_SDK).catch(reject)\n }\n })\n }\n\n const castVideo = (art, session) => {\n const url = option.url || art.option.url\n const mediaInfo = new window.chrome.cast.media.MediaInfo(url, option.mimeType || getMimeType(url))\n const request = new window.chrome.cast.media.LoadRequest(mediaInfo)\n session\n .loadMedia(request)\n .then(() => {\n art.notice.show = 'Casting started'\n option.onCastStart?.()\n })\n .catch((error) => {\n art.notice.show = 'Error casting media'\n option.onError?.(error)\n throw error\n })\n }\n\n return async (art) => {\n art.controls.add({\n name: 'chromecast',\n position: 'right',\n tooltip: 'Chromecast',\n html: `${option.icon || DEFAULT_ICON}`,\n click: async () => {\n if (!isCastInitialized) {\n try {\n await initializeCastApi()\n }\n catch (error) {\n art.notice.show = 'Failed to initialize Cast API'\n option.onError?.(error)\n throw error\n }\n }\n\n const context = window.cast.framework.CastContext.getInstance()\n if (castSession) {\n castVideo(art, castSession)\n }\n else {\n try {\n const session = await context.requestSession()\n castVideo(art, session)\n }\n catch (error) {\n art.notice.show = 'Error connecting to cast session'\n option.onError?.(error)\n throw error\n }\n }\n },\n })\n\n return {\n name: 'artplayerPluginChromecast',\n getCastState: () => castState,\n isCasting: () => castSession !== null,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginChromecast = artplayerPluginChromecast\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginChromecast","option","isCastInitialized","castSession","castState","updateCastButton","state","button","document","querySelector","style","color","castVideo","art","session","url","mediaInfo","chrome","cast","media","MediaInfo","mimeType","mimeTypes","mp4","webm","ogg","ogv","mp3","wav","flv","mov","avi","wmv","mpd","m3u8","split","pop","toLowerCase","request","LoadRequest","loadMedia","then","notice","show","onCastStart","catch","error","onError","controls","add","position","tooltip","html","icon","click","Promise","reject","src","__onGCastApiAvailable","isAvailable","context","framework","CastContext","getInstance","setOptions","receiverApplicationId","DEFAULT_MEDIA_RECEIVER_APP_ID","autoJoinPolicy","AutoJoinPolicy","ORIGIN_SCOPED","addEventListener","CastContextEventType","SESSION_STATE_CHANGED","event","SessionState","sessionState","NO_SESSION","onStateChange","SESSION_STARTING","SESSION_STARTED","SESSION_ENDING","SESSION_RESUMED","CAST_STATE_CHANGED","CastState","NO_DEVICES_AVAILABLE","onCastAvailable","NOT_CONNECTED","CONNECTING","CONNECTED","loadScript","sdk","script","createElement","onload","onerror","body","appendChild","requestSession","getCastState","isCasting","defineInteropFlag","export","interopDefault","a","__esModule","default","value","exportAll","source","dest","keys","forEach","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-danmuku-mask.mjs b/docs/compiled/artplayer-plugin-danmuku-mask.mjs index 34f03dd79..9b66f4424 100644 --- a/docs/compiled/artplayer-plugin-danmuku-mask.mjs +++ b/docs/compiled/artplayer-plugin-danmuku-mask.mjs @@ -5,5 +5,4 @@ * (c) 2017-2025 Harvey Zack * 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 680dba032..f30147ed0 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 1fb128481..57a8d1c42 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 227a7c56a..92a3aeb05 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 2d5b47da7..b5a6324f7 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 b5d05ea44..691a0e91c 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 1bbffd45b..9773fb248 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.CiuUgQUt.js b/docs/document/assets/en_index.md.CrBYmuoJ.js similarity index 98% rename from docs/document/assets/en_index.md.CiuUgQUt.js rename to docs/document/assets/en_index.md.CrBYmuoJ.js index 64ec14131..80cf876da 100644 --- a/docs/document/assets/en_index.md.CiuUgQUt.js +++ b/docs/document/assets/en_index.md.CrBYmuoJ.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":1755403790000}'),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":1755403790000}'),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
<script>
+</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
<script>
 import Artplayer from 'artplayer'
 
 export default {
@@ -83,7 +83,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
 
 <template>
   <Artplayer :option="option" :style="style" @get-instance="getInstance" />
-</template>

Artplayer Not Responsive:

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

React.js ​

jsx
import Artplayer from 'artplayer'
+</template>

Artplayer Not Responsive:

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

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 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.6, artplayer and all plugins will also provide an ESM version of mjs, such as:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
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.6, artplayer and all plugins will also provide an ESM version of mjs, such as:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
diff --git a/docs/document/assets/en_index.md.CiuUgQUt.lean.js b/docs/document/assets/en_index.md.CrBYmuoJ.lean.js
similarity index 100%
rename from docs/document/assets/en_index.md.CiuUgQUt.lean.js
rename to docs/document/assets/en_index.md.CrBYmuoJ.lean.js
diff --git a/docs/document/assets/en_start_i18n.md.DI6iL4s5.js b/docs/document/assets/en_start_i18n.md.LZJYrEMl.js
similarity index 98%
rename from docs/document/assets/en_start_i18n.md.DI6iL4s5.js
rename to docs/document/assets/en_start_i18n.md.LZJYrEMl.js
index b58958910..e4e26d5a9 100644
--- a/docs/document/assets/en_start_i18n.md.DI6iL4s5.js
+++ b/docs/document/assets/en_start_i18n.md.LZJYrEMl.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.DI6iL4s5.lean.js b/docs/document/assets/en_start_i18n.md.LZJYrEMl.lean.js
similarity index 100%
rename from docs/document/assets/en_start_i18n.md.DI6iL4s5.lean.js
rename to docs/document/assets/en_start_i18n.md.LZJYrEMl.lean.js
diff --git a/docs/document/assets/index.md.CX90tGf9.js b/docs/document/assets/index.md.Csi3pPGL.js
similarity index 98%
rename from docs/document/assets/index.md.CX90tGf9.js
rename to docs/document/assets/index.md.Csi3pPGL.js
index 4438bfde1..16e0572b9 100644
--- a/docs/document/assets/index.md.CX90tGf9.js
+++ b/docs/document/assets/index.md.Csi3pPGL.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":1755403790000}'),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":1755403790000}'),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
<script>
+</html>

提示

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

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

/packages/artplayer-template

Vue.js ​

vue
<script>
 import Artplayer from 'artplayer'
 
 export default {
@@ -83,7 +83,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
 
 <template>
   <Artplayer :option="option" :style="style" @get-instance="getInstance" />
-</template>

Artplayer 非响应式:

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

React.js ​

jsx
import Artplayer from 'artplayer'
+</template>

Artplayer 非响应式:

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

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 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.6 开始,artplayer 和所有插件还会提供一个 ESM 版本的 mjs,如:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
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.6 开始,artplayer 和所有插件还会提供一个 ESM 版本的 mjs,如:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
diff --git a/docs/document/assets/index.md.CX90tGf9.lean.js b/docs/document/assets/index.md.Csi3pPGL.lean.js
similarity index 100%
rename from docs/document/assets/index.md.CX90tGf9.lean.js
rename to docs/document/assets/index.md.Csi3pPGL.lean.js
diff --git a/docs/document/assets/plugin_danmuku.md.BlYDlg9O.js b/docs/document/assets/plugin_danmuku.md.B787tX6f.js
similarity index 99%
rename from docs/document/assets/plugin_danmuku.md.BlYDlg9O.js
rename to docs/document/assets/plugin_danmuku.md.B787tX6f.js
index e96ce54cf..612d03811 100644
--- a/docs/document/assets/plugin_danmuku.md.BlYDlg9O.js
+++ b/docs/document/assets/plugin_danmuku.md.B787tX6f.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.BlYDlg9O.lean.js b/docs/document/assets/plugin_danmuku.md.B787tX6f.lean.js
similarity index 100%
rename from docs/document/assets/plugin_danmuku.md.BlYDlg9O.lean.js
rename to docs/document/assets/plugin_danmuku.md.B787tX6f.lean.js
diff --git a/docs/document/assets/start_i18n.md.DDW5i8aM.js b/docs/document/assets/start_i18n.md.Bc8eeWY1.js
similarity index 98%
rename from docs/document/assets/start_i18n.md.DDW5i8aM.js
rename to docs/document/assets/start_i18n.md.Bc8eeWY1.js
index 4b4fd36bb..5abb1d7e8 100644
--- a/docs/document/assets/start_i18n.md.DDW5i8aM.js
+++ b/docs/document/assets/start_i18n.md.Bc8eeWY1.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.DDW5i8aM.lean.js b/docs/document/assets/start_i18n.md.Bc8eeWY1.lean.js
similarity index 100%
rename from docs/document/assets/start_i18n.md.DDW5i8aM.lean.js
rename to docs/document/assets/start_i18n.md.Bc8eeWY1.lean.js
diff --git a/docs/document/component/contextmenu.html b/docs/document/component/contextmenu.html
index 6e3a809b2..bbfdd885c 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 f2df5b8cd..f181a0099 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 255ea05e6..39ab0f968 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 24ac6d4c3..4634f7f5d 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 f98e57920..c962805e2 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 540699953..04ff47367 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 54c512695..8567b970c 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 32e928286..b91beb98c 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 139fed2e0..ee1dfdae6 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 06eb253ba..91fdc5ad6 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 c41f23e95..843b46ea8 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 f3c8eec1d..75032fcae 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 d63296124..a60a74f0e 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 bc1f54ab0..6dc968ca4 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 7b17ebe3d..9c58f77fc 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
<script>
+</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
<script>
 import Artplayer from 'artplayer'
 
 export default {
@@ -108,7 +108,7 @@
 
 <template>
   <Artplayer :option="option" :style="style" @get-instance="getInstance" />
-</template>

Artplayer Not Responsive:

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

React.js ​

jsx
import Artplayer from 'artplayer'
+</template>

Artplayer Not Responsive:

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

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 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.6, artplayer and all plugins will also provide an ESM version of mjs, such as:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
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.6, artplayer and all plugins will also provide an ESM version of mjs, such as:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
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 534ff830b..dd900ad98 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 7d89effb7..e4b4f5965 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 810c34bf3..b4a35d64d 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":"CiuUgQUt","en_start_i18n.md":"DI6iL4s5","en_start_option.md":"6JX4hU8Q","index.md":"CX90tGf9","plugin_danmuku.md":"BlYDlg9O","start_i18n.md":"DDW5i8aM","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":"CrBYmuoJ","en_start_i18n.md":"LZJYrEMl","en_start_option.md":"6JX4hU8Q","index.md":"Csi3pPGL","plugin_danmuku.md":"B787tX6f","start_i18n.md":"Bc8eeWY1","start_option.md":"B5CHO-We"} diff --git a/docs/document/index.html b/docs/document/index.html index 020143baf..fe72d9b55 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
<script>
+</html>

提示

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

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

/packages/artplayer-template

Vue.js ​

vue
<script>
 import Artplayer from 'artplayer'
 
 export default {
@@ -108,7 +108,7 @@
 
 <template>
   <Artplayer :option="option" :style="style" @get-instance="getInstance" />
-</template>

Artplayer 非响应式:

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

React.js ​

jsx
import Artplayer from 'artplayer'
+</template>

Artplayer 非响应式:

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

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 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.6 开始,artplayer 和所有插件还会提供一个 ESM 版本的 mjs,如:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
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.6 开始,artplayer 和所有插件还会提供一个 ESM 版本的 mjs,如:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
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 e428233c6..cba842099 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 4956c4dfe..e9eb8467b 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 f599955e3..caf0f9fe6 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/scripts/build.js b/scripts/build.js index 58c07fae4..e0bf31aef 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -55,7 +55,7 @@ async function build(name, targetName, clean = false) { esm: { context: 'browser', distDir, - sourceMap: true, + sourceMap: false, outputFormat: 'esmodule', isLibrary: true, engines: { @@ -105,27 +105,6 @@ async function build(name, targetName, clean = false) { const size = fs.statSync(newFilePath).size / 1024 await cpy(newFilePath, compiledPath) - if (targetName === 'esm') { - const jsFile = newFilePath - const oldMapName = 'index.js.map' - const newMapName = `${names.esm}.map` - - 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=${path.basename(newMapName)}`, - ) - fs.writeFileSync(jsFile, jsContent) - await cpy(newMapPath, compiledPath) - await cpy(jsFile, compiledPath) - } - console.log( `✨ Built@${targetName} ${name}@${version}`, `Bundles@${bundles.length}`,