mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -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(e,t,r,n,o,i,c,a){var u="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},f="function"==typeof u[n]&&u[n],l=f.i||{},s=f.cache||{},d="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,r){if(!s[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(f)return f(t,!0);if(d&&"string"==typeof t)return d(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var a=s[t]=new p.Module(t);e[t][0].call(a.exports,l,a,a.exports,u)}return s[t].exports;function l(e){var t=l.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],o=e[2]||e[0],i=p(n);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(r,t,{enumerable:!0,value:i}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),r}return p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=d,this.exports={}},p.modules=e,p.cache=s,p.parent=f,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=l,p.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(p,"root",{get:function(){return u[n]}}),u[n]=p;for(var y=0;y<t.length;y++)p(t[y]);if(r){var b=p(r);"object"==typeof exports&&"u">typeof module?module.exports=b:"function"==typeof define&&define.amd&&define(function(){return b})}}({LnyEn:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return u});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_to_consumable_array.cjs"),a=e("@swc/helpers/cjs/_ts_generator.cjs");function u(e){return function(t){var r,n=function(e){e in l||Object.defineProperty(l,e,{get:function(){var t=s[e];return"function"==typeof t?t.bind(s):t},set:function(t){s[e]=t},configurable:!0,enumerable:!0})},o=function(e){l[e]=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e in y?y[e].apply(y,(0,c._)(r)):s[e].apply(s,(0,c._)(r))}},u=t.constructor,f=u.utils.createElement,l=f("canvas"),s=f("video"),d=l.getContext("2d"),p=null,y={};for(var b in l)"function"==typeof l[b]&&(y[b]=l[b].bind(l));for(var h in s)n(h);for(var v in y)o(v);return r=u.config.events,setTimeout(function(){r.forEach(function(e){t.proxy(s,e,function(e){t.emit("video:".concat(e.type),e)})})}),t.on("video:loadedmetadata",function(){l.width=s.videoWidth,l.height=s.videoHeight}),t.on("video:play",function(){cancelAnimationFrame(p),function e(){return(0,i._)(function(){return(0,a._)(this,function(t){switch(t.label){case 0:return[4,m()];case 1:return t.sent(),p=requestAnimationFrame(e),[2]}})})()}()}),t.on("video:pause",function(){cancelAnimationFrame(p)}),t.on("resize",function(){!function(){var e,r,n,o=null==(e=t.template)?void 0:e.$player;if(o&&!t.option.autoSize){var i=s.videoWidth/s.videoHeight,c=o.clientWidth,a=o.clientHeight;c/a>i?r=(n=a)*i:n=(r=c)/i,l.width=r,l.height=n;var u=(c-r)/2,f=(a-n)/2;Object.assign(l.style,{padding:"".concat(f,"px ").concat(u,"px")})}}(),m()}),t.on("destroy",function(){cancelAnimationFrame(p)}),l;function m(){return(0,i._)(function(){var r,n;return(0,a._)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,4,,5]),"u"<typeof createImageBitmap)return[3,2];return[4,createImageBitmap(s)];case 1:return r=o.sent(),d.drawImage(r,0,0,l.width,l.height),r.close(),[3,3];case 2:d.drawImage(s,0,0,l.width,l.height),o.label=3;case 3:return e&&e(d,s),t.emit("artplayerProxyCanvas:draw",d,s),[3,5];case 4:return n=o.sent(),t.emit("artplayerProxyCanvas:error",n),[3,5];case 5:return[2]}})})()}}}"u">typeof window&&(window.artplayerProxyCanvas=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],i81N6:[function(e,t,r,n){"use strict";var o=e("d402183024004bc7"),i=e("3209e2b12672cd18"),c=e("fc58adb8f1bff142"),a=e("5e213dc122a10171");r._=function(e){return o._(e)||i._(e)||a._(e)||c._()}},{d402183024004bc7:"hfQG0","3209e2b12672cd18":"fQrlQ",fc58adb8f1bff142:"fWabh","5e213dc122a10171":"fh7mx"}],hfQG0:[function(e,t,r,n){"use strict";var o=e("5bd5b10bf87fc8e");r._=function(e){if(Array.isArray(e))return o._Line truncated
|
||||
!function(e,t,r,n,o){var i="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},c="function"==typeof i[n]&&i[n],a=c.i||{},u=c.cache||{},f="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function l(t,r){if(!u[t]){if(!e[t]){if(o[t])return o[t];var a="function"==typeof i[n]&&i[n];if(!r&&a)return a(t,!0);if(c)return c(t,!0);if(f&&"string"==typeof t)return f(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}p.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},p.cache={};var d=u[t]=new l.Module(t);e[t][0].call(d.exports,p,d,d.exports,i)}return u[t].exports;function p(e){var t=p.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],o=e[2]||e[0],i=l(n);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(r,t,{enumerable:!0,value:i}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),r}return l(t)}}l.isParcelRequire=!0,l.Module=function(e){this.id=e,this.bundle=l,this.require=f,this.exports={}},l.modules=e,l.cache=u,l.parent=c,l.distDir=void 0,l.publicUrl=void 0,l.devServer=void 0,l.i=a,l.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(l,"root",{get:function(){return i[n]}}),i[n]=l;for(var s=0;s<t.length;s++)l(t[s]);if(r){var d=l(r);"object"==typeof exports&&"u">typeof module?module.exports=d:"function"==typeof define&&define.amd&&define(function(){return d})}}({LnyEn:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return u});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_to_consumable_array.cjs"),a=e("@swc/helpers/cjs/_ts_generator.cjs");function u(e){return function(t){var r,n=function(e){e in l||Object.defineProperty(l,e,{get:function(){var t=s[e];return"function"==typeof t?t.bind(s):t},set:function(t){s[e]=t},configurable:!0,enumerable:!0})},o=function(e){l[e]=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e in y?y[e].apply(y,(0,c._)(r)):s[e].apply(s,(0,c._)(r))}},u=t.constructor,f=u.utils.createElement,l=f("canvas"),s=f("video"),d=l.getContext("2d"),p=null,y={};for(var b in l)"function"==typeof l[b]&&(y[b]=l[b].bind(l));for(var h in s)n(h);for(var v in y)o(v);return r=u.config.events,setTimeout(function(){r.forEach(function(e){t.proxy(s,e,function(e){t.emit("video:".concat(e.type),e)})})}),t.on("video:loadedmetadata",function(){l.width=s.videoWidth,l.height=s.videoHeight}),t.on("video:play",function(){cancelAnimationFrame(p),function e(){return(0,i._)(function(){return(0,a._)(this,function(t){switch(t.label){case 0:return[4,m()];case 1:return t.sent(),p=requestAnimationFrame(e),[2]}})})()}()}),t.on("video:pause",function(){cancelAnimationFrame(p)}),t.on("resize",function(){!function(){var e,r,n,o=null==(e=t.template)?void 0:e.$player;if(o&&!t.option.autoSize){var i=s.videoWidth/s.videoHeight,c=o.clientWidth,a=o.clientHeight;c/a>i?r=(n=a)*i:n=(r=c)/i,l.width=r,l.height=n;var u=(c-r)/2,f=(a-n)/2;Object.assign(l.style,{padding:"".concat(f,"px ").concat(u,"px")})}}(),m()}),t.on("destroy",function(){cancelAnimationFrame(p)}),l;function m(){return(0,i._)(function(){var r,n;return(0,a._)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,4,,5]),"u"<typeof createImageBitmap)return[3,2];return[4,createImageBitmap(s)];case 1:return r=o.sent(),d.drawImage(r,0,0,l.width,l.height),r.close(),[3,3];case 2:d.drawImage(s,0,0,l.width,l.height),o.label=3;case 3:return e&&e(d,s),t.emit("artplayerProxyCanvas:draw",d,s),[3,5];case 4:return n=o.sent(),t.emit("artplayerProxyCanvas:error",n),[3,5];case 5:return[2]}})})()}}}"u">typeof window&&(window.artplayerProxyCanvas=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],i81N6:[function(e,t,r,n){"use strict";var o=e("d402183024004bc7"),i=e("3209e2b12672cd18"),c=e("fc58adb8f1bff142"),a=e("5e213dc122a10171");r._=function(e){return o._(e)||i._(e)||a._(e)||c._()}},{d402183024004bc7:"hfQG0","3209e2b12672cd18":"fQrlQ",fc58adb8f1bff142:"fWabh","5e213dc122a10171":"fh7mx"}],hfQG0:[function(e,t,r,n){"use strict";var o=e("5bd5b10bf87fc8e");r._=function(e){if(Array.isArray(e))return o._(e)}},Line truncated
|
||||
Reference in new issue
Block a user