mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
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.
8 lines
9.8 KiB
JavaScript
8 lines
9.8 KiB
JavaScript
|
|
/*!
|
|
* artplayer-plugin-document-pip.js v1.0.2
|
|
* Github: https://github.com/zhw2590582/ArtPlayer
|
|
* (c) 2017-2026 Harvey Zack
|
|
* Released under the MIT License.
|
|
*/
|
|
!function(e,t,n,r,o){var i="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},l="function"==typeof i[r]&&i[r],c=l.i||{},u=l.cache||{},a="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,n){if(!u[t]){if(!e[t]){if(o[t])return o[t];var c="function"==typeof i[r]&&i[r];if(!n&&c)return c(t,!0);if(l)return l(t,!0);if(a&&"string"==typeof t)return a(t);var s=Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}f.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},f.cache={};var p=u[t]=new d.Module(t);e[t][0].call(p.exports,f,p,p.exports,i)}return u[t].exports;function f(e){var t=f.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],r=e[1],o=e[2]||e[0],i=d(r);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(n,t,{enumerable:!0,value:i}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),n}return d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=a,this.exports={}},d.modules=e,d.cache=u,d.parent=l,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=c,d.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(d,"root",{get:function(){return i[r]}}),i[r]=d;for(var s=0;s<t.length;s++)d(t[s]);if(n){var p=d(n);"object"==typeof exports&&"u">typeof module?module.exports=p:"function"==typeof define&&define.amd&&define(function(){return p})}}({"5Wzsp":[function(e,t,n,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(n),o.export(n,"default",function(){return d});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),l=e("@swc/helpers/cjs/_object_spread.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs"),u=e("bundle-text:./style.less"),a=o.interopDefault(u);function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,l._)({width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture"},e);return function(e){var n,r="documentPictureInPicture"in window&&"function"==typeof(null==(n=window.documentPictureInPicture)?void 0:n.requestWindow),o=e.proxy,l=e.icons,u=e.i18n,a=e.template.$player,d=e.constructor.utils,s=d.append,p=d.tooltip,f=d.addClass,h=d.removeClass,m=d.sleep,y={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};function v(){return(0,i._)(function(){var n,o,i,l,u,d,s,p;return(0,c._)(this,function(c){switch(c.label){case 0:if(!r&&t.fallbackToVideoPiP)return e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture"),[2];if(y.win)return[2];c.label=1;case 1:return c.trys.push([1,4,,5]),[4,window.documentPictureInPicture.requestWindow({width:t.width,height:t.height})];case 2:y.win=i=c.sent(),y.currentDoc=i.document,y.placeholder=document.createElement("div"),y.placeholder.className="artplayer-document-pip-placeholder",y.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",y.placeholder.textContent=t.placeholder,y.originalParent=a.parentNode,y.originalNext=a.nextSibling,y.originalParent.insertBefore(y.placeholder,y.originalNext),(l=i.document.createElement("div")).id="__art_dpip_root",i.document.body.appendChild(l);var h=i.document,v=h.createElement("style");if(v.textContent="\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n ",h.head.appendChild(v),!h.querySelector('meta[name="viewport"]')){var g=h.createElement("meta");g.name="viewport",g.content="width=device-width,initial-scale=1",h.head.appendChild(g)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(function(e){var t=h.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),h.head.appendChild(t)})}catch(e){}try{document.querySelectorAll("style").forEach(function(e){var t=h.createElement("style");t.textContent=e.textContent,h.head.appendChild(t)})}catch(e){}return u=i.document.adoptNode(a),l.appendChild(u),y.currentDoc=i.document,d=function(){var t;return null==(t=e.resize)?void 0:t.call(e)},s=function(){return b()},i.addEventListener("resize",d),i.addEventListener("pagehide",s),i.addEventListener("unload",s),y.cleanup=function(){i.removeEventListener("resize",d),i.removeEventListener("pagehide",s),i.removeEventListener("unload",s)},f(a,"artplayer-document-pip"),null==(n=(o=e.events).bindGlobalEvents)||n.call(o),e.emit("document-pip",!0),[4,m(100)];case 3:return c.sent(),e.emit("resize"),[3,5];case 4:return p=c.sent(),e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",p),[3,5];case 5:return[2]}})})()}function b(){return(0,i._)(function(){var t,n,r,o;return(0,c._)(this,function(i){switch(i.label){case 0:if(!y.win)return[2];i.label=1;case 1:if(i.trys.push([1,3,,4]),null==(t=y.cleanup)||t.call(y),y.placeholder){var l=y.placeholder.ownerDocument||document,c=l.adoptNode(a);y.originalParent.insertBefore(c,y.placeholder),y.placeholder.remove(),y.placeholder=null,y.currentDoc=l}return y.win.close(),y.win=null,h(a,"artplayer-document-pip"),null==(n=(r=e.events).bindGlobalEvents)||n.call(r),e.emit("document-pip",!1),[4,m(100)];case 2:return i.sent(),e.emit("resize"),[3,4];case 3:return o=i.sent(),e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",o),[3,4];case 4:return[2]}})})()}function g(){y.win?b():v()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:function(t){s(t,l.pip),o(t,"click",g),e.on("document-pip",function(e){p(t,u.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",b),{name:"artplayerPluginDocumentPip",get isSupported(){return r},get isActive(){return!!y.win},open:v,close:b,toggle:g}}}if("u">typeof window&&(window.artplayerPluginDocumentPip=d),"u">typeof document){var s="artplayer-plugin-document-pip",p=document.getElementById(s);p||((p=document.createElement("style")).id=s,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){document.head.appendChild(p)}):(document.head||document.documentElement).appendChild(p)),p.textContent=a.default}},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","bundle-text:./style.less":"gAlyW","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,n,r){"use strict";function o(e,t,n,r,o,i,l){try{var c=e[i](l),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}n._=function(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var l=e.apply(t,n);function c(e){o(l,r,i,c,u,"next",e)}function u(e){o(l,r,i,c,u,"throw",e)}c(void 0)})}}},{}],kyoEj:[function(e,t,n,r){"use strict";var o=e("9f9b8a24218ee51e");n._=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){o._(e,t,n[t])})}return e}},{"9f9b8a24218ee51e":"ltU3W"}],ltU3W:[function(e,t,n,r){"use strict";n._=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},{}],eltGh:[function(e,t,n,r){"use strict";n._=function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(l,"next",{value:u(0)}),c(l,"throw",{value:u(1)}),c(l,"return",{value:u(2)}),"function"==typeof Symbol&&c(l,Symbol.iterator,{value:function(){return this}}),l;function u(c){return function(u){var a=[c,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}},{}],gAlyW:[function(e,t,n,r){t.exports=".artplayer-document-pip.art-video-player{width:100%!important;height:100%!important}"},{}],qpMMf:[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["5Wzsp"],"5Wzsp","parcelRequire4dc0",{}); |