build all

Refactor utility functions for improved readability and consistency

- Updated compatibility.js to use consistent line endings and formatting.
- Refactored component.js for better readability and structure, including consistent use of arrow functions and binding.
- Simplified dom.js functions with consistent formatting and improved readability.
- Enhanced emitter.js with consistent formatting and arrow function usage.
- Streamlined error.js for improved readability and consistency.
- Refactored file.js to use consistent formatting and improved readability.
- Improved format.js functions for better readability and consistency.
- Updated index.js to maintain consistent export formatting.
- Refactored property.js for improved readability and consistency.
- Enhanced subtitle.js with consistent formatting and improved readability.
- Refactored time.js for better readability and consistent formatting.

fix: update lint script to target only source files for consistency

Revert "fix: restore export statements for various plugins and update type definitions for better clarity"

This reverts commit b5e969d81ec765cd8a34b06e6ef4f232ef25087f.

fix: restore export statements for various plugins and update type definitions for better clarity

Refactor type definitions to use interfaces instead of type aliases for better extensibility and clarity across i18n, icons, option, player, quality, setting, subtitle, template, and utils modules.
This commit is contained in:
Harvey Zack committed 2025-08-03 13:17:33 +08:00
1 parent 532dd67cfd
commit 35ad9883af
447 files changed
+18248 -17946

No files matched your search

@@ -5,5 +5,5 @@
* (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:{},p="function"==typeof i[n]&&i[n],u=p.i||{},c=p.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(p)return p(t,!0);if(d&&"string"==typeof t)return d(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}u.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},u.cache={};var l=c[t]=new f.Module(t);e[t][0].call(l.exports,u,l,l.exports,i)}return c[t].exports;function u(e){var t=u.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=p,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=u,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;m<t.length;m++)f(t[m]);if(r){var h=f(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({"4omrA":[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js");s.defineInteropFlag(r),s.export(r,"default",()=>l);var a=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var o=e("@tensorflow-models/body-segmentation");function l(e={}){return t=>{let{template:{$video:r,$danmuku:n}}=t,s=null,l=null,i=null,p=null,u=!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 a.setBackend("webgl")}catch(e){console.warn("WebGL backend not available, falling back to CPU"),await a.setBackend("cpu")}}async function f(){await d();let e=o.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 o.createSegmenter(e,t),console.log("Segmenter initialized:",s),u=!0}catch(e){console.error("Error initializing segmenter:",e),u=!1}}async function m(){if(!u||r.paused||r.ended){p=requestAnimationFrame(m);return}try{l.width=r.videoWidth,l.height=r.videoHeight;let e=await s.segmentPeople(r);if(!e||0===e.length){p=requestAnimationFrame(m);return}let t=await o.toBinaryMask(e,{r:255,g:255,b:255,a:255},{r:0,g:0,b:0,a:255},c.drawContour,c.foregroundThreshold);await o.drawMask(l,r,t,c.opacity,c.maskBlurAmount);let a=i.getImageData(0,0,l.width,l.height);i.putImageData(function(e){let t=e.data;for(let e=0;e<t.length;e+=4)t[e]>250&&t[e+1]>250&&t[e+2]>250&&(t[e+3]=0);return e}(a),0,0),n.style.maskImage=`url(${l.toDataURL()})`}catch(e){console.error("Error in segmentBody:",e)}p=requestAnimationFrame(m)}async function h(){u||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",p&&(cancelAnimationFrame(p),p=null)}return t.on("ready",h),t.on("destroy",g),{name:"artplayerPluginDanmukuMask",start:h,stop:g}}}"undefined"!=typeof window&&(window.artplayerPluginDanmukuMask=l)},{"@tensorflow/tfjs-core":"1yKDM","@tensorflow/tfjs-backend-webgl":"5VdQ3","@tensorflow/tfjs-backend-cpu":"7Tpr3","@tensorflow-models/body-segmentation":"ehGbm","@parcel/transformer-js/src/esmodule-helpers.js":"w4pLy"}],"1yKDM":[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js");s.defineInteropFlag(r),e("./base_side_effects");var a=e("./optimizers/register_optimizers"),o=e("./base");s.exportAll(o,r),(0,a.registerOptimizers)()},{"./base_side_effects":"kHuGE","./optimizers/register_optimizers":"5pGXp","./base":"1T9Pk","@parcel/transformer-js/src/esmodule-helpers.js":"w4pLy"}],kHuGE:[function(e,t,r,n){var s=e("./engine");e("./flags"),e("./platforms/platform_browser"),e("./platforms/platform_node");var a=e("./ops/buffer"),o=e("./ops/cast"),l=e("./ops/clone"),i=e("./ops/print"),p=e("./tensor");(0,s.getOrMakeEngine)();let u={buffer:a.buffer,cast:o.cast,clone:l.clone,print:i.print};(0,p.setOpHandler)(u)},{"./engine":"3Kkwy","./flags":"alKWv","./platforms/platform_browser":"7iwjp","./platforms/platform_node":"lAuBP","./ops/buffer":"5Qstz"Line truncated
!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;m<t.length;m++)f(t[m]);if(r){var h=f(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({"9DY5l":[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js");s.defineInteropFlag(r),s.export(r,"default",()=>l);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;e<t.length;e+=4)t[e]>250&&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=ObjecLine truncated
//# sourceMappingURL=artplayer-plugin-danmuku-mask.esm.js.map
@@ -1 +1 @@
{"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,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CAAC,EAAE,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,IAAK,CAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,AAAF,EAAI,OAAO,CAAC,CAAA,EAAI,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,GAAI,CAAA,GAAI,CAAA,EAAE,OAAA,CAAM,EAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,Line truncated
@@ -5,4 +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 h=0;h<t.length;h++)f(t[h]);if(r){var m=f(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({jz4E5:[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js");s.defineInteropFlag(r),s.export(r,"default",()=>l);var a=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var o=e("@tensorflow-models/body-segmentation");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 a.setBackend("webgl")}catch(e){console.warn("WebGL backend not available, falling back to CPU"),await a.setBackend("cpu")}}async function f(){await d();let e=o.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 o.createSegmenter(e,t),console.log("Segmenter initialized:",s),p=!0}catch(e){console.error("Error initializing segmenter:",e),p=!1}}async function h(){if(!p||r.paused||r.ended){u=requestAnimationFrame(h);return}try{l.width=r.videoWidth,l.height=r.videoHeight;let e=await s.segmentPeople(r);if(!e||0===e.length){u=requestAnimationFrame(h);return}let t=await o.toBinaryMask(e,{r:255,g:255,b:255,a:255},{r:0,g:0,b:0,a:255},c.drawContour,c.foregroundThreshold);await o.drawMask(l,r,t,c.opacity,c.maskBlurAmount);let a=i.getImageData(0,0,l.width,l.height);i.putImageData(function(e){let t=e.data;for(let e=0;e<t.length;e+=4)t[e]>250&&t[e+1]>250&&t[e+2]>250&&(t[e+3]=0);return e}(a),0,0),n.style.maskImage=`url(${l.toDataURL()})`}catch(e){console.error("Error in segmentBody:",e)}u=requestAnimationFrame(h)}async function m(){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"}),h()}function g(){n.style.maskImage="none",u&&(cancelAnimationFrame(u),u=null)}return t.on("ready",m),t.on("destroy",g),{name:"artplayerPluginDanmukuMask",start:m,stop:g}}}"undefined"!=typeof window&&(window.artplayerPluginDanmukuMask=l)},{"@tensorflow/tfjs-core":"jhEX1","@tensorflow/tfjs-backend-webgl":"2Izis","@tensorflow/tfjs-backend-cpu":"45fLq","@tensorflow-models/body-segmentation":"ikA4O","@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],jhEX1:[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js");s.defineInteropFlag(r),e("./base_side_effects");var a=e("./optimizers/register_optimizers"),o=e("./base");s.exportAll(o,r),(0,a.registerOptimizers)()},{"./base_side_effects":"iSAWM","./optimizers/register_optimizers":"8DxTt","./base":"gLLDj","@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],iSAWM:[function(e,t,r,n){var s=e("./engine");e("./flags"),e("./platforms/platform_browser"),e("./platforms/platform_node");var a=e("./ops/buffer"),o=e("./ops/cast"),l=e("./ops/clone"),i=e("./ops/print"),u=e("./tensor");(0,s.getOrMakeEngine)();let p={buffer:a.buffer,cast:o.cast,clone:l.clone,print:i.print};(0,u.setOpHandler)(p)},{"./engine":"1cdCr","./flags":"4KDHE","./platforms/platform_browser":"lkHTQ","./platforms/platform_node":"9b1si","./ops/buffer":"lKgEf","./Line truncated
!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:{},p="function"==typeof i[n]&&i[n],u=p.i||{},c=p.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(p)return p(t,!0);if(d&&"string"==typeof t)return d(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}u.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},u.cache={};var l=c[t]=new f.Module(t);e[t][0].call(l.exports,u,l,l.exports,i)}return c[t].exports;function u(e){var t=u.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=p,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=u,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;m<t.length;m++)f(t[m]);if(r){var h=f(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({ecCzQ:[function(e,t,r,n){var s=e("@parcel/transformer-js/src/esmodule-helpers.js");s.defineInteropFlag(r),s.export(r,"default",()=>l);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,p=null,u=!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),u=!0}catch(e){console.error("Error initializing segmenter:",e),u=!1}}async function m(){if(!u||r.paused||r.ended){p=requestAnimationFrame(m);return}try{l.width=r.videoWidth,l.height=r.videoHeight;let e=await s.segmentPeople(r);if(!e||0===e.length){p=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;e<t.length;e+=4)t[e]>250&&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)}p=requestAnimationFrame(m)}async function h(){u||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",p&&(cancelAnimationFrame(p),p=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":"5Otso","@tensorflow/tfjs-core":"2Gtps","@tensorflow/tfjs-backend-webgl":"2ZcDF","@tensorflow/tfjs-backend-cpu":"b4yJT","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"5Otso":[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",()=>eJ),a.export(r,"bodyPixMaskValueToRainbowColor",()=>b),a.export(r,"createSegmenter",()=>e$),a.export(r,"drawBokehEffect",()=>eQ),a.export(r,"drawMask",()=>eZ),a.export(r,"drawPixelatedMask",()=>eY),a.export(r,"toBinaryMask",()=>eK),a.export(r,"toColoredMask",()=>eX);var o=e("@tensorflow/tfjs-core"),l=e("@tensorflow/tfjs-converter"),i=e("@mediapipe/selfie_segmentation"),p=function(e,t){return(p=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 u(e,t){function r(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var c=function(){return(c=ObjecLine truncated
@@ -5,4 +5,4 @@
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,a,o,s,i){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],l=u.i||{},p=u.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!p[t]){if(!e[t]){if(a[t])return a[t];var o="function"==typeof c[n]&&c[n];if(!r&&o)return o(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var i=p[t]=new d.Module(t);e[t][0].call(i.exports,l,i,i.exports,c)}return p[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=f,this.exports={}},d.modules=e,d.cache=p,d.parent=u,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=l,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return c[n]}}),c[n]=d;for(var h=0;h<t.length;h++)d(t[h]);if(r){var m=d(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({bzF6W:[function(e,t,r,n){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(r),a.export(r,"default",function(){return u});var o=e("@swc/helpers/cjs/_async_to_generator.cjs"),s=e("@swc/helpers/cjs/_ts_generator.cjs"),i=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var c=e("@tensorflow-models/body-segmentation");function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=t.template,n=r.$video,a=r.$danmuku,u=null,l=null,p=null,f=null,d=!1,h={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};function m(){return(m=(0,o._)(function(){return(0,s._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,i.setBackend("webgl")];case 1:case 3:return e.sent(),[3,4];case 2:return e.sent(),console.warn("WebGL backend not available, falling back to CPU"),[4,i.setBackend("cpu")];case 4:return[2]}})})).apply(this,arguments)}function g(){return(g=(0,o._)(function(){var e,t;return(0,s._)(this,function(r){switch(r.label){case 0:return[4,function(){return m.apply(this,arguments)}()];case 1:r.sent(),e=c.SupportedModels.MediaPipeSelfieSegmentation,t={runtime:"mediapipe",modelType:"general",solutionPath:h.solutionPath,modelSelection:h.modelSelection,smoothSegmentation:h.smoothSegmentation,minDetectionConfidence:h.minDetectionConfidence,minTrackingConfidence:h.minTrackingConfidence,selfieMode:h.selfieMode},r.label=2;case 2:return r.trys.push([2,4,,5]),[4,c.createSegmenter(e,t)];case 3:return console.log("Segmenter initialized:",u=r.sent()),d=!0,[3,5];case 4:return console.error("Error initializing segmenter:",r.sent()),d=!1,[3,5];case 5:return[2]}})})).apply(this,arguments)}function v(){return _.apply(this,arguments)}function _(){return(_=(0,o._)(function(){var e,t,r,o,i;return(0,s._)(this,function(s){switch(s.label){case 0:if(!d||n.paused||n.ended)return f=requestAnimationFrame(v),[2];s.label=1;case 1:return s.trys.push([1,5,,6]),l.width=n.videoWidth,l.height=n.videoHeight,[4,u.segmentPeople(n)];case 2:if(!(e=s.sent())||0===e.length)return f=requestAnimationFrame(v),[2];return t={r:255,g:255,b:255,a:255},r={r:0,g:0,b:0,a:255},[4,c.toBinaryMask(e,t,r,h.drawContour,h.foregroundThreshold)];case 3:return o=s.sent(),[4,c.drawMask(l,n,o,h.opacity,h.maskBlurAmount)];case 4:return s.sent(),i=p.getImageData(0,0,l.width,l.height),p.putImageData(function(e){for(var t=e.data,r=0;r<t.length;r+=4)t[r]>250&&t[r+1]>250&&t[r+2]>250&&(t[r+3]=0);return e}(i),0,0),a.style.maskImage="url(".concat(l.toDataURL(),")"),[3,6];case 5:return console.error("Error in segmentBody:",s.sent()),[3,6];case 6:return f=requestAnimationFrame(v),[2]}})})).apply(this,arguments)}function x(){return y.apply(this,arguments)}function y(){return(y=(0,o._)(function(){return(0,s._)(this,function(e){switch(e.label){case 0:if(d)return[3,2];return[4,function(){return g.apply(this,arguments)}()];case 1:e.sent(),e.label=2;case 2:return l||(p=(l=document.createElement("canvas")).getContext("2d")),Object.assign(a.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),v(),[2]}})})).apply(this,arguments)}function b(){a.style.maskImage="none",f&&(cancelAnimationFrame(f),f=null)}return t.on("ready",x),t.on(Line truncated
!function(e,t,r,n,a,s,o,i){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],l=u.i||{},p=u.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!p[t]){if(!e[t]){if(a[t])return a[t];var s="function"==typeof c[n]&&c[n];if(!r&&s)return s(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var o=Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var i=p[t]=new d.Module(t);e[t][0].call(i.exports,l,i,i.exports,c)}return p[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=f,this.exports={}},d.modules=e,d.cache=p,d.parent=u,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=l,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return c[n]}}),c[n]=d;for(var h=0;h<t.length;h++)d(t[h]);if(r){var m=d(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m})}}({"1FGEJ":[function(e,t,r,n){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(r),a.export(r,"default",function(){return u});var s=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_ts_generator.cjs"),i=e("@tensorflow-models/body-segmentation"),c=e("@tensorflow/tfjs-core");function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=t.template,n=r.$video,a=r.$danmuku,u=null,l=null,p=null,f=null,d=!1,h={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};function m(){return(0,s._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:if(d)return[3,2];return[4,(0,s._)(function(){var e,t;return(0,o._)(this,function(r){switch(r.label){case 0:return[4,(0,s._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,c.setBackend("webgl")];case 1:case 3:return e.sent(),[3,4];case 2:return console.warn("WebGL backend not available, falling back to CPU",e.sent().message),[4,c.setBackend("cpu")];case 4:return[2]}})})()];case 1:r.sent(),e=i.SupportedModels.MediaPipeSelfieSegmentation,t={runtime:"mediapipe",modelType:"general",solutionPath:h.solutionPath,modelSelection:h.modelSelection,smoothSegmentation:h.smoothSegmentation,minDetectionConfidence:h.minDetectionConfidence,minTrackingConfidence:h.minTrackingConfidence,selfieMode:h.selfieMode},r.label=2;case 2:return r.trys.push([2,4,,5]),[4,i.createSegmenter(e,t)];case 3:return u=r.sent(),d=!0,[3,5];case 4:return console.error("Error initializing segmenter:",r.sent()),d=!1,[3,5];case 5:return[2]}})})()];case 1:e.sent(),e.label=2;case 2:return l||(p=(l=document.createElement("canvas")).getContext("2d")),Object.assign(a.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),!function e(){return(0,s._)(function(){var t,r,s,c,m;return(0,o._)(this,function(o){switch(o.label){case 0:if(!d||n.paused||n.ended)return f=requestAnimationFrame(e),[2];o.label=1;case 1:return o.trys.push([1,5,,6]),l.width=n.videoWidth,l.height=n.videoHeight,[4,u.segmentPeople(n)];case 2:if(!(t=o.sent())||0===t.length)return f=requestAnimationFrame(e),[2];return r={r:255,g:255,b:255,a:255},s={r:0,g:0,b:0,a:255},[4,i.toBinaryMask(t,r,s,h.drawContour,h.foregroundThreshold)];case 3:return c=o.sent(),[4,i.drawMask(l,n,c,h.opacity,h.maskBlurAmount)];case 4:return o.sent(),m=p.getImageData(0,0,l.width,l.height),p.putImageData(function(e){for(var t=e.data,r=0;r<t.length;r+=4)t[r]>250&&t[r+1]>250&&t[r+2]>250&&(t[r+3]=0);return e}(m),0,0),a.style.maskImage="url(".concat(l.toDataURL(),")"),[3,6];case 5:return console.error("Error in segmentBody:",o.sent()),[3,6];case 6:return f=requestAnimationFrame(e),[2]}})})()}(),[2]}})})()}function g(){a.style.maskImage="none",f&&(cancelAnimationFrame(f),f=null)}return t.on("ready",m),t.on("destroy",g),{name:"artplayerPluginDanmukuMask",start:m,stop:g}}}e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu"),"undefined"!=typeof window&&(window.artplayerPluginDanmukuMask=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@tensorflow-models/body-segmentation":"8yK79","@tensorflow/tfjs-core":"aOH7b","@tensorflow/tfjs-backend-webgl":"8uLine truncated
@@ -1,38 +1,38 @@
{
"license": "MIT",
"version": "1.0.0",
"name": "artplayer-plugin-danmuku-mask",
"description": "Danmuku mask plugin for ArtPlayer",
"main": "dist/artplayer-plugin-danmuku-mask.js",
"legacy": "dist/artplayer-plugin-danmuku-mask.legacy.js",
"module": "dist/artplayer-plugin-danmuku-mask.esm.js",
"types": "types/artplayer-plugin-danmuku-mask.d.ts",
"exports": {
"import": "./dist/artplayer-plugin-danmuku-mask.esm.js",
"require": "./dist/artplayer-plugin-danmuku-mask.js",
"default": "./dist/artplayer-plugin-danmuku-mask.js"
},
"author": "Harvey Zack <laozhaochaguan@gmail.com>",
"browserslist": "last 1 Chrome version",
"homepage": "https://artplayer.org",
"repository": {
"type": "git",
"url": "git+https://github.com/zhw2590582/ArtPlayer.git"
},
"bugs": {
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
},
"keywords": [
"html5",
"video",
"player"
],
"dependencies": {
"@mediapipe/selfie_segmentation": "^0.1.1675465747",
"@tensorflow-models/body-segmentation": "^1.0.2",
"@tensorflow/tfjs-backend-cpu": "^4.21.0",
"@tensorflow/tfjs-backend-webgl": "^4.21.0",
"@tensorflow/tfjs-converter": "^4.21.0",
"@tensorflow/tfjs-core": "^4.21.0"
}
"name": "artplayer-plugin-danmuku-mask",
"version": "1.0.0",
"description": "Danmuku mask plugin for ArtPlayer",
"author": "Harvey Zack <laozhaochaguan@gmail.com>",
"license": "MIT",
"homepage": "https://artplayer.org",
"repository": {
"type": "git",
"url": "git+https://github.com/zhw2590582/ArtPlayer.git"
},
"bugs": {
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
},
"keywords": [
"html5",
"video",
"player"
],
"exports": {
"import": "./dist/artplayer-plugin-danmuku-mask.esm.js",
"require": "./dist/artplayer-plugin-danmuku-mask.js",
"default": "./dist/artplayer-plugin-danmuku-mask.js"
},
"main": "dist/artplayer-plugin-danmuku-mask.js",
"legacy": "dist/artplayer-plugin-danmuku-mask.legacy.js",
"module": "dist/artplayer-plugin-danmuku-mask.esm.js",
"types": "types/artplayer-plugin-danmuku-mask.d.ts",
"browserslist": "last 1 Chrome version",
"dependencies": {
"@mediapipe/selfie_segmentation": "^0.1.1675465747",
"@tensorflow-models/body-segmentation": "^1.0.2",
"@tensorflow/tfjs-backend-cpu": "^4.21.0",
"@tensorflow/tfjs-backend-webgl": "^4.21.0",
"@tensorflow/tfjs-converter": "^4.21.0",
"@tensorflow/tfjs-core": "^4.21.0"
}
}
@@ -1,161 +1,163 @@
import * as tf from '@tensorflow/tfjs-core';
import '@tensorflow/tfjs-backend-webgl';
import '@tensorflow/tfjs-backend-cpu';
import * as bodySegmentation from '@tensorflow-models/body-segmentation';
import * as bodySegmentation from '@tensorflow-models/body-segmentation'
import * as tf from '@tensorflow/tfjs-core'
import '@tensorflow/tfjs-backend-webgl'
import '@tensorflow/tfjs-backend-cpu'
export default function artplayerPluginDanmukuMask(option = {}) {
return (art) => {
const {
template: { $video, $danmuku },
} = art;
return (art) => {
const {
template: { $video, $danmuku },
} = art
let segmenter = null;
let canvas = null;
let ctx = null;
let animationFrameId = null;
let isInitialized = false;
let segmenter = null
let canvas = null
let ctx = null
let animationFrameId = null
let isInitialized = false
const config = {
solutionPath: option.solutionPath || 'https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation',
modelSelection: option.modelSelection || 1,
smoothSegmentation: option.smoothSegmentation !== undefined ? option.smoothSegmentation : true,
minDetectionConfidence: option.minDetectionConfidence || 0.5,
minTrackingConfidence: option.minTrackingConfidence || 0.5,
selfieMode: option.selfieMode || false,
drawContour: option.drawContour || false,
foregroundThreshold: option.foregroundThreshold || 0.5,
opacity: option.opacity || 1,
maskBlurAmount: option.maskBlurAmount || 3,
};
const config = {
solutionPath: option.solutionPath || 'https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation',
modelSelection: option.modelSelection || 1,
smoothSegmentation: option.smoothSegmentation !== undefined ? option.smoothSegmentation : true,
minDetectionConfidence: option.minDetectionConfidence || 0.5,
minTrackingConfidence: option.minTrackingConfidence || 0.5,
selfieMode: option.selfieMode || false,
drawContour: option.drawContour || false,
foregroundThreshold: option.foregroundThreshold || 0.5,
opacity: option.opacity || 1,
maskBlurAmount: option.maskBlurAmount || 3,
}
async function initTensorFlow() {
try {
await tf.setBackend('webgl');
} catch (error) {
console.warn('WebGL backend not available, falling back to CPU', error.message);
await tf.setBackend('cpu');
}
async function initTensorFlow() {
try {
await tf.setBackend('webgl')
}
catch (error) {
console.warn('WebGL backend not available, falling back to CPU', error.message)
await tf.setBackend('cpu')
}
}
async function initSegmenter() {
await initTensorFlow()
const model = bodySegmentation.SupportedModels.MediaPipeSelfieSegmentation
const segmenterConfig = {
runtime: 'mediapipe',
modelType: 'general',
solutionPath: config.solutionPath,
modelSelection: config.modelSelection,
smoothSegmentation: config.smoothSegmentation,
minDetectionConfidence: config.minDetectionConfidence,
minTrackingConfidence: config.minTrackingConfidence,
selfieMode: config.selfieMode,
}
try {
segmenter = await bodySegmentation.createSegmenter(model, segmenterConfig)
isInitialized = true
}
catch (error) {
console.error('Error initializing segmenter:', error)
isInitialized = false
}
}
function setupDanmukuStyle() {
Object.assign($danmuku.style, {
maskMode: 'alpha',
maskSize: 'contain',
maskRepeat: 'no-repeat',
backgroundSize: 'contain',
backgroundRepeat: 'no-repeat',
})
}
function createCanvas() {
canvas = document.createElement('canvas')
ctx = canvas.getContext('2d')
}
function makeWhiteTransparent(imageData) {
const data = imageData.data
for (let i = 0; i < data.length; i += 4) {
if (data[i] > 250 && data[i + 1] > 250 && data[i + 2] > 250) {
data[i + 3] = 0
}
}
return imageData
}
async function segmentBody() {
if (!isInitialized || $video.paused || $video.ended) {
animationFrameId = requestAnimationFrame(segmentBody)
return
}
try {
canvas.width = $video.videoWidth
canvas.height = $video.videoHeight
const segmentation = await segmenter.segmentPeople($video)
if (!segmentation || segmentation.length === 0) {
animationFrameId = requestAnimationFrame(segmentBody)
return
}
async function initSegmenter() {
await initTensorFlow();
const model = bodySegmentation.SupportedModels.MediaPipeSelfieSegmentation;
const foregroundColor = { r: 255, g: 255, b: 255, a: 255 }
const backgroundColor = { r: 0, g: 0, b: 0, a: 255 }
const mask = await bodySegmentation.toBinaryMask(
segmentation,
foregroundColor,
backgroundColor,
config.drawContour,
config.foregroundThreshold,
)
const segmenterConfig = {
runtime: 'mediapipe',
modelType: 'general',
solutionPath: config.solutionPath,
modelSelection: config.modelSelection,
smoothSegmentation: config.smoothSegmentation,
minDetectionConfidence: config.minDetectionConfidence,
minTrackingConfidence: config.minTrackingConfidence,
selfieMode: config.selfieMode,
};
await bodySegmentation.drawMask(canvas, $video, mask, config.opacity, config.maskBlurAmount)
try {
segmenter = await bodySegmentation.createSegmenter(model, segmenterConfig);
console.log('Segmenter initialized:', segmenter);
isInitialized = true;
} catch (error) {
console.error('Error initializing segmenter:', error);
isInitialized = false;
}
}
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
ctx.putImageData(makeWhiteTransparent(imageData), 0, 0)
$danmuku.style.maskImage = `url(${canvas.toDataURL()})`
}
catch (error) {
console.error('Error in segmentBody:', error)
}
function setupDanmukuStyle() {
Object.assign($danmuku.style, {
maskMode: 'alpha',
maskSize: 'contain',
maskRepeat: 'no-repeat',
backgroundSize: 'contain',
backgroundRepeat: 'no-repeat',
});
}
animationFrameId = requestAnimationFrame(segmentBody)
}
function createCanvas() {
canvas = document.createElement('canvas');
ctx = canvas.getContext('2d');
}
async function startSegmentation() {
if (!isInitialized) {
await initSegmenter()
}
if (!canvas) {
createCanvas()
}
setupDanmukuStyle()
segmentBody()
}
function makeWhiteTransparent(imageData) {
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
if (data[i] > 250 && data[i + 1] > 250 && data[i + 2] > 250) {
data[i + 3] = 0;
}
}
return imageData;
}
function stopSegmentation() {
$danmuku.style.maskImage = 'none'
if (animationFrameId) {
cancelAnimationFrame(animationFrameId)
animationFrameId = null
}
}
async function segmentBody() {
if (!isInitialized || $video.paused || $video.ended) {
animationFrameId = requestAnimationFrame(segmentBody);
return;
}
art.on('ready', startSegmentation)
art.on('destroy', stopSegmentation)
try {
canvas.width = $video.videoWidth;
canvas.height = $video.videoHeight;
const segmentation = await segmenter.segmentPeople($video);
if (!segmentation || segmentation.length === 0) {
animationFrameId = requestAnimationFrame(segmentBody);
return;
}
const foregroundColor = { r: 255, g: 255, b: 255, a: 255 };
const backgroundColor = { r: 0, g: 0, b: 0, a: 255 };
const mask = await bodySegmentation.toBinaryMask(
segmentation,
foregroundColor,
backgroundColor,
config.drawContour,
config.foregroundThreshold,
);
await bodySegmentation.drawMask(canvas, $video, mask, config.opacity, config.maskBlurAmount);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
ctx.putImageData(makeWhiteTransparent(imageData), 0, 0);
$danmuku.style.maskImage = `url(${canvas.toDataURL()})`;
} catch (error) {
console.error('Error in segmentBody:', error);
}
animationFrameId = requestAnimationFrame(segmentBody);
}
async function startSegmentation() {
if (!isInitialized) {
await initSegmenter();
}
if (!canvas) {
createCanvas();
}
setupDanmukuStyle();
segmentBody();
}
function stopSegmentation() {
$danmuku.style.maskImage = 'none';
if (animationFrameId) {
cancelAnimationFrame(animationFrameId);
animationFrameId = null;
}
}
art.on('ready', startSegmentation);
art.on('destroy', stopSegmentation);
return {
name: 'artplayerPluginDanmukuMask',
start: startSegmentation,
stop: stopSegmentation,
};
};
return {
name: 'artplayerPluginDanmukuMask',
start: startSegmentation,
stop: stopSegmentation,
}
}
}
if (typeof window !== 'undefined') {
window['artplayerPluginDanmukuMask'] = artplayerPluginDanmukuMask;
window.artplayerPluginDanmukuMask = artplayerPluginDanmukuMask
}
@@ -1,25 +1,25 @@
import type Artplayer from 'artplayer';
import type Artplayer from 'artplayer'
export = artplayerPluginDanmukuMask;
export = artplayerPluginDanmukuMask
export as namespace artplayerPluginDanmukuMask;
type Option = {
solutionPath?: string;
modelSelection?: number;
smoothSegmentation?: boolean;
minDetectionConfidence?: number;
minTrackingConfidence?: number;
selfieMode?: boolean;
drawContour?: boolean;
foregroundThreshold?: number;
opacity?: number;
maskBlurAmount?: number;
};
interface Option {
solutionPath?: string
modelSelection?: number
smoothSegmentation?: boolean
minDetectionConfidence?: number
minTrackingConfidence?: number
selfieMode?: boolean
drawContour?: boolean
foregroundThreshold?: number
opacity?: number
maskBlurAmount?: number
}
type Result = {
name: 'artplayerPluginDanmukuMask';
start: () => Promise<void>;
stop: () => void;
};
interface Result {
name: 'artplayerPluginDanmukuMask'
start: () => Promise<void>
stop: () => void
}
declare const artplayerPluginDanmukuMask: (option?: Option) => (art: Artplayer) => Result;
declare const artplayerPluginDanmukuMask: (option?: Option) => (art: Artplayer) => Result