diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bbb7212b..b9f7f22d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - The `reset` method is used to reset video request - Fix [#1014](https://github.com/zhw2590582/ArtPlayer/issues/1014) - Fix [#1023](https://github.com/zhw2590582/ArtPlayer/issues/1023) +- Add `artplayer-plugin-jassub` plugin - Add `artplayer-proxy-mediabunny` plugin - Add `artplayer-plugin-audio-track` plugin diff --git a/docs/compiled/artplayer-plugin-jassub.js b/docs/compiled/artplayer-plugin-jassub.js new file mode 100644 index 000000000..b6c2eea04 --- /dev/null +++ b/docs/compiled/artplayer-plugin-jassub.js @@ -0,0 +1,8 @@ + +/*! + * artplayer-plugin-jassub.js v1.0.0 + * Github: https://github.com/zhw2590582/ArtPlayer + * (c) 2017-2026 Harvey Zack + * Released under the MIT License. + */ +!function(e,t,s,i,a,r,n,o){var h="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},d="function"==typeof h[i]&&h[i],l=d.i||{},c=d.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(t,s){if(!c[t]){if(!e[t]){if(a[t])return a[t];var r="function"==typeof h[i]&&h[i];if(!s&&r)return r(t,!0);if(d)return d(t,!0);if(u&&"string"==typeof t)return u(t);var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}l.resolve=function(s){var i=e[t][1][s];return null!=i?i:s},l.cache={};var o=c[t]=new m.Module(t);e[t][0].call(o.exports,l,o,o.exports,h)}return c[t].exports;function l(e){var t=l.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var s={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],a=e[2]||e[0],r=m(i);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===a?Object.defineProperty(s,t,{enumerable:!0,value:r}):Object.defineProperty(s,t,{enumerable:!0,get:function(){return"default"===a?r.__esModule?r.default:r:r[a]}})}),s}return m(t)}}m.isParcelRequire=!0,m.Module=function(e){this.id=e,this.bundle=m,this.require=u,this.exports={}},m.modules=e,m.cache=c,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=l,m.register=function(t,s){e[t]=[function(e,t){t.exports=s},{}]},Object.defineProperty(m,"root",{get:function(){return h[i]}}),h[i]=m;for(var _=0;_typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({g5KxT:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o);var r=e("./jassub.es.js"),n=a.interopDefault(r);function o(e){return t=>{let s=new(0,n.default)({video:t.video,...e});return s._canvasParent.style.zIndex=20,t.on("destroy",()=>{s.destroy()}),{name:"artplayerPluginJassub",instance:s}}}"u">typeof window&&(window.artplayerPluginJassub=o)},{"./jassub.es.js":"8Qqq1","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"8Qqq1":[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o),"u">typeof HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){let t=performance.now(),s=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||s.totalVideoFrames-s.droppedVideoFrames,a=(r,n)=>{let o=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||o.totalVideoFrames-o.droppedVideoFrames;if(h>i){let i=this.mozFrameDelay||o.totalFrameDelay-s.totalFrameDelay||0,a=n-r;e(n,{presentationTime:n+1e3*i,expectedDisplayTime:n+a,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+a/1e3,presentedFrames:h,processingDuration:i}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(n,e))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(t,e)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});let r={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},n={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}};class o extends EventTarget{constructor(e){if(super(),!globalThis.Worker)throw this.destroy("Worker not supported");if(!e)throw this.destroy("No options provided");this._loaded=new Promise(e=>{this._init=e});const t=o._test();if(this._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e.onDemandRender??!0),this._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(e.offscreenRender??!0),this.timeOffset=e.timeOffset||0,this._video=e.video,this._videoHeight=0,this._videoWidth=0,this._videoColorSpace=null,this._canvas=e.canvas,this._video&&!this._canvas)this._canvasParent=document.createElement("div"),this._canvasParent.className="JASSUB",this._canvasParent.style.position="relative",this._canvas=this._createCanvas(),this._video.insertAdjacentElement("afterend",this._canvasParent);else if(!this._canvas)throw this.destroy("Don't know where to render: you should give video or canvas in options.");if(this._bufferCanvas=document.createElement("canvas"),this._bufferCtx=this._bufferCanvas.getContext("2d"),!this._bufferCtx)throw this.destroy("Canvas rendering not supported");this._canvasctrl=this._offscreenRender?this._canvas.transferControlToOffscreen():this._canvas,this._ctx=!this._offscreenRender&&this._canvasctrl.getContext("2d"),this._lastRenderTime=0,this.debug=!!e.debug,this.prescaleFactor=e.prescaleFactor||1,this.prescaleHeightLimit=e.prescaleHeightLimit||1080,this.maxRenderHeight=e.maxRenderHeight||0,this._boundResize=this.resize.bind(this),this._boundTimeUpdate=this._timeupdate.bind(this),this._boundSetRate=this.setRate.bind(this),this._boundUpdateColorSpace=this._updateColorSpace.bind(this),this._video&&this.setVideo(e.video),this._onDemandRender&&(this.busy=!1,this._lastDemandTime=null),this._worker=new Worker(e.workerUrl||"jassub-worker.js"),this._worker.onmessage=e=>this._onmessage(e),this._worker.onerror=e=>this._error(e),t.then(()=>{this._worker.postMessage({target:"init",wasmUrl:o._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:e.wasmUrl??"jassub-worker.wasm",legacyWasmUrl:e.legacyWasmUrl??"jassub-worker.wasm.js",asyncRender:"u">typeof createImageBitmap&&(e.asyncRender??!0),onDemandRender:this._onDemandRender,width:this._canvasctrl.width||0,height:this._canvasctrl.height||0,blendMode:e.blendMode||"js",subUrl:e.subUrl,subContent:e.subContent||null,fonts:e.fonts||[],availableFonts:e.availableFonts||{"liberation sans":"./default.woff2"},fallbackFont:e.fallbackFont||"liberation sans",debug:this.debug,targetFps:e.targetFps||24,dropAllAnimations:e.dropAllAnimations,dropAllBlur:e.dropAllBlur,libassMemoryLimit:e.libassMemoryLimit||0,libassGlyphLimit:e.libassGlyphLimit||0,useLocalFonts:"u">typeof queryLocalFonts&&(e.useLocalFonts??!0),hasBitmapBug:o._hasBitmapBug}),!0===this._offscreenRender&&this.sendMessage("offscreenCanvas",null,[this._canvasctrl])})}_createCanvas(){return this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvasParent.appendChild(this._canvas),this._canvas}static _supportsSIMD=null;static _hasAlphaBug=null;static _hasBitmapBug=null;static _testSIMD(){if(null===o._supportsSIMD)try{o._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch{o._supportsSIMD=!1}}static async _testImageBugs(){if(null!==o._hasBitmapBug)return;let e=document.createElement("canvas"),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch{console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,s,i){let a=t.createImageData(s,i);return e&&a.data.set(e),a}}let s=document.createElement("canvas"),i=s.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("Canvas rendering not supported");e.width=s.width=1,e.height=s.height=1,t.clearRect(0,0,1,1),i.clearRect(0,0,1,1);let a=i.getImageData(0,0,1,1).data;t.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0);let r=i.getImageData(0,0,1,1).data;if(o._hasAlphaBug=a[1]!==r[1],o._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),"u">typeof createImageBitmap){let e=new Uint8ClampedArray([255,0,255,0,255]).subarray(1,5);i.drawImage(await createImageBitmap(new ImageData(e,1)),0,0);let{data:t}=i.getImageData(0,0,1,1);for(let[s,i]of(o._hasBitmapBug=!1,t.entries()))if(Math.abs(e[s]-i)>15){o._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}else o._hasBitmapBug=!1;e.remove(),s.remove()}static async _test(){o._testSIMD(),await o._testImageBugs()}resize(e=0,t=0,s=0,i=0,a=this._video?.paused){if((!e||!t)&&this._video){let a=this._getVideoPosition(),r=null;if(this._videoWidth){let e=this._video.videoWidth/this._videoWidth,t=this._video.videoHeight/this._videoHeight;r=this._computeCanvasSize((a.width||0)/e,(a.height||0)/t)}else r=this._computeCanvasSize(a.width||0,a.height||0);e=r.width,t=r.height,this._canvasParent&&(s=a.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=a.x),this._canvas.style.width=a.width+"px",this._canvas.style.height=a.height+"px"}this._canvas.style.top=s+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:e,height:t,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}_getVideoPosition(e=this._video.videoWidth,t=this._video.videoHeight){let s=e/t,{offsetWidth:i,offsetHeight:a}=this._video;e=i,t=a,i/a>s?e=Math.floor(a*s):t=Math.floor(i/s);let r=(i-e)/2,n=(a-t)/2;return{width:e,height:t,x:r,y:n}}_computeCanvasSize(e=0,t=0){let s=this.prescaleFactor<=0?1:this.prescaleFactor,i=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{let a=s<1?-1:1,r=t*i;a*r*s<=a*this.prescaleHeightLimit?r*=s:a*r0&&r>this.maxRenderHeight&&(r=this.maxRenderHeight),e*=r/t,t=r}return{width:e,height:t}}_timeupdate({type:e}){let t={seeking:!0,waiting:!0,playing:!1}[e];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}setVideo(e){e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),"u">typeof ResizeObserver&&(this._ro||(this._ro=new ResizeObserver(()=>this.resize())),this._ro.observe(e))):this._error("Video element invalid!")}runBenchmark(){this.sendMessage("runBenchmark")}setTrackByUrl(e){this.sendMessage("setTrackByUrl",{url:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}setTrack(e){this.sendMessage("setTrack",{content:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}freeTrack(){this.sendMessage("freeTrack")}setIsPaused(e){this.sendMessage("video",{isPaused:e})}setRate(e){this.sendMessage("video",{rate:e})}setCurrentTime(e,t,s){this.sendMessage("video",{isPaused:e,currentTime:t,rate:s,colorSpace:this._videoColorSpace})}createEvent(e){this.sendMessage("createEvent",{event:e})}setEvent(e,t){this.sendMessage("setEvent",{event:e,index:t})}removeEvent(e){this.sendMessage("removeEvent",{index:e})}getEvents(e){this._fetchFromWorker({target:"getEvents"},(t,{events:s})=>{e(t,s)})}styleOverride(e){this.sendMessage("styleOverride",{style:e})}disableStyleOverride(){this.sendMessage("disableStyleOverride")}createStyle(e){this.sendMessage("createStyle",{style:e})}setStyle(e,t){this.sendMessage("setStyle",{style:e,index:t})}removeStyle(e){this.sendMessage("removeStyle",{index:e})}getStyles(e){this._fetchFromWorker({target:"getStyles"},(t,{styles:s})=>{e(t,s)})}addFont(e){this.sendMessage("addFont",{font:e})}setDefaultFont(e){this.sendMessage("defaultFont",{font:e})}_sendLocalFont(e){try{queryLocalFonts().then(t=>{let s=t?.find(t=>t.fullName.toLowerCase()===e);s&&s.blob().then(e=>{e.arrayBuffer().then(e=>{this.addFont(new Uint8Array(e))})})})}catch(e){console.warn("Local fonts API:",e)}}_getLocalFont({font:e}){try{navigator?.permissions?.query?navigator.permissions.query({name:"local-fonts"}).then(t=>{"granted"===t.state&&this._sendLocalFont(e)}):this._sendLocalFont(e)}catch(e){console.warn("Local fonts API:",e)}}_unbusy(){this._lastDemandTime?this._demandRender(this._lastDemandTime):this.busy=!1}_handleRVFC(e,{mediaTime:t,width:s,height:i}){if(this._destroyed)return null;this.busy?this._lastDemandTime={mediaTime:t,width:s,height:i}:(this.busy=!0,this._demandRender({mediaTime:t,width:s,height:i})),this._video.requestVideoFrameCallback(this._handleRVFC.bind(this))}_demandRender({mediaTime:e,width:t,height:s}){this._lastDemandTime=null,(t!==this._videoWidth||s!==this._videoHeight)&&(this._videoWidth=t,this._videoHeight=s,this.resize()),this.sendMessage("demand",{time:e+this.timeOffset})}_detachOffscreen(){if(!this._offscreenRender||this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas,this._ctx=this._canvasctrl.getContext("2d"),this.sendMessage("detachOffscreen"),this.busy=!1,this.resize(0,0,0,0,!0)}_reAttachOffscreen(){if(!this._offscreenRender||!this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas.transferControlToOffscreen(),this._ctx=!1,this.sendMessage("offscreenCanvas",null,[this._canvasctrl]),this.resize(0,0,0,0,!0)}_updateColorSpace(){this._video.requestVideoFrameCallback(()=>{try{let e=new VideoFrame(this._video);this._videoColorSpace=r[e.colorSpace.matrix],e.close(),this.sendMessage("getColorSpace")}catch(e){console.warn(e)}})}_verifyColorSpace({subtitleColorSpace:e,videoColorSpace:t=this._videoColorSpace}){e&&t&&e!==t&&(this._detachOffscreen(),this._ctx.filter=`url("data:image/svg+xml;utf8,#f")`)}_render({images:e,asyncRender:t,times:s,width:i,height:a,colorSpace:r}){for(let n of(this._unbusy(),this.debug&&(s.IPCTime=Date.now()-s.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:r})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height),e))n.image&&(t?(this._ctx.drawImage(n.image,n.x,n.y),n.image.close()):(this._bufferCanvas.width=n.w,this._bufferCanvas.height=n.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(n.image)),n.w,n.h),0,0),this._ctx.drawImage(this._bufferCanvas,n.x,n.y)));if(this.debug){s.JSRenderTime=Date.now()-s.JSRenderTime-s.IPCTime;let t=0,i=s.bitmaps||e.length;for(let e in delete s.bitmaps,s)t+=s[e];console.log("Bitmaps: "+i+" Total: "+(0|t)+"ms",s)}}_fixAlpha(e){if(o._hasAlphaBug)for(let t=3;t1?e[t]:1;return e}_ready(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}async sendMessage(e,t={},s){await this._loaded,s?this._worker.postMessage({target:e,transferable:s,...t},[...s]):this._worker.postMessage({target:e,...t})}_fetchFromWorker(e,t){try{let s=e.target,i=setTimeout(()=>{r(Error("Error: Timeout while try to fetch "+s))},5e3),a=({data:e})=>{e.target===s&&(t(null,e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i))},r=e=>{t(e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",r),this._worker.postMessage(e)}catch(e){this._error(e)}}_console({content:e,command:t}){console[t].apply(console,JSON.parse(e))}_onmessage({data:e}){this["_"+e.target]&&this["_"+e.target](e)}_error(e){let t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),s=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(s),console.error(t),t}_removeListeners(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}destroy(e){return e&&(e=this._error(e)),this._video&&this._canvasParent&&this._video.parentNode?.removeChild(this._canvasParent),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),this._worker?.terminate(),e}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,s,i){s.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},s.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},s.exportAll=function(e,t){return Object.keys(e).forEach(function(s){"default"===s||"__esModule"===s||Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[s]}})}),t},s.export=function(e,t,s){Object.defineProperty(e,t,{enumerable:!0,get:s})}},{}]},["g5KxT"],"g5KxT","parcelRequire4dc0",{}); \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-jassub.legacy.js b/docs/compiled/artplayer-plugin-jassub.legacy.js new file mode 100644 index 000000000..d5ca1c56e --- /dev/null +++ b/docs/compiled/artplayer-plugin-jassub.legacy.js @@ -0,0 +1,8 @@ + +/*! + * artplayer-plugin-jassub.js v1.0.0 + * Github: https://github.com/zhw2590582/ArtPlayer + * (c) 2017-2026 Harvey Zack + * Released under the MIT License. + */ +!function(e,t,r,n,i,a,s,o){var c="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},l="function"==typeof c[n]&&c[n],u=l.i||{},d=l.cache||{},f="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function h(t,r){if(!d[t]){if(!e[t]){if(i[t])return i[t];var a="function"==typeof c[n]&&c[n];if(!r&&a)return a(t,!0);if(l)return l(t,!0);if(f&&"string"==typeof t)return f(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}u.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},u.cache={};var o=d[t]=new h.Module(t);e[t][0].call(o.exports,u,o,o.exports,c)}return d[t].exports;function u(e){var t=u.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],n=e[1],i=e[2]||e[0],a=h(n);"*"===t?Object.keys(a).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})}):"*"===i?Object.defineProperty(r,t,{enumerable:!0,value:a}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===i?a.__esModule?a.default:a:a[i]}})}),r}return h(t)}}h.isParcelRequire=!0,h.Module=function(e){this.id=e,this.bundle=h,this.require=f,this.exports={}},h.modules=e,h.cache=d,h.parent=l,h.distDir=void 0,h.publicUrl=void 0,h.devServer=void 0,h.i=u,h.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(h,"root",{get:function(){return c[n]}}),c[n]=h;for(var _=0;_typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({k1Tni:[function(e,t,r,n){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"default",function(){return c});var a=e("@swc/helpers/cjs/_object_spread.cjs"),s=e("./jassub.es.js"),o=i.interopDefault(s);function c(e){return function(t){var r=new(0,o.default)((0,a._)({video:t.video},e));return r._canvasParent.style.zIndex=20,t.on("destroy",function(){r.destroy()}),{name:"artplayerPluginJassub",instance:r}}}"u">typeof window&&(window.artplayerPluginJassub=c)},{"@swc/helpers/cjs/_object_spread.cjs":"kyoEj","./jassub.es.js":"5H1mY","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],kyoEj:[function(e,t,r,n){"use strict";var i=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;ti){var u=t.mozFrameDelay||c.totalFrameDelay-n.totalFrameDelay||0,d=o-s;e(o,{presentationTime:o+1e3*u,expectedDisplayTime:o+d,width:t.videoWidth,height:t.videoHeight,mediaTime:Math.max(0,t.currentTime||0)+d/1e3,presentedFrames:l,processingDuration:u}),delete t._rvfcpolyfillmap[r]}else t._rvfcpolyfillmap[r]=requestAnimationFrame(function(e){return a(o,e)})};return this._rvfcpolyfillmap[r]=requestAnimationFrame(function(e){return a(r,e)}),r},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});var m={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},y={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}},b=function(e){"use strict";function t(e){if((0,o._)(this,t),r=(0,s._)(this,t),!globalThis.Worker)throw r.destroy("Worker not supported");if(!e)throw r.destroy("No options provided");r._loaded=new Promise(function(e){r._init=e});var r,n,i,a=t._test();if(r._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(null==(n=e.onDemandRender)||n),r._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(null==(i=e.offscreenRender)||i),r.timeOffset=e.timeOffset||0,r._video=e.video,r._videoHeight=0,r._videoWidth=0,r._videoColorSpace=null,r._canvas=e.canvas,r._video&&!r._canvas)r._canvasParent=document.createElement("div"),r._canvasParent.className="JASSUB",r._canvasParent.style.position="relative",r._canvas=r._createCanvas(),r._video.insertAdjacentElement("afterend",r._canvasParent);else if(!r._canvas)throw r.destroy("Don't know where to render: you should give video or canvas in options.");if(r._bufferCanvas=document.createElement("canvas"),r._bufferCtx=r._bufferCanvas.getContext("2d"),!r._bufferCtx)throw r.destroy("Canvas rendering not supported");return r._canvasctrl=r._offscreenRender?r._canvas.transferControlToOffscreen():r._canvas,r._ctx=!r._offscreenRender&&r._canvasctrl.getContext("2d"),r._lastRenderTime=0,r.debug=!!e.debug,r.prescaleFactor=e.prescaleFactor||1,r.prescaleHeightLimit=e.prescaleHeightLimit||1080,r.maxRenderHeight=e.maxRenderHeight||0,r._boundResize=r.resize.bind(r),r._boundTimeUpdate=r._timeupdate.bind(r),r._boundSetRate=r.setRate.bind(r),r._boundUpdateColorSpace=r._updateColorSpace.bind(r),r._video&&r.setVideo(e.video),r._onDemandRender&&(r.busy=!1,r._lastDemandTime=null),r._worker=new Worker(e.workerUrl||"jassub-worker.js"),r._worker.onmessage=function(e){return r._onmessage(e)},r._worker.onerror=function(e){return r._error(e)},a.then(function(){var n,i,a,s;r._worker.postMessage({target:"init",wasmUrl:t._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:null!=(n=e.wasmUrl)?n:"jassub-worker.wasm",legacyWasmUrl:null!=(i=e.legacyWasmUrl)?i:"jassub-worker.wasm.js",asyncRender:("u"0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null==(e=this._video)?void 0:e.paused;if((!t||!r)&&this._video){var s=this._getVideoPosition(),o=null;if(this._videoWidth){var c=this._video.videoWidth/this._videoWidth,l=this._video.videoHeight/this._videoHeight;o=this._computeCanvasSize((s.width||0)/c,(s.height||0)/l)}else o=this._computeCanvasSize(s.width||0,s.height||0);t=o.width,r=o.height,this._canvasParent&&(n=s.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=s.x),this._canvas.style.width=s.width+"px",this._canvas.style.height=s.height+"px"}this._canvas.style.top=n+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:t,height:r,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}},{key:"_getVideoPosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._video.videoWidth,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._video.videoHeight,r=e/t,n=this._video,i=n.offsetWidth,a=n.offsetHeight;e=i,t=a,i/a>r?e=Math.floor(a*r):t=Math.floor(i/r);var s=(i-e)/2,o=(a-t)/2;return{width:e,height:t,x:s,y:o}}},{key:"_computeCanvasSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.prescaleFactor<=0?1:this.prescaleFactor,n=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{var i=r<1?-1:1,a=t*n;i*a*r<=i*this.prescaleHeightLimit?a*=r:i*a0&&a>this.maxRenderHeight&&(a=this.maxRenderHeight),e*=a/t,t=a}return{width:e,height:t}}},{key:"_timeupdate",value:function(e){var t={seeking:!0,waiting:!0,playing:!1}[e.type];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}},{key:"setVideo",value:function(e){var t=this;e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),("u"#f\")"))}},{key:"_render",value:function(e){var t=e.images,r=e.asyncRender,n=e.times,i=e.width,a=e.height,s=e.colorSpace;this._unbusy(),this.debug&&(n.IPCTime=Date.now()-n.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:s})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height);var o=!0,c=!1,l=void 0;try{for(var u,d=t[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){var f=u.value;f.image&&(r?(this._ctx.drawImage(f.image,f.x,f.y),f.image.close()):(this._bufferCanvas.width=f.w,this._bufferCanvas.height=f.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(f.image)),f.w,f.h),0,0),this._ctx.drawImage(this._bufferCanvas,f.x,f.y)))}}catch(e){c=!0,l=e}finally{try{o||null==d.return||d.return()}finally{if(c)throw l}}if(this.debug){n.JSRenderTime=Date.now()-n.JSRenderTime-n.IPCTime;var h=0,_=n.bitmaps||t.length;for(var v in delete n.bitmaps,n)h+=n[v];console.log("Bitmaps: "+_+" Total: "+(0|h)+"ms",n)}}},{key:"_fixAlpha",value:function(e){if(t._hasAlphaBug)for(var r=3;r1?e[r]:1;return e}},{key:"_ready",value:function(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}},{key:"sendMessage",value:function(e,t){return(0,a._)(function(e){var t,r,n=arguments;return(0,p._)(this,function(i){switch(i.label){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:{},r=n.length>2?n[2]:void 0,[4,this._loaded];case 1:return i.sent(),r?this._worker.postMessage((0,d._)({target:e,transferable:r},t),(0,h._)(r)):this._worker.postMessage((0,d._)({target:e},t)),[2]}})}).apply(this,arguments)}},{key:"_fetchFromWorker",value:function(e,t){var r=this;try{var n=e.target,i=setTimeout(function(){s(Error("Error: Timeout while try to fetch "+n))},5e3),a=function(e){var o=e.data;o.target===n&&(t(null,o),r._worker.removeEventListener("message",a),r._worker.removeEventListener("error",s),clearTimeout(i))},s=function(e){t(e),r._worker.removeEventListener("message",a),r._worker.removeEventListener("error",s),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",s),this._worker.postMessage(e)}catch(e){this._error(e)}}},{key:"_console",value:function(e){var t=e.content,r=e.command;console[r].apply(console,JSON.parse(t))}},{key:"_onmessage",value:function(e){var t=e.data;this["_"+t.target]&&this["_"+t.target](t)}},{key:"_error",value:function(e){var t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),r=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(r),console.error(t),t}},{key:"_removeListeners",value:function(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}},{key:"destroy",value:function(e){var t,r;return e&&(e=this._error(e)),this._video&&this._canvasParent&&(null==(t=this._video.parentNode)||t.removeChild(this._canvasParent)),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),null==(r=this._worker)||r.terminate(),e}}],[{key:"_testSIMD",value:function(){if(null===t._supportsSIMD)try{t._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch(e){t._supportsSIMD=!1}}},{key:"_testImageBugs",value:function(){return(0,a._)(function(){var e,r,n,i,a,s,o,c,l,u,d,h,v,m,y,b,g;return(0,p._)(this,function(p){switch(p.label){case 0:if(null!==t._hasBitmapBug)return[2];if(!(r=(e=document.createElement("canvas")).getContext("2d",{willReadFrequently:!0})))throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch(e){console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,t,n){var i=r.createImageData(t,n);return e&&i.data.set(e),i}}if(!(i=(n=document.createElement("canvas")).getContext("2d",{willReadFrequently:!0})))throw Error("Canvas rendering not supported");if(e.width=n.width=1,e.height=n.height=1,r.clearRect(0,0,1,1),i.clearRect(0,0,1,1),a=i.getImageData(0,0,1,1).data,r.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0),s=i.getImageData(0,0,1,1).data,t._hasAlphaBug=a[1]!==s[1],t._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),!(("u"15){t._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}catch(e){d=!0,h=e}finally{try{u||null==v.return||v.return()}finally{if(d)throw h}}return[3,3];case 2:t._hasBitmapBug=!1,p.label=3;case 3:return e.remove(),n.remove(),[2]}})})()}},{key:"_test",value:function(){return(0,a._)(function(){return(0,p._)(this,function(e){switch(e.label){case 0:return t._testSIMD(),[4,t._testImageBugs()];case 1:return e.sent(),[2]}})})()}}]),t}((0,v._)(EventTarget));(0,l._)(b,"_supportsSIMD",null),(0,l._)(b,"_hasAlphaBug",null),(0,l._)(b,"_hasBitmapBug",null)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_define_property.cjs":"ltU3W","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_sliced_to_array.cjs":"gIQTH","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@swc/helpers/cjs/_wrap_native_super.cjs":"j8pRR","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function i(e,t,r,n,i,a,s){try{var o=e[a](s),c=o.value}catch(e){r(e);return}o.done?t(c):Promise.resolve(c).then(n,i)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,c,"next",e)}function c(e){i(s,n,a,o,c,"throw",e)}o(void 0)})}}},{}],clpdF:[function(e,t,r,n){"use strict";var i=e("feddc910f69a01a6"),a=e("b644f6b72647b399"),s=e("ba991daace2b8ed9");r._=function(e,t,r){return t=i._(t),s._(e,a._()?Reflect.construct(t,r||[],i._(e).constructor):t.apply(e,r))}},{feddc910f69a01a6:"NOGHw",b644f6b72647b399:"83nDe",ba991daace2b8ed9:"hd12h"}],NOGHw:[function(e,t,r,n){"use strict";function i(e){return r._=i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}r._=i},{}],"83nDe":[function(e,t,r,n){"use strict";function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(r._=i=function(){return!!e})()}r._=i},{}],hd12h:[function(e,t,r,n){"use strict";var i=e("f7151fe13994d2aa"),a=e("f18e81760bb14899");r._=function(e,t){return t&&("object"===a._(t)||"function"==typeof t)?t:i._(e)}},{f7151fe13994d2aa:"1tlYe",f18e81760bb14899:"iXhRw"}],"1tlYe":[function(e,t,r,n){"use strict";r._=function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},{}],iXhRw:[function(e,t,r,n){"use strict";r._=function(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}},{}],"4Uf9M":[function(e,t,r,n){"use strict";r._=function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}},{}],igUuK:[function(e,t,r,n){"use strict";function i(e,t){for(var r=0;rtypeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(r=i.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,n=e}finally{try{s||null==i.return||i.return()}finally{if(o)throw n}}return a}}},{}],heYSj:[function(e,t,r,n){"use strict";r._=function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],fh7mx:[function(e,t,r,n){"use strict";var i=e("3ee51b7dc02d0c44");r._=function(e,t){if(e){if("string"==typeof e)return i._(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i._(e,t)}}},{"3ee51b7dc02d0c44":"1WOAB"}],"1WOAB":[function(e,t,r,n){"use strict";r._=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);rtypeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}},{}],fWabh:[function(e,t,r,n){"use strict";r._=function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],j8pRR:[function(e,t,r,n){"use strict";var i=e("c8857d56f4968279"),a=e("2ed7bdf1701f2d07"),s=e("5c5ad8846076b9cd"),o=e("2db6fa09e8a5be4c");function c(e){var t="function"==typeof Map?new Map:void 0;return r._=c=function(e){if(null===e||!s._(e))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return i._(e,arguments,a._(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o._(r,e)},c(e)}r._=c},{c8857d56f4968279:"bC52X","2ed7bdf1701f2d07":"NOGHw","5c5ad8846076b9cd":"1mpbk","2db6fa09e8a5be4c":"7ubVA"}],bC52X:[function(e,t,r,n){"use strict";var i=e("62fc231ae2e75266"),a=e("3f98bf9d4f706151");function s(e,t,n){return i._()?r._=s=Reflect.construct:r._=s=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a._(i,r.prototype),i},s.apply(null,arguments)}r._=s},{"62fc231ae2e75266":"83nDe","3f98bf9d4f706151":"7ubVA"}],"1mpbk":[function(e,t,r,n){"use strict";r._=function(e){return -1!==Function.toString.call(e).indexOf("[native code]")}},{}],eltGh:[function(e,t,r,n){"use strict";r._=function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(s,"next",{value:c(0)}),o(s,"throw",{value:c(1)}),o(s,"return",{value:c(2)}),"function"==typeof Symbol&&o(s,Symbol.iterator,{value:function(){return this}}),s;function c(o){return function(c){var l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&l[0]?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},d="function"==typeof h[i]&&h[i],l=d.i||{},c=d.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(t,s){if(!c[t]){if(!e[t]){if(a[t])return a[t];var r="function"==typeof h[i]&&h[i];if(!s&&r)return r(t,!0);if(d)return d(t,!0);if(u&&"string"==typeof t)return u(t);var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}l.resolve=function(s){var i=e[t][1][s];return null!=i?i:s},l.cache={};var o=c[t]=new m.Module(t);e[t][0].call(o.exports,l,o,o.exports,h)}return c[t].exports;function l(e){var t=l.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var s={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],a=e[2]||e[0],r=m(i);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===a?Object.defineProperty(s,t,{enumerable:!0,value:r}):Object.defineProperty(s,t,{enumerable:!0,get:function(){return"default"===a?r.__esModule?r.default:r:r[a]}})}),s}return m(t)}}m.isParcelRequire=!0,m.Module=function(e){this.id=e,this.bundle=m,this.require=u,this.exports={}},m.modules=e,m.cache=c,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=l,m.register=function(t,s){e[t]=[function(e,t){t.exports=s},{}]},Object.defineProperty(m,"root",{get:function(){return h[i]}}),h[i]=m;for(var _=0;_typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({bm4Y0:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o);var r=e("./jassub.es.js"),n=a.interopDefault(r);function o(e){return t=>{let s=new(0,n.default)({video:t.video,...e});return s._canvasParent.style.zIndex=20,t.on("destroy",()=>{s.destroy()}),{name:"artplayerPluginJassub",instance:s}}}"u">typeof window&&(window.artplayerPluginJassub=o)},{"./jassub.es.js":"kL36e","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],kL36e:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o),"u">typeof HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){let t=performance.now(),s=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||s.totalVideoFrames-s.droppedVideoFrames,a=(r,n)=>{let o=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||o.totalVideoFrames-o.droppedVideoFrames;if(h>i){let i=this.mozFrameDelay||o.totalFrameDelay-s.totalFrameDelay||0,a=n-r;e(n,{presentationTime:n+1e3*i,expectedDisplayTime:n+a,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+a/1e3,presentedFrames:h,processingDuration:i}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(n,e))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(t,e)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});let r={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},n={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}};class o extends EventTarget{constructor(e){if(super(),!globalThis.Worker)throw this.destroy("Worker not supported");if(!e)throw this.destroy("No options provided");this._loaded=new Promise(e=>{this._init=e});let t=o._test();if(this._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e.onDemandRender??!0),this._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(e.offscreenRender??!0),this.timeOffset=e.timeOffset||0,this._video=e.video,this._videoHeight=0,this._videoWidth=0,this._videoColorSpace=null,this._canvas=e.canvas,this._video&&!this._canvas)this._canvasParent=document.createElement("div"),this._canvasParent.className="JASSUB",this._canvasParent.style.position="relative",this._canvas=this._createCanvas(),this._video.insertAdjacentElement("afterend",this._canvasParent);else if(!this._canvas)throw this.destroy("Don't know where to render: you should give video or canvas in options.");if(this._bufferCanvas=document.createElement("canvas"),this._bufferCtx=this._bufferCanvas.getContext("2d"),!this._bufferCtx)throw this.destroy("Canvas rendering not supported");this._canvasctrl=this._offscreenRender?this._canvas.transferControlToOffscreen():this._canvas,this._ctx=!this._offscreenRender&&this._canvasctrl.getContext("2d"),this._lastRenderTime=0,this.debug=!!e.debug,this.prescaleFactor=e.prescaleFactor||1,this.prescaleHeightLimit=e.prescaleHeightLimit||1080,this.maxRenderHeight=e.maxRenderHeight||0,this._boundResize=this.resize.bind(this),this._boundTimeUpdate=this._timeupdate.bind(this),this._boundSetRate=this.setRate.bind(this),this._boundUpdateColorSpace=this._updateColorSpace.bind(this),this._video&&this.setVideo(e.video),this._onDemandRender&&(this.busy=!1,this._lastDemandTime=null),this._worker=new Worker(e.workerUrl||"jassub-worker.js"),this._worker.onmessage=e=>this._onmessage(e),this._worker.onerror=e=>this._error(e),t.then(()=>{this._worker.postMessage({target:"init",wasmUrl:o._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:e.wasmUrl??"jassub-worker.wasm",legacyWasmUrl:e.legacyWasmUrl??"jassub-worker.wasm.js",asyncRender:"u">typeof createImageBitmap&&(e.asyncRender??!0),onDemandRender:this._onDemandRender,width:this._canvasctrl.width||0,height:this._canvasctrl.height||0,blendMode:e.blendMode||"js",subUrl:e.subUrl,subContent:e.subContent||null,fonts:e.fonts||[],availableFonts:e.availableFonts||{"liberation sans":"./default.woff2"},fallbackFont:e.fallbackFont||"liberation sans",debug:this.debug,targetFps:e.targetFps||24,dropAllAnimations:e.dropAllAnimations,dropAllBlur:e.dropAllBlur,libassMemoryLimit:e.libassMemoryLimit||0,libassGlyphLimit:e.libassGlyphLimit||0,useLocalFonts:"u">typeof queryLocalFonts&&(e.useLocalFonts??!0),hasBitmapBug:o._hasBitmapBug}),!0===this._offscreenRender&&this.sendMessage("offscreenCanvas",null,[this._canvasctrl])})}_createCanvas(){return this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvasParent.appendChild(this._canvas),this._canvas}static _supportsSIMD=null;static _hasAlphaBug=null;static _hasBitmapBug=null;static _testSIMD(){if(null===o._supportsSIMD)try{o._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch{o._supportsSIMD=!1}}static async _testImageBugs(){if(null!==o._hasBitmapBug)return;let e=document.createElement("canvas"),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch{console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,s,i){let a=t.createImageData(s,i);return e&&a.data.set(e),a}}let s=document.createElement("canvas"),i=s.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("Canvas rendering not supported");e.width=s.width=1,e.height=s.height=1,t.clearRect(0,0,1,1),i.clearRect(0,0,1,1);let a=i.getImageData(0,0,1,1).data;t.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0);let r=i.getImageData(0,0,1,1).data;if(o._hasAlphaBug=a[1]!==r[1],o._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),"u">typeof createImageBitmap){let e=new Uint8ClampedArray([255,0,255,0,255]).subarray(1,5);i.drawImage(await createImageBitmap(new ImageData(e,1)),0,0);let{data:t}=i.getImageData(0,0,1,1);for(let[s,i]of(o._hasBitmapBug=!1,t.entries()))if(Math.abs(e[s]-i)>15){o._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}else o._hasBitmapBug=!1;e.remove(),s.remove()}static async _test(){o._testSIMD(),await o._testImageBugs()}resize(e=0,t=0,s=0,i=0,a=this._video?.paused){if((!e||!t)&&this._video){let a=this._getVideoPosition(),r=null;if(this._videoWidth){let e=this._video.videoWidth/this._videoWidth,t=this._video.videoHeight/this._videoHeight;r=this._computeCanvasSize((a.width||0)/e,(a.height||0)/t)}else r=this._computeCanvasSize(a.width||0,a.height||0);e=r.width,t=r.height,this._canvasParent&&(s=a.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=a.x),this._canvas.style.width=a.width+"px",this._canvas.style.height=a.height+"px"}this._canvas.style.top=s+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:e,height:t,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}_getVideoPosition(e=this._video.videoWidth,t=this._video.videoHeight){let s=e/t,{offsetWidth:i,offsetHeight:a}=this._video;e=i,t=a,i/a>s?e=Math.floor(a*s):t=Math.floor(i/s);let r=(i-e)/2,n=(a-t)/2;return{width:e,height:t,x:r,y:n}}_computeCanvasSize(e=0,t=0){let s=this.prescaleFactor<=0?1:this.prescaleFactor,i=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{let a=s<1?-1:1,r=t*i;a*r*s<=a*this.prescaleHeightLimit?r*=s:a*r0&&r>this.maxRenderHeight&&(r=this.maxRenderHeight),e*=r/t,t=r}return{width:e,height:t}}_timeupdate({type:e}){let t={seeking:!0,waiting:!0,playing:!1}[e];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}setVideo(e){e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),"u">typeof ResizeObserver&&(this._ro||(this._ro=new ResizeObserver(()=>this.resize())),this._ro.observe(e))):this._error("Video element invalid!")}runBenchmark(){this.sendMessage("runBenchmark")}setTrackByUrl(e){this.sendMessage("setTrackByUrl",{url:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}setTrack(e){this.sendMessage("setTrack",{content:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}freeTrack(){this.sendMessage("freeTrack")}setIsPaused(e){this.sendMessage("video",{isPaused:e})}setRate(e){this.sendMessage("video",{rate:e})}setCurrentTime(e,t,s){this.sendMessage("video",{isPaused:e,currentTime:t,rate:s,colorSpace:this._videoColorSpace})}createEvent(e){this.sendMessage("createEvent",{event:e})}setEvent(e,t){this.sendMessage("setEvent",{event:e,index:t})}removeEvent(e){this.sendMessage("removeEvent",{index:e})}getEvents(e){this._fetchFromWorker({target:"getEvents"},(t,{events:s})=>{e(t,s)})}styleOverride(e){this.sendMessage("styleOverride",{style:e})}disableStyleOverride(){this.sendMessage("disableStyleOverride")}createStyle(e){this.sendMessage("createStyle",{style:e})}setStyle(e,t){this.sendMessage("setStyle",{style:e,index:t})}removeStyle(e){this.sendMessage("removeStyle",{index:e})}getStyles(e){this._fetchFromWorker({target:"getStyles"},(t,{styles:s})=>{e(t,s)})}addFont(e){this.sendMessage("addFont",{font:e})}setDefaultFont(e){this.sendMessage("defaultFont",{font:e})}_sendLocalFont(e){try{queryLocalFonts().then(t=>{let s=t?.find(t=>t.fullName.toLowerCase()===e);s&&s.blob().then(e=>{e.arrayBuffer().then(e=>{this.addFont(new Uint8Array(e))})})})}catch(e){console.warn("Local fonts API:",e)}}_getLocalFont({font:e}){try{navigator?.permissions?.query?navigator.permissions.query({name:"local-fonts"}).then(t=>{"granted"===t.state&&this._sendLocalFont(e)}):this._sendLocalFont(e)}catch(e){console.warn("Local fonts API:",e)}}_unbusy(){this._lastDemandTime?this._demandRender(this._lastDemandTime):this.busy=!1}_handleRVFC(e,{mediaTime:t,width:s,height:i}){if(this._destroyed)return null;this.busy?this._lastDemandTime={mediaTime:t,width:s,height:i}:(this.busy=!0,this._demandRender({mediaTime:t,width:s,height:i})),this._video.requestVideoFrameCallback(this._handleRVFC.bind(this))}_demandRender({mediaTime:e,width:t,height:s}){this._lastDemandTime=null,(t!==this._videoWidth||s!==this._videoHeight)&&(this._videoWidth=t,this._videoHeight=s,this.resize()),this.sendMessage("demand",{time:e+this.timeOffset})}_detachOffscreen(){if(!this._offscreenRender||this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas,this._ctx=this._canvasctrl.getContext("2d"),this.sendMessage("detachOffscreen"),this.busy=!1,this.resize(0,0,0,0,!0)}_reAttachOffscreen(){if(!this._offscreenRender||!this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas.transferControlToOffscreen(),this._ctx=!1,this.sendMessage("offscreenCanvas",null,[this._canvasctrl]),this.resize(0,0,0,0,!0)}_updateColorSpace(){this._video.requestVideoFrameCallback(()=>{try{let e=new VideoFrame(this._video);this._videoColorSpace=r[e.colorSpace.matrix],e.close(),this.sendMessage("getColorSpace")}catch(e){console.warn(e)}})}_verifyColorSpace({subtitleColorSpace:e,videoColorSpace:t=this._videoColorSpace}){e&&t&&e!==t&&(this._detachOffscreen(),this._ctx.filter=`url("data:image/svg+xml;utf8,#f")`)}_render({images:e,asyncRender:t,times:s,width:i,height:a,colorSpace:r}){for(let n of(this._unbusy(),this.debug&&(s.IPCTime=Date.now()-s.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:r})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height),e))n.image&&(t?(this._ctx.drawImage(n.image,n.x,n.y),n.image.close()):(this._bufferCanvas.width=n.w,this._bufferCanvas.height=n.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(n.image)),n.w,n.h),0,0),this._ctx.drawImage(this._bufferCanvas,n.x,n.y)));if(this.debug){s.JSRenderTime=Date.now()-s.JSRenderTime-s.IPCTime;let t=0,i=s.bitmaps||e.length;for(let e in delete s.bitmaps,s)t+=s[e];console.log("Bitmaps: "+i+" Total: "+(0|t)+"ms",s)}}_fixAlpha(e){if(o._hasAlphaBug)for(let t=3;t1?e[t]:1;return e}_ready(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}async sendMessage(e,t={},s){await this._loaded,s?this._worker.postMessage({target:e,transferable:s,...t},[...s]):this._worker.postMessage({target:e,...t})}_fetchFromWorker(e,t){try{let s=e.target,i=setTimeout(()=>{r(Error("Error: Timeout while try to fetch "+s))},5e3),a=({data:e})=>{e.target===s&&(t(null,e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i))},r=e=>{t(e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",r),this._worker.postMessage(e)}catch(e){this._error(e)}}_console({content:e,command:t}){console[t].apply(console,JSON.parse(e))}_onmessage({data:e}){this["_"+e.target]&&this["_"+e.target](e)}_error(e){let t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),s=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(s),console.error(t),t}_removeListeners(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}destroy(e){return e&&(e=this._error(e)),this._video&&this._canvasParent&&this._video.parentNode?.removeChild(this._canvasParent),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),this._worker?.terminate(),e}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],loqXi:[function(e,t,s,i){s.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},s.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},s.exportAll=function(e,t){return Object.keys(e).forEach(function(s){"default"===s||"__esModule"===s||Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[s]}})}),t},s.export=function(e,t,s){Object.defineProperty(e,t,{enumerable:!0,get:s})}},{}]},["bm4Y0"],"bm4Y0","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("bm4Y0");export{e as default}; \ No newline at end of file diff --git a/docs/document/404.html b/docs/document/404.html index 1cbe323b2..a44818d33 100644 --- a/docs/document/404.html +++ b/docs/document/404.html @@ -21,7 +21,7 @@
- + \ No newline at end of file diff --git a/docs/document/advanced/built-in.html b/docs/document/advanced/built-in.html index adbfec345..cc5585bf0 100644 --- a/docs/document/advanced/built-in.html +++ b/docs/document/advanced/built-in.html @@ -217,7 +217,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 784dd2fce..2cd466da9 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 db17576bb..0c0fbce22 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 f71e92d6c..440446961 100644 --- a/docs/document/advanced/global.html +++ b/docs/document/advanced/global.html @@ -248,7 +248,7 @@ // 只销毁界面,不主动清空 src art.destroy(); - + \ No newline at end of file diff --git a/docs/document/advanced/plugin.html b/docs/document/advanced/plugin.html index 4df99ba3b..ccb1c1cd2 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 e9d1e35b2..c012569bd 100644 --- a/docs/document/advanced/property.html +++ b/docs/document/advanced/property.html @@ -457,7 +457,7 @@ art.on('ready', () => { art.subtitleOffset = 1; }); - + \ No newline at end of file diff --git a/docs/document/assets/en_index.md.DV389qew.js b/docs/document/assets/en_index.md.7shqBtga.js similarity index 98% rename from docs/document/assets/en_index.md.DV389qew.js rename to docs/document/assets/en_index.md.7shqBtga.js index 64bd87395..6d1688894 100644 --- a/docs/document/assets/en_index.md.DV389qew.js +++ b/docs/document/assets/en_index.md.7shqBtga.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 & Usage","description":"","frontmatter":{},"headers":[],"relativePath":"en/index.md","filePath":"en/index.md","lastUpdated":1764426402000}'),p={name:"en/index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`

Installation & 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 & Usage","description":"","frontmatter":{},"headers":[],"relativePath":"en/index.md","filePath":"en/index.md","lastUpdated":1767420511000}'),p={name:"en/index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`

Installation & 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>

Note

The player's dimensions depend on the size of its container container, so your container must have defined dimensions.

See more usage examples at the following link:

/example

Vue.js ​

vue
<template>
+</html>

Note

The player's dimensions depend on the size of its container container, so your container must have defined dimensions.

See more usage examples at the following link:

/example

Vue.js ​

vue
<template>
   <div ref="$container" />
 </template>
 
@@ -71,7 +71,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
 function getInstance(art) {
   console.log(art)
 }
-</script>

Artplayer is not reactive:

Directly modifying option in Vue.js will not update the player.

React.js ​

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

Artplayer is not reactive:

Directly modifying option in Vue.js will not update the player.

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -154,7 +154,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);

Legacy Browsers ​

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

For legacy browsers, you can use the artplayer.legacy.js file, which supports compatibility down to: IE 11

js
import Artplayer from 'artplayer/legacy'
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, modify the following configuration and build it yourself:

Build configuration: scripts/build.js

Reference documentation: browserslist

ECMAScript Module ​

Starting from 5.2.6, artplayer and all plugins also provide an ESM version mjs, such as:

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

Legacy Browsers ​

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

For legacy browsers, you can use the artplayer.legacy.js file, which supports compatibility down to: IE 11

js
import Artplayer from 'artplayer/legacy'
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, modify the following configuration and build it yourself:

Build configuration: scripts/build.js

Reference documentation: browserslist

ECMAScript Module ​

Starting from 5.2.6, artplayer and all plugins also provide an ESM version 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.DV389qew.lean.js b/docs/document/assets/en_index.md.7shqBtga.lean.js
similarity index 84%
rename from docs/document/assets/en_index.md.DV389qew.lean.js
rename to docs/document/assets/en_index.md.7shqBtga.lean.js
index bef158a13..e41d652b3 100644
--- a/docs/document/assets/en_index.md.DV389qew.lean.js
+++ b/docs/document/assets/en_index.md.7shqBtga.lean.js
@@ -1 +1 @@
-import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g=JSON.parse('{"title":"Installation & Usage","description":"","frontmatter":{},"headers":[],"relativePath":"en/index.md","filePath":"en/index.md","lastUpdated":1764426402000}'),p={name:"en/index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l("",50)]))}const c=i(p,[["render",t]]);export{g as __pageData,c as default};
+import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g=JSON.parse('{"title":"Installation & Usage","description":"","frontmatter":{},"headers":[],"relativePath":"en/index.md","filePath":"en/index.md","lastUpdated":1767420511000}'),p={name:"en/index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l("",50)]))}const c=i(p,[["render",t]]);export{g as __pageData,c as default};
diff --git a/docs/document/assets/en_start_i18n.md.DnrHSZPX.js b/docs/document/assets/en_start_i18n.md.Br6ZSUj7.js
similarity index 98%
rename from docs/document/assets/en_start_i18n.md.DnrHSZPX.js
rename to docs/document/assets/en_start_i18n.md.Br6ZSUj7.js
index 5775fb8e1..687d193cb 100644
--- a/docs/document/assets/en_start_i18n.md.DnrHSZPX.js
+++ b/docs/document/assets/en_start_i18n.md.Br6ZSUj7.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 bundling are located at: artplayer/src/i18n/*.js. Contributions to add your language are welcome.

Language files after bundling are located at: artplayer/dist/i18n/*.js

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

Importing Languages ​

Language files before bundling are located at: artplayer/src/i18n/*.js. Contributions to add your language are welcome.

Language files after bundling are located at: artplayer/dist/i18n/*.js

js
import id from 'artplayer/i18n/id';
 import zhTw from 'artplayer/i18n/zh-tw';
 
 var art = new Artplayer({
diff --git a/docs/document/assets/en_start_i18n.md.DnrHSZPX.lean.js b/docs/document/assets/en_start_i18n.md.Br6ZSUj7.lean.js
similarity index 100%
rename from docs/document/assets/en_start_i18n.md.DnrHSZPX.lean.js
rename to docs/document/assets/en_start_i18n.md.Br6ZSUj7.lean.js
diff --git a/docs/document/assets/index.md.jfrBQ5d9.js b/docs/document/assets/index.md.Xug2h4MQ.js
similarity index 98%
rename from docs/document/assets/index.md.jfrBQ5d9.js
rename to docs/document/assets/index.md.Xug2h4MQ.js
index e7c0b3ac1..a36531137 100644
--- a/docs/document/assets/index.md.jfrBQ5d9.js
+++ b/docs/document/assets/index.md.Xug2h4MQ.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":1757137705000}'),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":1767420511000}'),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 必须是有尺寸的

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

/example

Vue.js ​

vue
<template>
+</html>

提示

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

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

/example

Vue.js ​

vue
<template>
   <div ref="$container" />
 </template>
 
@@ -71,7 +71,7 @@ import{_ as i,c as a,o as n,ak as l}from"./chunks/framework.xxfEszSJ.js";const g
 function getInstance(art) {
   console.log(art)
 }
-</script>

Artplayer 非响应式:

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

React.js ​

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

Artplayer 非响应式:

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

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -154,7 +154,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/legacy'
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/legacy'
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.jfrBQ5d9.lean.js b/docs/document/assets/index.md.Xug2h4MQ.lean.js
similarity index 84%
rename from docs/document/assets/index.md.jfrBQ5d9.lean.js
rename to docs/document/assets/index.md.Xug2h4MQ.lean.js
index 793c6a2e2..59beeb14b 100644
--- a/docs/document/assets/index.md.jfrBQ5d9.lean.js
+++ b/docs/document/assets/index.md.Xug2h4MQ.lean.js
@@ -1 +1 @@
-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":1757137705000}'),p={name:"index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l("",50)]))}const c=i(p,[["render",t]]);export{g as __pageData,c as default};
+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":1767420511000}'),p={name:"index.md"};function t(e,s,h,k,r,E){return n(),a("div",null,s[0]||(s[0]=[l("",50)]))}const c=i(p,[["render",t]]);export{g as __pageData,c as default};
diff --git a/docs/document/assets/plugin_danmuku.md.Clulf0MS.js b/docs/document/assets/plugin_danmuku.md.Dm8aaMVM.js
similarity index 99%
rename from docs/document/assets/plugin_danmuku.md.Clulf0MS.js
rename to docs/document/assets/plugin_danmuku.md.Dm8aaMVM.js
index aaf7c60ef..35f2378f9 100644
--- a/docs/document/assets/plugin_danmuku.md.Clulf0MS.js
+++ b/docs/document/assets/plugin_danmuku.md.Dm8aaMVM.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.Clulf0MS.lean.js b/docs/document/assets/plugin_danmuku.md.Dm8aaMVM.lean.js
similarity index 100%
rename from docs/document/assets/plugin_danmuku.md.Clulf0MS.lean.js
rename to docs/document/assets/plugin_danmuku.md.Dm8aaMVM.lean.js
diff --git a/docs/document/assets/start_i18n.md.D2f3WWA8.js b/docs/document/assets/start_i18n.md.B-KNPVtu.js
similarity index 98%
rename from docs/document/assets/start_i18n.md.D2f3WWA8.js
rename to docs/document/assets/start_i18n.md.B-KNPVtu.js
index 035a8942c..1e1fdac88 100644
--- a/docs/document/assets/start_i18n.md.D2f3WWA8.js
+++ b/docs/document/assets/start_i18n.md.B-KNPVtu.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/i18n/id';
+});

导入语言 ​

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

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

js
import id from 'artplayer/i18n/id';
 import zhTw from 'artplayer/i18n/zh-tw';
 
 var art = new Artplayer({
diff --git a/docs/document/assets/start_i18n.md.D2f3WWA8.lean.js b/docs/document/assets/start_i18n.md.B-KNPVtu.lean.js
similarity index 100%
rename from docs/document/assets/start_i18n.md.D2f3WWA8.lean.js
rename to docs/document/assets/start_i18n.md.B-KNPVtu.lean.js
diff --git a/docs/document/component/contextmenu.html b/docs/document/component/contextmenu.html
index 792e26ed5..a34ea2dce 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 0249fb87d..91c0e5bd7 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 b1a9b2a39..3f181bd9c 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 f13c056ed..1db05af6b 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 a808876fa..7d3ab56ba 100644 --- a/docs/document/en/advanced/built-in.html +++ b/docs/document/en/advanced/built-in.html @@ -217,7 +217,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 3dfe4a445..007ef9a66 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 for videos.

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

utils ​

Returns the collection of utility functions for the player.

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

For all utility functions, please refer to the following address:

artplayer/types/utils.d.ts

scheme ​

Returns the validation schema for player options.

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

Emitter ​

Returns the constructor function for the event emitter.

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

validator ​

Returns the validation function for options.

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

kindOf ​

Returns the utility function for type detection.

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

html ​

Returns the html string required by the player.

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

option ​

Returns the default options for the player.

▶ 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 2462e0fa9..fdab36cd1 100644 --- a/docs/document/en/advanced/event.html +++ b/docs/document/en/advanced/event.html @@ -412,7 +412,7 @@ art.on('keydown', (event) => { console.log(event.code); });

video:canplay ​

The browser can start playing the media, but estimates there isn't 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 to buffer content

video:complete ​

OfflineAudioContext rendering is complete

video:durationchange ​

Triggered when the value of the duration property changes

video:emptied ​

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

video:ended ​

Playback has stopped because the media has reached its 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 begun

video:playing ​

Playback is ready to start after having been paused or delayed due to lack of data

video:progress ​

Periodically triggered while the browser is loading the resource

video:ratechange ​

The playback rate has changed

video:seeked ​

A seek operation has completed

video:seeking ​

A seek operation has begun

video:stalled ​

The user agent is trying to fetch media data, but data is unexpectedly not forthcoming

video:suspend ​

Media data loading has been suspended

video:timeupdate ​

The time indicated by the currentTime attribute has been updated

video:volumechange ​

The volume has changed

video:waiting ​

Playback has stopped due to temporary lack of data

- + \ No newline at end of file diff --git a/docs/document/en/advanced/global.html b/docs/document/en/advanced/global.html index 5752e9071..abae32ebb 100644 --- a/docs/document/en/advanced/global.html +++ b/docs/document/en/advanced/global.html @@ -266,7 +266,7 @@ // Only destroys the UI, does not actively clear src art.destroy(); - + \ No newline at end of file diff --git a/docs/document/en/advanced/plugin.html b/docs/document/en/advanced/plugin.html index 4d11e8e6c..700468e45 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 db89919f5..e93278954 100644 --- a/docs/document/en/advanced/property.html +++ b/docs/document/en/advanced/property.html @@ -487,7 +487,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 fd37e07a1..72bca6f98 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 2b8d6ea05..9d407c0b8 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 8b4545b12..2f5acbbda 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 201221892..b528fca98 100644 --- a/docs/document/en/component/setting.html +++ b/docs/document/en/component/setting.html @@ -260,7 +260,7 @@ }); }, 3000); }); - + \ No newline at end of file diff --git a/docs/document/en/index.html b/docs/document/en/index.html index 2399f6fe1..43513fa99 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 & 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 & 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>

Note

The player's dimensions depend on the size of its container container, so your container must have defined dimensions.

See more usage examples at the following link:

/example

Vue.js ​

vue
<template>
+</html>

Note

The player's dimensions depend on the size of its container container, so your container must have defined dimensions.

See more usage examples at the following link:

/example

Vue.js ​

vue
<template>
   <div ref="$container" />
 </template>
 
@@ -96,7 +96,7 @@
 function getInstance(art) {
   console.log(art)
 }
-</script>

Artplayer is not reactive:

Directly modifying option in Vue.js will not update the player.

React.js ​

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

Artplayer is not reactive:

Directly modifying option in Vue.js will not update the player.

React.js ​

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

Legacy Browsers ​

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

For legacy browsers, you can use the artplayer.legacy.js file, which supports compatibility down to: IE 11

js
import Artplayer from 'artplayer/legacy'
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, modify the following configuration and build it yourself:

Build configuration: scripts/build.js

Reference documentation: browserslist

ECMAScript Module ​

Starting from 5.2.6, artplayer and all plugins also provide an ESM version mjs, such as:

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

Legacy Browsers ​

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

For legacy browsers, you can use the artplayer.legacy.js file, which supports compatibility down to: IE 11

js
import Artplayer from 'artplayer/legacy'
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, modify the following configuration and build it yourself:

Build configuration: scripts/build.js

Reference documentation: browserslist

ECMAScript Module ​

Starting from 5.2.6, artplayer and all plugins also provide an ESM version mjs, such as:

  • artplayer/dist/artplayer.mjs
  • artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.mjs
html
<!DOCTYPE html>
 <html lang="en">
 
 <head>
@@ -236,8 +236,8 @@
           });
         </script>
     </body>
-</html>

Note

You need to modify it before importing the Artplayer dependency for it to take effect.

- +</html>

Note

You need to modify it before importing the Artplayer dependency 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 0d65b5718..08bb29ba7 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 bundling are located at: artplayer/src/i18n/*.js. Contributions to add your language are welcome.

Language files after bundling are located at: artplayer/dist/i18n/*.js

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

Importing Languages ​

Language files before bundling are located at: artplayer/src/i18n/*.js. Contributions to add your language are welcome.

Language files after bundling are located at: artplayer/dist/i18n/*.js

js
import id from 'artplayer/i18n/id';
 import zhTw from 'artplayer/i18n/zh-tw';
 
 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 b966d57bb..44e406482 100644 --- a/docs/document/en/start/option.html +++ b/docs/document/en/start/option.html @@ -475,7 +475,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 20debf9d2..bf338b6fa 100644 --- a/docs/document/hashmap.json +++ b/docs/document/hashmap.json @@ -1 +1 @@ -{"advanced_built-in.md":"DiyRIcIA","advanced_class.md":"Da3aE0pP","advanced_event.md":"mrsB0MsK","advanced_global.md":"Bdw3azKs","advanced_plugin.md":"B3Pobmcq","advanced_property.md":"CA7GaeI3","component_contextmenu.md":"ClKmcIKr","component_controls.md":"Cl62yW1F","component_layers.md":"Cys52VMi","component_setting.md":"BP5674ir","en_advanced_built-in.md":"XdT81JC0","en_advanced_class.md":"BLyA7rxa","en_advanced_event.md":"CtQl1IYg","en_advanced_global.md":"D5Nz8wyo","en_advanced_plugin.md":"BOuMu80J","en_advanced_property.md":"urRMaqHe","en_component_contextmenu.md":"COLfX45a","en_component_controls.md":"BbQsn0wJ","en_component_layers.md":"CX93a7QS","en_component_setting.md":"C6o2AWtX","en_index.md":"DV389qew","en_start_i18n.md":"DnrHSZPX","en_start_option.md":"Bk4YXvof","index.md":"jfrBQ5d9","plugin_danmuku.md":"Clulf0MS","start_i18n.md":"D2f3WWA8","start_option.md":"D52S8Ynf"} +{"advanced_built-in.md":"DiyRIcIA","advanced_class.md":"Da3aE0pP","advanced_event.md":"mrsB0MsK","advanced_global.md":"Bdw3azKs","advanced_plugin.md":"B3Pobmcq","advanced_property.md":"CA7GaeI3","component_contextmenu.md":"ClKmcIKr","component_controls.md":"Cl62yW1F","component_layers.md":"Cys52VMi","component_setting.md":"BP5674ir","en_advanced_built-in.md":"XdT81JC0","en_advanced_class.md":"BLyA7rxa","en_advanced_event.md":"CtQl1IYg","en_advanced_global.md":"D5Nz8wyo","en_advanced_plugin.md":"BOuMu80J","en_advanced_property.md":"urRMaqHe","en_component_contextmenu.md":"COLfX45a","en_component_controls.md":"BbQsn0wJ","en_component_layers.md":"CX93a7QS","en_component_setting.md":"C6o2AWtX","en_index.md":"7shqBtga","en_start_i18n.md":"Br6ZSUj7","en_start_option.md":"Bk4YXvof","index.md":"Xug2h4MQ","plugin_danmuku.md":"Dm8aaMVM","start_i18n.md":"B-KNPVtu","start_option.md":"D52S8Ynf"} diff --git a/docs/document/index.html b/docs/document/index.html index 5e8dcb21b..f134e2967 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 必须是有尺寸的

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

/example

Vue.js ​

vue
<template>
+</html>

提示

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

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

/example

Vue.js ​

vue
<template>
   <div ref="$container" />
 </template>
 
@@ -96,7 +96,7 @@
 function getInstance(art) {
   console.log(art)
 }
-</script>

Artplayer 非响应式:

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

React.js ​

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

Artplayer 非响应式:

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

React.js ​

jsx
import Artplayer from 'artplayer'
 import { useEffect, useRef } from 'react'
 
 export default function Player({ option, getInstance, ...rest }) {
@@ -179,7 +179,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/legacy'
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/legacy'
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>
@@ -236,8 +236,8 @@
           });
         </script>
     </body>
-</html>

提示

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

- +</html>

提示

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

+ \ No newline at end of file diff --git a/docs/document/plugin/danmuku.html b/docs/document/plugin/danmuku.html index f40016caa..f3e4aed50 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 bab5d87e8..d3bcbb8e0 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/i18n/id';
+});

导入语言 ​

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

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

js
import id from 'artplayer/i18n/id';
 import zhTw from 'artplayer/i18n/zh-tw';
 
 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 60511f67c..94da21054 100644 --- a/docs/document/start/option.html +++ b/docs/document/start/option.html @@ -415,7 +415,7 @@ url: '/assets/sample/video.mp4', proxy: () => document.createElement('video') }); - + \ No newline at end of file diff --git a/package.json b/package.json index 5dfdd1dbb..b3b8506fc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "dev": "npx cross-env NODE_ENV=development node ./scripts/dev.js", "build": "npx cross-env NODE_ENV=production node ./scripts/build.js", "lint": "npx eslint packages/*/{src,types,package.json} scripts/*.js test/* docs/assets/ts/* --fix", - "build:all": "npm run build all && npm run build:i18n && npm run build:ts && npm run build:docs" + "build:all": "npm run build all && npm run build:i18n && npm run build:ts && npm run build:docs && npm run lint" }, "browserslist": "last 1 Chrome version", "dependencies": { diff --git a/packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.js b/packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.js new file mode 100644 index 000000000..b6c2eea04 --- /dev/null +++ b/packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.js @@ -0,0 +1,8 @@ + +/*! + * artplayer-plugin-jassub.js v1.0.0 + * Github: https://github.com/zhw2590582/ArtPlayer + * (c) 2017-2026 Harvey Zack + * Released under the MIT License. + */ +!function(e,t,s,i,a,r,n,o){var h="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},d="function"==typeof h[i]&&h[i],l=d.i||{},c=d.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(t,s){if(!c[t]){if(!e[t]){if(a[t])return a[t];var r="function"==typeof h[i]&&h[i];if(!s&&r)return r(t,!0);if(d)return d(t,!0);if(u&&"string"==typeof t)return u(t);var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}l.resolve=function(s){var i=e[t][1][s];return null!=i?i:s},l.cache={};var o=c[t]=new m.Module(t);e[t][0].call(o.exports,l,o,o.exports,h)}return c[t].exports;function l(e){var t=l.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var s={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],a=e[2]||e[0],r=m(i);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===a?Object.defineProperty(s,t,{enumerable:!0,value:r}):Object.defineProperty(s,t,{enumerable:!0,get:function(){return"default"===a?r.__esModule?r.default:r:r[a]}})}),s}return m(t)}}m.isParcelRequire=!0,m.Module=function(e){this.id=e,this.bundle=m,this.require=u,this.exports={}},m.modules=e,m.cache=c,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=l,m.register=function(t,s){e[t]=[function(e,t){t.exports=s},{}]},Object.defineProperty(m,"root",{get:function(){return h[i]}}),h[i]=m;for(var _=0;_typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({g5KxT:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o);var r=e("./jassub.es.js"),n=a.interopDefault(r);function o(e){return t=>{let s=new(0,n.default)({video:t.video,...e});return s._canvasParent.style.zIndex=20,t.on("destroy",()=>{s.destroy()}),{name:"artplayerPluginJassub",instance:s}}}"u">typeof window&&(window.artplayerPluginJassub=o)},{"./jassub.es.js":"8Qqq1","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"8Qqq1":[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o),"u">typeof HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){let t=performance.now(),s=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||s.totalVideoFrames-s.droppedVideoFrames,a=(r,n)=>{let o=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||o.totalVideoFrames-o.droppedVideoFrames;if(h>i){let i=this.mozFrameDelay||o.totalFrameDelay-s.totalFrameDelay||0,a=n-r;e(n,{presentationTime:n+1e3*i,expectedDisplayTime:n+a,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+a/1e3,presentedFrames:h,processingDuration:i}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(n,e))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(t,e)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});let r={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},n={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}};class o extends EventTarget{constructor(e){if(super(),!globalThis.Worker)throw this.destroy("Worker not supported");if(!e)throw this.destroy("No options provided");this._loaded=new Promise(e=>{this._init=e});const t=o._test();if(this._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e.onDemandRender??!0),this._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(e.offscreenRender??!0),this.timeOffset=e.timeOffset||0,this._video=e.video,this._videoHeight=0,this._videoWidth=0,this._videoColorSpace=null,this._canvas=e.canvas,this._video&&!this._canvas)this._canvasParent=document.createElement("div"),this._canvasParent.className="JASSUB",this._canvasParent.style.position="relative",this._canvas=this._createCanvas(),this._video.insertAdjacentElement("afterend",this._canvasParent);else if(!this._canvas)throw this.destroy("Don't know where to render: you should give video or canvas in options.");if(this._bufferCanvas=document.createElement("canvas"),this._bufferCtx=this._bufferCanvas.getContext("2d"),!this._bufferCtx)throw this.destroy("Canvas rendering not supported");this._canvasctrl=this._offscreenRender?this._canvas.transferControlToOffscreen():this._canvas,this._ctx=!this._offscreenRender&&this._canvasctrl.getContext("2d"),this._lastRenderTime=0,this.debug=!!e.debug,this.prescaleFactor=e.prescaleFactor||1,this.prescaleHeightLimit=e.prescaleHeightLimit||1080,this.maxRenderHeight=e.maxRenderHeight||0,this._boundResize=this.resize.bind(this),this._boundTimeUpdate=this._timeupdate.bind(this),this._boundSetRate=this.setRate.bind(this),this._boundUpdateColorSpace=this._updateColorSpace.bind(this),this._video&&this.setVideo(e.video),this._onDemandRender&&(this.busy=!1,this._lastDemandTime=null),this._worker=new Worker(e.workerUrl||"jassub-worker.js"),this._worker.onmessage=e=>this._onmessage(e),this._worker.onerror=e=>this._error(e),t.then(()=>{this._worker.postMessage({target:"init",wasmUrl:o._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:e.wasmUrl??"jassub-worker.wasm",legacyWasmUrl:e.legacyWasmUrl??"jassub-worker.wasm.js",asyncRender:"u">typeof createImageBitmap&&(e.asyncRender??!0),onDemandRender:this._onDemandRender,width:this._canvasctrl.width||0,height:this._canvasctrl.height||0,blendMode:e.blendMode||"js",subUrl:e.subUrl,subContent:e.subContent||null,fonts:e.fonts||[],availableFonts:e.availableFonts||{"liberation sans":"./default.woff2"},fallbackFont:e.fallbackFont||"liberation sans",debug:this.debug,targetFps:e.targetFps||24,dropAllAnimations:e.dropAllAnimations,dropAllBlur:e.dropAllBlur,libassMemoryLimit:e.libassMemoryLimit||0,libassGlyphLimit:e.libassGlyphLimit||0,useLocalFonts:"u">typeof queryLocalFonts&&(e.useLocalFonts??!0),hasBitmapBug:o._hasBitmapBug}),!0===this._offscreenRender&&this.sendMessage("offscreenCanvas",null,[this._canvasctrl])})}_createCanvas(){return this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvasParent.appendChild(this._canvas),this._canvas}static _supportsSIMD=null;static _hasAlphaBug=null;static _hasBitmapBug=null;static _testSIMD(){if(null===o._supportsSIMD)try{o._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch{o._supportsSIMD=!1}}static async _testImageBugs(){if(null!==o._hasBitmapBug)return;let e=document.createElement("canvas"),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch{console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,s,i){let a=t.createImageData(s,i);return e&&a.data.set(e),a}}let s=document.createElement("canvas"),i=s.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("Canvas rendering not supported");e.width=s.width=1,e.height=s.height=1,t.clearRect(0,0,1,1),i.clearRect(0,0,1,1);let a=i.getImageData(0,0,1,1).data;t.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0);let r=i.getImageData(0,0,1,1).data;if(o._hasAlphaBug=a[1]!==r[1],o._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),"u">typeof createImageBitmap){let e=new Uint8ClampedArray([255,0,255,0,255]).subarray(1,5);i.drawImage(await createImageBitmap(new ImageData(e,1)),0,0);let{data:t}=i.getImageData(0,0,1,1);for(let[s,i]of(o._hasBitmapBug=!1,t.entries()))if(Math.abs(e[s]-i)>15){o._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}else o._hasBitmapBug=!1;e.remove(),s.remove()}static async _test(){o._testSIMD(),await o._testImageBugs()}resize(e=0,t=0,s=0,i=0,a=this._video?.paused){if((!e||!t)&&this._video){let a=this._getVideoPosition(),r=null;if(this._videoWidth){let e=this._video.videoWidth/this._videoWidth,t=this._video.videoHeight/this._videoHeight;r=this._computeCanvasSize((a.width||0)/e,(a.height||0)/t)}else r=this._computeCanvasSize(a.width||0,a.height||0);e=r.width,t=r.height,this._canvasParent&&(s=a.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=a.x),this._canvas.style.width=a.width+"px",this._canvas.style.height=a.height+"px"}this._canvas.style.top=s+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:e,height:t,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}_getVideoPosition(e=this._video.videoWidth,t=this._video.videoHeight){let s=e/t,{offsetWidth:i,offsetHeight:a}=this._video;e=i,t=a,i/a>s?e=Math.floor(a*s):t=Math.floor(i/s);let r=(i-e)/2,n=(a-t)/2;return{width:e,height:t,x:r,y:n}}_computeCanvasSize(e=0,t=0){let s=this.prescaleFactor<=0?1:this.prescaleFactor,i=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{let a=s<1?-1:1,r=t*i;a*r*s<=a*this.prescaleHeightLimit?r*=s:a*r0&&r>this.maxRenderHeight&&(r=this.maxRenderHeight),e*=r/t,t=r}return{width:e,height:t}}_timeupdate({type:e}){let t={seeking:!0,waiting:!0,playing:!1}[e];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}setVideo(e){e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),"u">typeof ResizeObserver&&(this._ro||(this._ro=new ResizeObserver(()=>this.resize())),this._ro.observe(e))):this._error("Video element invalid!")}runBenchmark(){this.sendMessage("runBenchmark")}setTrackByUrl(e){this.sendMessage("setTrackByUrl",{url:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}setTrack(e){this.sendMessage("setTrack",{content:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}freeTrack(){this.sendMessage("freeTrack")}setIsPaused(e){this.sendMessage("video",{isPaused:e})}setRate(e){this.sendMessage("video",{rate:e})}setCurrentTime(e,t,s){this.sendMessage("video",{isPaused:e,currentTime:t,rate:s,colorSpace:this._videoColorSpace})}createEvent(e){this.sendMessage("createEvent",{event:e})}setEvent(e,t){this.sendMessage("setEvent",{event:e,index:t})}removeEvent(e){this.sendMessage("removeEvent",{index:e})}getEvents(e){this._fetchFromWorker({target:"getEvents"},(t,{events:s})=>{e(t,s)})}styleOverride(e){this.sendMessage("styleOverride",{style:e})}disableStyleOverride(){this.sendMessage("disableStyleOverride")}createStyle(e){this.sendMessage("createStyle",{style:e})}setStyle(e,t){this.sendMessage("setStyle",{style:e,index:t})}removeStyle(e){this.sendMessage("removeStyle",{index:e})}getStyles(e){this._fetchFromWorker({target:"getStyles"},(t,{styles:s})=>{e(t,s)})}addFont(e){this.sendMessage("addFont",{font:e})}setDefaultFont(e){this.sendMessage("defaultFont",{font:e})}_sendLocalFont(e){try{queryLocalFonts().then(t=>{let s=t?.find(t=>t.fullName.toLowerCase()===e);s&&s.blob().then(e=>{e.arrayBuffer().then(e=>{this.addFont(new Uint8Array(e))})})})}catch(e){console.warn("Local fonts API:",e)}}_getLocalFont({font:e}){try{navigator?.permissions?.query?navigator.permissions.query({name:"local-fonts"}).then(t=>{"granted"===t.state&&this._sendLocalFont(e)}):this._sendLocalFont(e)}catch(e){console.warn("Local fonts API:",e)}}_unbusy(){this._lastDemandTime?this._demandRender(this._lastDemandTime):this.busy=!1}_handleRVFC(e,{mediaTime:t,width:s,height:i}){if(this._destroyed)return null;this.busy?this._lastDemandTime={mediaTime:t,width:s,height:i}:(this.busy=!0,this._demandRender({mediaTime:t,width:s,height:i})),this._video.requestVideoFrameCallback(this._handleRVFC.bind(this))}_demandRender({mediaTime:e,width:t,height:s}){this._lastDemandTime=null,(t!==this._videoWidth||s!==this._videoHeight)&&(this._videoWidth=t,this._videoHeight=s,this.resize()),this.sendMessage("demand",{time:e+this.timeOffset})}_detachOffscreen(){if(!this._offscreenRender||this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas,this._ctx=this._canvasctrl.getContext("2d"),this.sendMessage("detachOffscreen"),this.busy=!1,this.resize(0,0,0,0,!0)}_reAttachOffscreen(){if(!this._offscreenRender||!this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas.transferControlToOffscreen(),this._ctx=!1,this.sendMessage("offscreenCanvas",null,[this._canvasctrl]),this.resize(0,0,0,0,!0)}_updateColorSpace(){this._video.requestVideoFrameCallback(()=>{try{let e=new VideoFrame(this._video);this._videoColorSpace=r[e.colorSpace.matrix],e.close(),this.sendMessage("getColorSpace")}catch(e){console.warn(e)}})}_verifyColorSpace({subtitleColorSpace:e,videoColorSpace:t=this._videoColorSpace}){e&&t&&e!==t&&(this._detachOffscreen(),this._ctx.filter=`url("data:image/svg+xml;utf8,#f")`)}_render({images:e,asyncRender:t,times:s,width:i,height:a,colorSpace:r}){for(let n of(this._unbusy(),this.debug&&(s.IPCTime=Date.now()-s.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:r})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height),e))n.image&&(t?(this._ctx.drawImage(n.image,n.x,n.y),n.image.close()):(this._bufferCanvas.width=n.w,this._bufferCanvas.height=n.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(n.image)),n.w,n.h),0,0),this._ctx.drawImage(this._bufferCanvas,n.x,n.y)));if(this.debug){s.JSRenderTime=Date.now()-s.JSRenderTime-s.IPCTime;let t=0,i=s.bitmaps||e.length;for(let e in delete s.bitmaps,s)t+=s[e];console.log("Bitmaps: "+i+" Total: "+(0|t)+"ms",s)}}_fixAlpha(e){if(o._hasAlphaBug)for(let t=3;t1?e[t]:1;return e}_ready(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}async sendMessage(e,t={},s){await this._loaded,s?this._worker.postMessage({target:e,transferable:s,...t},[...s]):this._worker.postMessage({target:e,...t})}_fetchFromWorker(e,t){try{let s=e.target,i=setTimeout(()=>{r(Error("Error: Timeout while try to fetch "+s))},5e3),a=({data:e})=>{e.target===s&&(t(null,e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i))},r=e=>{t(e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",r),this._worker.postMessage(e)}catch(e){this._error(e)}}_console({content:e,command:t}){console[t].apply(console,JSON.parse(e))}_onmessage({data:e}){this["_"+e.target]&&this["_"+e.target](e)}_error(e){let t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),s=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(s),console.error(t),t}_removeListeners(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}destroy(e){return e&&(e=this._error(e)),this._video&&this._canvasParent&&this._video.parentNode?.removeChild(this._canvasParent),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),this._worker?.terminate(),e}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,s,i){s.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},s.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},s.exportAll=function(e,t){return Object.keys(e).forEach(function(s){"default"===s||"__esModule"===s||Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[s]}})}),t},s.export=function(e,t,s){Object.defineProperty(e,t,{enumerable:!0,get:s})}},{}]},["g5KxT"],"g5KxT","parcelRequire4dc0",{}); \ No newline at end of file diff --git a/packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.legacy.js b/packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.legacy.js new file mode 100644 index 000000000..d5ca1c56e --- /dev/null +++ b/packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.legacy.js @@ -0,0 +1,8 @@ + +/*! + * artplayer-plugin-jassub.js v1.0.0 + * Github: https://github.com/zhw2590582/ArtPlayer + * (c) 2017-2026 Harvey Zack + * Released under the MIT License. + */ +!function(e,t,r,n,i,a,s,o){var c="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},l="function"==typeof c[n]&&c[n],u=l.i||{},d=l.cache||{},f="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function h(t,r){if(!d[t]){if(!e[t]){if(i[t])return i[t];var a="function"==typeof c[n]&&c[n];if(!r&&a)return a(t,!0);if(l)return l(t,!0);if(f&&"string"==typeof t)return f(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}u.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},u.cache={};var o=d[t]=new h.Module(t);e[t][0].call(o.exports,u,o,o.exports,c)}return d[t].exports;function u(e){var t=u.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],n=e[1],i=e[2]||e[0],a=h(n);"*"===t?Object.keys(a).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})}):"*"===i?Object.defineProperty(r,t,{enumerable:!0,value:a}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===i?a.__esModule?a.default:a:a[i]}})}),r}return h(t)}}h.isParcelRequire=!0,h.Module=function(e){this.id=e,this.bundle=h,this.require=f,this.exports={}},h.modules=e,h.cache=d,h.parent=l,h.distDir=void 0,h.publicUrl=void 0,h.devServer=void 0,h.i=u,h.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(h,"root",{get:function(){return c[n]}}),c[n]=h;for(var _=0;_typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({k1Tni:[function(e,t,r,n){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"default",function(){return c});var a=e("@swc/helpers/cjs/_object_spread.cjs"),s=e("./jassub.es.js"),o=i.interopDefault(s);function c(e){return function(t){var r=new(0,o.default)((0,a._)({video:t.video},e));return r._canvasParent.style.zIndex=20,t.on("destroy",function(){r.destroy()}),{name:"artplayerPluginJassub",instance:r}}}"u">typeof window&&(window.artplayerPluginJassub=c)},{"@swc/helpers/cjs/_object_spread.cjs":"kyoEj","./jassub.es.js":"5H1mY","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],kyoEj:[function(e,t,r,n){"use strict";var i=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;ti){var u=t.mozFrameDelay||c.totalFrameDelay-n.totalFrameDelay||0,d=o-s;e(o,{presentationTime:o+1e3*u,expectedDisplayTime:o+d,width:t.videoWidth,height:t.videoHeight,mediaTime:Math.max(0,t.currentTime||0)+d/1e3,presentedFrames:l,processingDuration:u}),delete t._rvfcpolyfillmap[r]}else t._rvfcpolyfillmap[r]=requestAnimationFrame(function(e){return a(o,e)})};return this._rvfcpolyfillmap[r]=requestAnimationFrame(function(e){return a(r,e)}),r},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});var m={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},y={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}},b=function(e){"use strict";function t(e){if((0,o._)(this,t),r=(0,s._)(this,t),!globalThis.Worker)throw r.destroy("Worker not supported");if(!e)throw r.destroy("No options provided");r._loaded=new Promise(function(e){r._init=e});var r,n,i,a=t._test();if(r._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(null==(n=e.onDemandRender)||n),r._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(null==(i=e.offscreenRender)||i),r.timeOffset=e.timeOffset||0,r._video=e.video,r._videoHeight=0,r._videoWidth=0,r._videoColorSpace=null,r._canvas=e.canvas,r._video&&!r._canvas)r._canvasParent=document.createElement("div"),r._canvasParent.className="JASSUB",r._canvasParent.style.position="relative",r._canvas=r._createCanvas(),r._video.insertAdjacentElement("afterend",r._canvasParent);else if(!r._canvas)throw r.destroy("Don't know where to render: you should give video or canvas in options.");if(r._bufferCanvas=document.createElement("canvas"),r._bufferCtx=r._bufferCanvas.getContext("2d"),!r._bufferCtx)throw r.destroy("Canvas rendering not supported");return r._canvasctrl=r._offscreenRender?r._canvas.transferControlToOffscreen():r._canvas,r._ctx=!r._offscreenRender&&r._canvasctrl.getContext("2d"),r._lastRenderTime=0,r.debug=!!e.debug,r.prescaleFactor=e.prescaleFactor||1,r.prescaleHeightLimit=e.prescaleHeightLimit||1080,r.maxRenderHeight=e.maxRenderHeight||0,r._boundResize=r.resize.bind(r),r._boundTimeUpdate=r._timeupdate.bind(r),r._boundSetRate=r.setRate.bind(r),r._boundUpdateColorSpace=r._updateColorSpace.bind(r),r._video&&r.setVideo(e.video),r._onDemandRender&&(r.busy=!1,r._lastDemandTime=null),r._worker=new Worker(e.workerUrl||"jassub-worker.js"),r._worker.onmessage=function(e){return r._onmessage(e)},r._worker.onerror=function(e){return r._error(e)},a.then(function(){var n,i,a,s;r._worker.postMessage({target:"init",wasmUrl:t._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:null!=(n=e.wasmUrl)?n:"jassub-worker.wasm",legacyWasmUrl:null!=(i=e.legacyWasmUrl)?i:"jassub-worker.wasm.js",asyncRender:("u"0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null==(e=this._video)?void 0:e.paused;if((!t||!r)&&this._video){var s=this._getVideoPosition(),o=null;if(this._videoWidth){var c=this._video.videoWidth/this._videoWidth,l=this._video.videoHeight/this._videoHeight;o=this._computeCanvasSize((s.width||0)/c,(s.height||0)/l)}else o=this._computeCanvasSize(s.width||0,s.height||0);t=o.width,r=o.height,this._canvasParent&&(n=s.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=s.x),this._canvas.style.width=s.width+"px",this._canvas.style.height=s.height+"px"}this._canvas.style.top=n+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:t,height:r,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}},{key:"_getVideoPosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._video.videoWidth,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._video.videoHeight,r=e/t,n=this._video,i=n.offsetWidth,a=n.offsetHeight;e=i,t=a,i/a>r?e=Math.floor(a*r):t=Math.floor(i/r);var s=(i-e)/2,o=(a-t)/2;return{width:e,height:t,x:s,y:o}}},{key:"_computeCanvasSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.prescaleFactor<=0?1:this.prescaleFactor,n=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{var i=r<1?-1:1,a=t*n;i*a*r<=i*this.prescaleHeightLimit?a*=r:i*a0&&a>this.maxRenderHeight&&(a=this.maxRenderHeight),e*=a/t,t=a}return{width:e,height:t}}},{key:"_timeupdate",value:function(e){var t={seeking:!0,waiting:!0,playing:!1}[e.type];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}},{key:"setVideo",value:function(e){var t=this;e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),("u"#f\")"))}},{key:"_render",value:function(e){var t=e.images,r=e.asyncRender,n=e.times,i=e.width,a=e.height,s=e.colorSpace;this._unbusy(),this.debug&&(n.IPCTime=Date.now()-n.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:s})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height);var o=!0,c=!1,l=void 0;try{for(var u,d=t[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){var f=u.value;f.image&&(r?(this._ctx.drawImage(f.image,f.x,f.y),f.image.close()):(this._bufferCanvas.width=f.w,this._bufferCanvas.height=f.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(f.image)),f.w,f.h),0,0),this._ctx.drawImage(this._bufferCanvas,f.x,f.y)))}}catch(e){c=!0,l=e}finally{try{o||null==d.return||d.return()}finally{if(c)throw l}}if(this.debug){n.JSRenderTime=Date.now()-n.JSRenderTime-n.IPCTime;var h=0,_=n.bitmaps||t.length;for(var v in delete n.bitmaps,n)h+=n[v];console.log("Bitmaps: "+_+" Total: "+(0|h)+"ms",n)}}},{key:"_fixAlpha",value:function(e){if(t._hasAlphaBug)for(var r=3;r1?e[r]:1;return e}},{key:"_ready",value:function(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}},{key:"sendMessage",value:function(e,t){return(0,a._)(function(e){var t,r,n=arguments;return(0,p._)(this,function(i){switch(i.label){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:{},r=n.length>2?n[2]:void 0,[4,this._loaded];case 1:return i.sent(),r?this._worker.postMessage((0,d._)({target:e,transferable:r},t),(0,h._)(r)):this._worker.postMessage((0,d._)({target:e},t)),[2]}})}).apply(this,arguments)}},{key:"_fetchFromWorker",value:function(e,t){var r=this;try{var n=e.target,i=setTimeout(function(){s(Error("Error: Timeout while try to fetch "+n))},5e3),a=function(e){var o=e.data;o.target===n&&(t(null,o),r._worker.removeEventListener("message",a),r._worker.removeEventListener("error",s),clearTimeout(i))},s=function(e){t(e),r._worker.removeEventListener("message",a),r._worker.removeEventListener("error",s),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",s),this._worker.postMessage(e)}catch(e){this._error(e)}}},{key:"_console",value:function(e){var t=e.content,r=e.command;console[r].apply(console,JSON.parse(t))}},{key:"_onmessage",value:function(e){var t=e.data;this["_"+t.target]&&this["_"+t.target](t)}},{key:"_error",value:function(e){var t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),r=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(r),console.error(t),t}},{key:"_removeListeners",value:function(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}},{key:"destroy",value:function(e){var t,r;return e&&(e=this._error(e)),this._video&&this._canvasParent&&(null==(t=this._video.parentNode)||t.removeChild(this._canvasParent)),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),null==(r=this._worker)||r.terminate(),e}}],[{key:"_testSIMD",value:function(){if(null===t._supportsSIMD)try{t._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch(e){t._supportsSIMD=!1}}},{key:"_testImageBugs",value:function(){return(0,a._)(function(){var e,r,n,i,a,s,o,c,l,u,d,h,v,m,y,b,g;return(0,p._)(this,function(p){switch(p.label){case 0:if(null!==t._hasBitmapBug)return[2];if(!(r=(e=document.createElement("canvas")).getContext("2d",{willReadFrequently:!0})))throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch(e){console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,t,n){var i=r.createImageData(t,n);return e&&i.data.set(e),i}}if(!(i=(n=document.createElement("canvas")).getContext("2d",{willReadFrequently:!0})))throw Error("Canvas rendering not supported");if(e.width=n.width=1,e.height=n.height=1,r.clearRect(0,0,1,1),i.clearRect(0,0,1,1),a=i.getImageData(0,0,1,1).data,r.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0),s=i.getImageData(0,0,1,1).data,t._hasAlphaBug=a[1]!==s[1],t._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),!(("u"15){t._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}catch(e){d=!0,h=e}finally{try{u||null==v.return||v.return()}finally{if(d)throw h}}return[3,3];case 2:t._hasBitmapBug=!1,p.label=3;case 3:return e.remove(),n.remove(),[2]}})})()}},{key:"_test",value:function(){return(0,a._)(function(){return(0,p._)(this,function(e){switch(e.label){case 0:return t._testSIMD(),[4,t._testImageBugs()];case 1:return e.sent(),[2]}})})()}}]),t}((0,v._)(EventTarget));(0,l._)(b,"_supportsSIMD",null),(0,l._)(b,"_hasAlphaBug",null),(0,l._)(b,"_hasBitmapBug",null)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_define_property.cjs":"ltU3W","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_sliced_to_array.cjs":"gIQTH","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@swc/helpers/cjs/_wrap_native_super.cjs":"j8pRR","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function i(e,t,r,n,i,a,s){try{var o=e[a](s),c=o.value}catch(e){r(e);return}o.done?t(c):Promise.resolve(c).then(n,i)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,c,"next",e)}function c(e){i(s,n,a,o,c,"throw",e)}o(void 0)})}}},{}],clpdF:[function(e,t,r,n){"use strict";var i=e("feddc910f69a01a6"),a=e("b644f6b72647b399"),s=e("ba991daace2b8ed9");r._=function(e,t,r){return t=i._(t),s._(e,a._()?Reflect.construct(t,r||[],i._(e).constructor):t.apply(e,r))}},{feddc910f69a01a6:"NOGHw",b644f6b72647b399:"83nDe",ba991daace2b8ed9:"hd12h"}],NOGHw:[function(e,t,r,n){"use strict";function i(e){return r._=i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}r._=i},{}],"83nDe":[function(e,t,r,n){"use strict";function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(r._=i=function(){return!!e})()}r._=i},{}],hd12h:[function(e,t,r,n){"use strict";var i=e("f7151fe13994d2aa"),a=e("f18e81760bb14899");r._=function(e,t){return t&&("object"===a._(t)||"function"==typeof t)?t:i._(e)}},{f7151fe13994d2aa:"1tlYe",f18e81760bb14899:"iXhRw"}],"1tlYe":[function(e,t,r,n){"use strict";r._=function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},{}],iXhRw:[function(e,t,r,n){"use strict";r._=function(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}},{}],"4Uf9M":[function(e,t,r,n){"use strict";r._=function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}},{}],igUuK:[function(e,t,r,n){"use strict";function i(e,t){for(var r=0;rtypeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(r=i.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,n=e}finally{try{s||null==i.return||i.return()}finally{if(o)throw n}}return a}}},{}],heYSj:[function(e,t,r,n){"use strict";r._=function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],fh7mx:[function(e,t,r,n){"use strict";var i=e("3ee51b7dc02d0c44");r._=function(e,t){if(e){if("string"==typeof e)return i._(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i._(e,t)}}},{"3ee51b7dc02d0c44":"1WOAB"}],"1WOAB":[function(e,t,r,n){"use strict";r._=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);rtypeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}},{}],fWabh:[function(e,t,r,n){"use strict";r._=function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],j8pRR:[function(e,t,r,n){"use strict";var i=e("c8857d56f4968279"),a=e("2ed7bdf1701f2d07"),s=e("5c5ad8846076b9cd"),o=e("2db6fa09e8a5be4c");function c(e){var t="function"==typeof Map?new Map:void 0;return r._=c=function(e){if(null===e||!s._(e))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return i._(e,arguments,a._(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o._(r,e)},c(e)}r._=c},{c8857d56f4968279:"bC52X","2ed7bdf1701f2d07":"NOGHw","5c5ad8846076b9cd":"1mpbk","2db6fa09e8a5be4c":"7ubVA"}],bC52X:[function(e,t,r,n){"use strict";var i=e("62fc231ae2e75266"),a=e("3f98bf9d4f706151");function s(e,t,n){return i._()?r._=s=Reflect.construct:r._=s=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a._(i,r.prototype),i},s.apply(null,arguments)}r._=s},{"62fc231ae2e75266":"83nDe","3f98bf9d4f706151":"7ubVA"}],"1mpbk":[function(e,t,r,n){"use strict";r._=function(e){return -1!==Function.toString.call(e).indexOf("[native code]")}},{}],eltGh:[function(e,t,r,n){"use strict";r._=function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(s,"next",{value:c(0)}),o(s,"throw",{value:c(1)}),o(s,"return",{value:c(2)}),"function"==typeof Symbol&&o(s,Symbol.iterator,{value:function(){return this}}),s;function c(o){return function(c){var l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&l[0]?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},d="function"==typeof h[i]&&h[i],l=d.i||{},c=d.cache||{},u="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(t,s){if(!c[t]){if(!e[t]){if(a[t])return a[t];var r="function"==typeof h[i]&&h[i];if(!s&&r)return r(t,!0);if(d)return d(t,!0);if(u&&"string"==typeof t)return u(t);var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}l.resolve=function(s){var i=e[t][1][s];return null!=i?i:s},l.cache={};var o=c[t]=new m.Module(t);e[t][0].call(o.exports,l,o,o.exports,h)}return c[t].exports;function l(e){var t=l.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var s={__esModule:!0};return t.forEach(function(e){var t=e[0],i=e[1],a=e[2]||e[0],r=m(i);"*"===t?Object.keys(r).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{enumerable:!0,get:function(){return r[e]}})}):"*"===a?Object.defineProperty(s,t,{enumerable:!0,value:r}):Object.defineProperty(s,t,{enumerable:!0,get:function(){return"default"===a?r.__esModule?r.default:r:r[a]}})}),s}return m(t)}}m.isParcelRequire=!0,m.Module=function(e){this.id=e,this.bundle=m,this.require=u,this.exports={}},m.modules=e,m.cache=c,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=l,m.register=function(t,s){e[t]=[function(e,t){t.exports=s},{}]},Object.defineProperty(m,"root",{get:function(){return h[i]}}),h[i]=m;for(var _=0;_typeof module?module.exports=v:"function"==typeof define&&define.amd&&define(function(){return v})}}({bm4Y0:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o);var r=e("./jassub.es.js"),n=a.interopDefault(r);function o(e){return t=>{let s=new(0,n.default)({video:t.video,...e});return s._canvasParent.style.zIndex=20,t.on("destroy",()=>{s.destroy()}),{name:"artplayerPluginJassub",instance:s}}}"u">typeof window&&(window.artplayerPluginJassub=o)},{"./jassub.es.js":"kL36e","@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],kL36e:[function(e,t,s,i){var a=e("@parcel/transformer-js/src/esmodule-helpers.js");a.defineInteropFlag(s),a.export(s,"default",()=>o),"u">typeof HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){let t=performance.now(),s=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||s.totalVideoFrames-s.droppedVideoFrames,a=(r,n)=>{let o=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||o.totalVideoFrames-o.droppedVideoFrames;if(h>i){let i=this.mozFrameDelay||o.totalFrameDelay-s.totalFrameDelay||0,a=n-r;e(n,{presentationTime:n+1e3*i,expectedDisplayTime:n+a,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+a/1e3,presentedFrames:h,processingDuration:i}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(n,e))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(e=>a(t,e)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});let r={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},n={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}};class o extends EventTarget{constructor(e){if(super(),!globalThis.Worker)throw this.destroy("Worker not supported");if(!e)throw this.destroy("No options provided");this._loaded=new Promise(e=>{this._init=e});let t=o._test();if(this._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e.onDemandRender??!0),this._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(e.offscreenRender??!0),this.timeOffset=e.timeOffset||0,this._video=e.video,this._videoHeight=0,this._videoWidth=0,this._videoColorSpace=null,this._canvas=e.canvas,this._video&&!this._canvas)this._canvasParent=document.createElement("div"),this._canvasParent.className="JASSUB",this._canvasParent.style.position="relative",this._canvas=this._createCanvas(),this._video.insertAdjacentElement("afterend",this._canvasParent);else if(!this._canvas)throw this.destroy("Don't know where to render: you should give video or canvas in options.");if(this._bufferCanvas=document.createElement("canvas"),this._bufferCtx=this._bufferCanvas.getContext("2d"),!this._bufferCtx)throw this.destroy("Canvas rendering not supported");this._canvasctrl=this._offscreenRender?this._canvas.transferControlToOffscreen():this._canvas,this._ctx=!this._offscreenRender&&this._canvasctrl.getContext("2d"),this._lastRenderTime=0,this.debug=!!e.debug,this.prescaleFactor=e.prescaleFactor||1,this.prescaleHeightLimit=e.prescaleHeightLimit||1080,this.maxRenderHeight=e.maxRenderHeight||0,this._boundResize=this.resize.bind(this),this._boundTimeUpdate=this._timeupdate.bind(this),this._boundSetRate=this.setRate.bind(this),this._boundUpdateColorSpace=this._updateColorSpace.bind(this),this._video&&this.setVideo(e.video),this._onDemandRender&&(this.busy=!1,this._lastDemandTime=null),this._worker=new Worker(e.workerUrl||"jassub-worker.js"),this._worker.onmessage=e=>this._onmessage(e),this._worker.onerror=e=>this._error(e),t.then(()=>{this._worker.postMessage({target:"init",wasmUrl:o._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:e.wasmUrl??"jassub-worker.wasm",legacyWasmUrl:e.legacyWasmUrl??"jassub-worker.wasm.js",asyncRender:"u">typeof createImageBitmap&&(e.asyncRender??!0),onDemandRender:this._onDemandRender,width:this._canvasctrl.width||0,height:this._canvasctrl.height||0,blendMode:e.blendMode||"js",subUrl:e.subUrl,subContent:e.subContent||null,fonts:e.fonts||[],availableFonts:e.availableFonts||{"liberation sans":"./default.woff2"},fallbackFont:e.fallbackFont||"liberation sans",debug:this.debug,targetFps:e.targetFps||24,dropAllAnimations:e.dropAllAnimations,dropAllBlur:e.dropAllBlur,libassMemoryLimit:e.libassMemoryLimit||0,libassGlyphLimit:e.libassGlyphLimit||0,useLocalFonts:"u">typeof queryLocalFonts&&(e.useLocalFonts??!0),hasBitmapBug:o._hasBitmapBug}),!0===this._offscreenRender&&this.sendMessage("offscreenCanvas",null,[this._canvasctrl])})}_createCanvas(){return this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvasParent.appendChild(this._canvas),this._canvas}static _supportsSIMD=null;static _hasAlphaBug=null;static _hasBitmapBug=null;static _testSIMD(){if(null===o._supportsSIMD)try{o._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch{o._supportsSIMD=!1}}static async _testImageBugs(){if(null!==o._hasBitmapBug)return;let e=document.createElement("canvas"),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch{console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,s,i){let a=t.createImageData(s,i);return e&&a.data.set(e),a}}let s=document.createElement("canvas"),i=s.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("Canvas rendering not supported");e.width=s.width=1,e.height=s.height=1,t.clearRect(0,0,1,1),i.clearRect(0,0,1,1);let a=i.getImageData(0,0,1,1).data;t.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0);let r=i.getImageData(0,0,1,1).data;if(o._hasAlphaBug=a[1]!==r[1],o._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),"u">typeof createImageBitmap){let e=new Uint8ClampedArray([255,0,255,0,255]).subarray(1,5);i.drawImage(await createImageBitmap(new ImageData(e,1)),0,0);let{data:t}=i.getImageData(0,0,1,1);for(let[s,i]of(o._hasBitmapBug=!1,t.entries()))if(Math.abs(e[s]-i)>15){o._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}else o._hasBitmapBug=!1;e.remove(),s.remove()}static async _test(){o._testSIMD(),await o._testImageBugs()}resize(e=0,t=0,s=0,i=0,a=this._video?.paused){if((!e||!t)&&this._video){let a=this._getVideoPosition(),r=null;if(this._videoWidth){let e=this._video.videoWidth/this._videoWidth,t=this._video.videoHeight/this._videoHeight;r=this._computeCanvasSize((a.width||0)/e,(a.height||0)/t)}else r=this._computeCanvasSize(a.width||0,a.height||0);e=r.width,t=r.height,this._canvasParent&&(s=a.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=a.x),this._canvas.style.width=a.width+"px",this._canvas.style.height=a.height+"px"}this._canvas.style.top=s+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:e,height:t,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}_getVideoPosition(e=this._video.videoWidth,t=this._video.videoHeight){let s=e/t,{offsetWidth:i,offsetHeight:a}=this._video;e=i,t=a,i/a>s?e=Math.floor(a*s):t=Math.floor(i/s);let r=(i-e)/2,n=(a-t)/2;return{width:e,height:t,x:r,y:n}}_computeCanvasSize(e=0,t=0){let s=this.prescaleFactor<=0?1:this.prescaleFactor,i=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{let a=s<1?-1:1,r=t*i;a*r*s<=a*this.prescaleHeightLimit?r*=s:a*r0&&r>this.maxRenderHeight&&(r=this.maxRenderHeight),e*=r/t,t=r}return{width:e,height:t}}_timeupdate({type:e}){let t={seeking:!0,waiting:!0,playing:!1}[e];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}setVideo(e){e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),"u">typeof ResizeObserver&&(this._ro||(this._ro=new ResizeObserver(()=>this.resize())),this._ro.observe(e))):this._error("Video element invalid!")}runBenchmark(){this.sendMessage("runBenchmark")}setTrackByUrl(e){this.sendMessage("setTrackByUrl",{url:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}setTrack(e){this.sendMessage("setTrack",{content:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}freeTrack(){this.sendMessage("freeTrack")}setIsPaused(e){this.sendMessage("video",{isPaused:e})}setRate(e){this.sendMessage("video",{rate:e})}setCurrentTime(e,t,s){this.sendMessage("video",{isPaused:e,currentTime:t,rate:s,colorSpace:this._videoColorSpace})}createEvent(e){this.sendMessage("createEvent",{event:e})}setEvent(e,t){this.sendMessage("setEvent",{event:e,index:t})}removeEvent(e){this.sendMessage("removeEvent",{index:e})}getEvents(e){this._fetchFromWorker({target:"getEvents"},(t,{events:s})=>{e(t,s)})}styleOverride(e){this.sendMessage("styleOverride",{style:e})}disableStyleOverride(){this.sendMessage("disableStyleOverride")}createStyle(e){this.sendMessage("createStyle",{style:e})}setStyle(e,t){this.sendMessage("setStyle",{style:e,index:t})}removeStyle(e){this.sendMessage("removeStyle",{index:e})}getStyles(e){this._fetchFromWorker({target:"getStyles"},(t,{styles:s})=>{e(t,s)})}addFont(e){this.sendMessage("addFont",{font:e})}setDefaultFont(e){this.sendMessage("defaultFont",{font:e})}_sendLocalFont(e){try{queryLocalFonts().then(t=>{let s=t?.find(t=>t.fullName.toLowerCase()===e);s&&s.blob().then(e=>{e.arrayBuffer().then(e=>{this.addFont(new Uint8Array(e))})})})}catch(e){console.warn("Local fonts API:",e)}}_getLocalFont({font:e}){try{navigator?.permissions?.query?navigator.permissions.query({name:"local-fonts"}).then(t=>{"granted"===t.state&&this._sendLocalFont(e)}):this._sendLocalFont(e)}catch(e){console.warn("Local fonts API:",e)}}_unbusy(){this._lastDemandTime?this._demandRender(this._lastDemandTime):this.busy=!1}_handleRVFC(e,{mediaTime:t,width:s,height:i}){if(this._destroyed)return null;this.busy?this._lastDemandTime={mediaTime:t,width:s,height:i}:(this.busy=!0,this._demandRender({mediaTime:t,width:s,height:i})),this._video.requestVideoFrameCallback(this._handleRVFC.bind(this))}_demandRender({mediaTime:e,width:t,height:s}){this._lastDemandTime=null,(t!==this._videoWidth||s!==this._videoHeight)&&(this._videoWidth=t,this._videoHeight=s,this.resize()),this.sendMessage("demand",{time:e+this.timeOffset})}_detachOffscreen(){if(!this._offscreenRender||this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas,this._ctx=this._canvasctrl.getContext("2d"),this.sendMessage("detachOffscreen"),this.busy=!1,this.resize(0,0,0,0,!0)}_reAttachOffscreen(){if(!this._offscreenRender||!this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas.transferControlToOffscreen(),this._ctx=!1,this.sendMessage("offscreenCanvas",null,[this._canvasctrl]),this.resize(0,0,0,0,!0)}_updateColorSpace(){this._video.requestVideoFrameCallback(()=>{try{let e=new VideoFrame(this._video);this._videoColorSpace=r[e.colorSpace.matrix],e.close(),this.sendMessage("getColorSpace")}catch(e){console.warn(e)}})}_verifyColorSpace({subtitleColorSpace:e,videoColorSpace:t=this._videoColorSpace}){e&&t&&e!==t&&(this._detachOffscreen(),this._ctx.filter=`url("data:image/svg+xml;utf8,#f")`)}_render({images:e,asyncRender:t,times:s,width:i,height:a,colorSpace:r}){for(let n of(this._unbusy(),this.debug&&(s.IPCTime=Date.now()-s.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:r})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height),e))n.image&&(t?(this._ctx.drawImage(n.image,n.x,n.y),n.image.close()):(this._bufferCanvas.width=n.w,this._bufferCanvas.height=n.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(n.image)),n.w,n.h),0,0),this._ctx.drawImage(this._bufferCanvas,n.x,n.y)));if(this.debug){s.JSRenderTime=Date.now()-s.JSRenderTime-s.IPCTime;let t=0,i=s.bitmaps||e.length;for(let e in delete s.bitmaps,s)t+=s[e];console.log("Bitmaps: "+i+" Total: "+(0|t)+"ms",s)}}_fixAlpha(e){if(o._hasAlphaBug)for(let t=3;t1?e[t]:1;return e}_ready(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}async sendMessage(e,t={},s){await this._loaded,s?this._worker.postMessage({target:e,transferable:s,...t},[...s]):this._worker.postMessage({target:e,...t})}_fetchFromWorker(e,t){try{let s=e.target,i=setTimeout(()=>{r(Error("Error: Timeout while try to fetch "+s))},5e3),a=({data:e})=>{e.target===s&&(t(null,e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i))},r=e=>{t(e),this._worker.removeEventListener("message",a),this._worker.removeEventListener("error",r),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",r),this._worker.postMessage(e)}catch(e){this._error(e)}}_console({content:e,command:t}){console[t].apply(console,JSON.parse(e))}_onmessage({data:e}){this["_"+e.target]&&this["_"+e.target](e)}_error(e){let t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),s=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(s),console.error(t),t}_removeListeners(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}destroy(e){return e&&(e=this._error(e)),this._video&&this._canvasParent&&this._video.parentNode?.removeChild(this._canvasParent),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),this._worker?.terminate(),e}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"loqXi"}],loqXi:[function(e,t,s,i){s.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},s.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},s.exportAll=function(e,t){return Object.keys(e).forEach(function(s){"default"===s||"__esModule"===s||Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[s]}})}),t},s.export=function(e,t,s){Object.defineProperty(e,t,{enumerable:!0,get:s})}},{}]},["bm4Y0"],"bm4Y0","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("bm4Y0");export{e as default}; \ No newline at end of file