mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-09 20:26:16 -08:00
Refactor code structure for improved readability and maintainability
Remove debugging border from the websr plugin's styling Enhance canvas sizing logic in artplayer-plugin-websr - Updated canvas positioning to center it within the player. - Introduced a new function to calculate canvas size based on the video aspect ratio. - Adjusted canvas dimensions during initialization and on resize events to maintain aspect ratio. - Ensured canvas styles are updated to reflect the calculated dimensions. feat: add comparison mode to artplayer-plugin-websr - Updated README.md to reflect new comparison feature and simplified content. - Modified package.json to remove unnecessary keywords. - Enhanced index.js to implement comparison functionality, allowing users to compare original and upscaled video. - Added new methods for enabling, disabling, and toggling comparison mode, as well as setting and getting the comparison position. - Updated TypeScript definitions to include new comparison options and methods.
This commit is contained in:
1 parent
07a5b0c0f0
commit
7dffd99cfd
308 files changed
+3175
-852
No files matched your search
@@ -5,4 +5,4 @@
|
||||
* (c) 2017-2026 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(t,e,r,a,n,o,i,l){var d="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},p="function"==typeof d[a]&&d[a],s=p.i||{},u=p.cache||{},c="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(e,r){if(!u[e]){if(!t[e]){if(n[e])return n[e];var o="function"==typeof d[a]&&d[a];if(!r&&o)return o(e,!0);if(p)return p(e,!0);if(c&&"string"==typeof e)return c(e);var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}s.resolve=function(r){var a=t[e][1][r];return null!=a?a:r},s.cache={};var l=u[e]=new f.Module(e);t[e][0].call(l.exports,s,l,l.exports,d)}return u[e].exports;function s(t){var e=s.resolve(t);if(!1===e)return{};if(Array.isArray(e)){var r={__esModule:!0};return e.forEach(function(t){var e=t[0],a=t[1],n=t[2]||t[0],o=f(a);"*"===e?Object.keys(o).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:function(){return o[t]}})}):"*"===n?Object.defineProperty(r,e,{enumerable:!0,value:o}):Object.defineProperty(r,e,{enumerable:!0,get:function(){return"default"===n?o.__esModule?o.default:o:o[n]}})}),r}return f(e)}}f.isParcelRequire=!0,f.Module=function(t){this.id=t,this.bundle=f,this.require=c,this.exports={}},f.modules=t,f.cache=u,f.parent=p,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=s,f.register=function(e,r){t[e]=[function(t,e){e.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return d[a]}}),d[a]=f;for(var h=0;h<e.length;h++)f(e[h]);if(r){var g=f(r);"object"==typeof exports&&"u">typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({"3VfEb":[function(t,e,r,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",()=>l);var o=t("bundle-text:./style.less"),i=n.interopDefault(o);function l(t={}){return e=>{let{$player:r}=e.template,{setStyle:a,append:n,clamp:o,query:i,addClass:l,removeClass:d}=e.constructor.utils,p=`<div class="art-chapter"><div class="art-chapter-inner"><div class="art-progress-hover"></div><div class="art-progress-loaded"></div><div class="art-progress-played"></div></div></div>`,s=[],u=e.query(".art-control-progress-inner"),c=n(u,'<div class="art-chapters"></div>'),f=n(u,'<div class="art-chapter-title"></div>');function h(t=[]){if((s=[],c.textContent="",d(r,"artplayer-plugin-chapter"),Array.isArray(t)&&t.length)&&e.duration){t=t.sort((t,e)=>t.start-e.start);for(let r=0;r<t.length;r++){let a=t[r],n=t[r+1];if(a.end===1/0&&(a.end=e.duration),"number"!=typeof a.start||"number"!=typeof a.end||"string"!=typeof a.title)throw TypeError("Illegal chapter data type");if(a.start<0||a.end>e.duration||a.start>=a.end||n&&a.end>n.start)throw Error("Illegal chapter time point")}t[0].start>0&&t.unshift({start:0,end:t[0].start,title:""}),t[t.length-1].end<e.duration&&t.push({start:t[t.length-1].end,end:e.duration,title:""});for(let e=0;e<t.length-1;e++)t[e].end!==t[e+1].start&&t.splice(e+1,0,{start:t[e].end,end:t[e+1].start,title:""});s=t.map(t=>{let r=n(c,p),a=o(t.start,0,e.duration),l=o(t.end,0,e.duration),d=l-a,s=d/e.duration;return r.dataset.start=a,r.dataset.end=l,r.dataset.duration=d,r.dataset.title=t.title.trim(),r.style.width=`${100*s}%`,{$chapter:r,$hover:i(".art-progress-hover",r),$loaded:i(".art-progress-loaded",r),$played:i(".art-progress-played",r)}}),l(r,"artplayer-plugin-chapter"),e.emit("setBar","loaded",e.loaded||0)}}return e.on("setBar",(t,r)=>{if(s.length)for(let n=0;n<s.length;n++){let{$chapter:o,$loaded:i,$played:l,$hover:d}=s[n],p={hover:d,loaded:i,played:l}[t];if(!p)return;let h=c.clientWidth*r,g=e.duration*r,y=Number.parseFloat(o.dataset.duration),m=Number.parseFloat(o.dataset.start),v=Number.parseFloat(o.dataset.end);if(g<m&&a(p,"width",0),g>v&&a(p,"width","100%"),g>=m&&g<=v){let e=(g-m)/y;a(p,"width",`${100*e}%`),"hover"===t&&h>0&&function({$chapter:t,width:e}){let r=t.dataset.title.trim();if(r){f.textContent=r;let t=f.clientWidth;e<=t/2?a(f,"left",0):e>u.clientWidth-t/2?a(f,"left",`${u.clientWidth-t}px`):a(f,"left",`${e-t/2}px`)}}({$chapter:o,width:h})}}}),e.once("video:loadedmetadata",()=>h(t.chapters)),{name:"artplayerPluginChapter",update:({chapters:t})=>h(t)}}}if("u">typeof document){let t="artplayer-plugin-chapter",e=document.getElementById(t);e||((e=document.createElement("style")).id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(e)}):(document.head||document.documentElement).appendChild(e)),e.textContent=i.default}"u">typeof window&&(window.artplayerPluginChapter=l)},{"bundle-text:./style.less":"4RPBI","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"4RPBI":[function(t,e,r,a){e.exports=".artplayer-plugin-chapter .art-control-progress-inner{background-color:#0000!important;height:100%!important}.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-hover,.artplayer-pluginLine truncated
|
||||
!function(t,e,r,a,n){var o="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},i="function"==typeof o[a]&&o[a],l=i.i||{},d=i.cache||{},p="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(e,r){if(!d[e]){if(!t[e]){if(n[e])return n[e];var l="function"==typeof o[a]&&o[a];if(!r&&l)return l(e,!0);if(i)return i(e,!0);if(p&&"string"==typeof e)return p(e);var u=Error("Cannot find module '"+e+"'");throw u.code="MODULE_NOT_FOUND",u}f.resolve=function(r){var a=t[e][1][r];return null!=a?a:r},f.cache={};var c=d[e]=new s.Module(e);t[e][0].call(c.exports,f,c,c.exports,o)}return d[e].exports;function f(t){var e=f.resolve(t);if(!1===e)return{};if(Array.isArray(e)){var r={__esModule:!0};return e.forEach(function(t){var e=t[0],a=t[1],n=t[2]||t[0],o=s(a);"*"===e?Object.keys(o).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:function(){return o[t]}})}):"*"===n?Object.defineProperty(r,e,{enumerable:!0,value:o}):Object.defineProperty(r,e,{enumerable:!0,get:function(){return"default"===n?o.__esModule?o.default:o:o[n]}})}),r}return s(e)}}s.isParcelRequire=!0,s.Module=function(t){this.id=t,this.bundle=s,this.require=p,this.exports={}},s.modules=t,s.cache=d,s.parent=i,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=l,s.register=function(e,r){t[e]=[function(t,e){e.exports=r},{}]},Object.defineProperty(s,"root",{get:function(){return o[a]}}),o[a]=s;for(var u=0;u<e.length;u++)s(e[u]);if(r){var c=s(r);"object"==typeof exports&&"u">typeof module?module.exports=c:"function"==typeof define&&define.amd&&define(function(){return c})}}({"3VfEb":[function(t,e,r,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",()=>l);var o=t("bundle-text:./style.less"),i=n.interopDefault(o);function l(t={}){return e=>{let{$player:r}=e.template,{setStyle:a,append:n,clamp:o,query:i,addClass:l,removeClass:d}=e.constructor.utils,p=`<div class="art-chapter"><div class="art-chapter-inner"><div class="art-progress-hover"></div><div class="art-progress-loaded"></div><div class="art-progress-played"></div></div></div>`,s=[],u=e.query(".art-control-progress-inner"),c=n(u,'<div class="art-chapters"></div>'),f=n(u,'<div class="art-chapter-title"></div>');function h(t=[]){if((s=[],c.textContent="",d(r,"artplayer-plugin-chapter"),Array.isArray(t)&&t.length)&&e.duration){t=t.sort((t,e)=>t.start-e.start);for(let r=0;r<t.length;r++){let a=t[r],n=t[r+1];if(a.end===1/0&&(a.end=e.duration),"number"!=typeof a.start||"number"!=typeof a.end||"string"!=typeof a.title)throw TypeError("Illegal chapter data type");if(a.start<0||a.end>e.duration||a.start>=a.end||n&&a.end>n.start)throw Error("Illegal chapter time point")}t[0].start>0&&t.unshift({start:0,end:t[0].start,title:""}),t[t.length-1].end<e.duration&&t.push({start:t[t.length-1].end,end:e.duration,title:""});for(let e=0;e<t.length-1;e++)t[e].end!==t[e+1].start&&t.splice(e+1,0,{start:t[e].end,end:t[e+1].start,title:""});s=t.map(t=>{let r=n(c,p),a=o(t.start,0,e.duration),l=o(t.end,0,e.duration),d=l-a,s=d/e.duration;return r.dataset.start=a,r.dataset.end=l,r.dataset.duration=d,r.dataset.title=t.title.trim(),r.style.width=`${100*s}%`,{$chapter:r,$hover:i(".art-progress-hover",r),$loaded:i(".art-progress-loaded",r),$played:i(".art-progress-played",r)}}),l(r,"artplayer-plugin-chapter"),e.emit("setBar","loaded",e.loaded||0)}}return e.on("setBar",(t,r)=>{if(s.length)for(let n=0;n<s.length;n++){let{$chapter:o,$loaded:i,$played:l,$hover:d}=s[n],p={hover:d,loaded:i,played:l}[t];if(!p)return;let h=c.clientWidth*r,g=e.duration*r,y=Number.parseFloat(o.dataset.duration),m=Number.parseFloat(o.dataset.start),v=Number.parseFloat(o.dataset.end);if(g<m&&a(p,"width",0),g>v&&a(p,"width","100%"),g>=m&&g<=v){let e=(g-m)/y;a(p,"width",`${100*e}%`),"hover"===t&&h>0&&function({$chapter:t,width:e}){let r=t.dataset.title.trim();if(r){f.textContent=r;let t=f.clientWidth;e<=t/2?a(f,"left",0):e>u.clientWidth-t/2?a(f,"left",`${u.clientWidth-t}px`):a(f,"left",`${e-t/2}px`)}}({$chapter:o,width:h})}}}),e.once("video:loadedmetadata",()=>h(t.chapters)),{name:"artplayerPluginChapter",update:({chapters:t})=>h(t)}}}if("u">typeof document){let t="artplayer-plugin-chapter",e=document.getElementById(t);e||((e=document.createElement("style")).id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(e)}):(document.head||document.documentElement).appendChild(e)),e.textContent=i.default}"u">typeof window&&(window.artplayerPluginChapter=l)},{"bundle-text:./style.less":"4RPBI","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"4RPBI":[function(t,e,r,a){e.exports=".artplayer-plugin-chapter .art-control-progress-inner{background-color:#0000!important;height:100%!important}.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-hover,.artplayer-plugin-chaptLine truncated
|
||||
Reference in new issue
Block a user