mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 19:01:20 -08:00
feat: add Document Picture-in-Picture plugin for ArtPlayer
- Implemented the core functionality of the Document Picture-in-Picture plugin. - Created main plugin file `artplayer-plugin-document-pip.js` with support for opening and closing the PIP window. - Added legacy support in `artplayer-plugin-document-pip.legacy.js`. - Defined plugin options in `package.json` and included necessary metadata. - Developed the main logic in `src/index.js`, including style copying and event handling. - Created TypeScript definitions in `types/artplayer-plugin-document-pip.d.ts` for better type safety.
This commit is contained in:
1 parent
c23520a4a6
commit
7d4175efbc
73 files changed
+722
-230
No files matched your search
@@ -163,19 +163,17 @@
|
||||
})({"55Mmu":[function(require,module,exports,__globalThis) {
|
||||
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||||
parcelHelpers.defineInteropFlag(exports);
|
||||
parcelHelpers.export(exports, "default", ()=>artplayerPluginPip);
|
||||
function artplayerPluginPip(userOptions = {}) {
|
||||
parcelHelpers.export(exports, "default", ()=>artplayerPluginDocumentPip);
|
||||
function artplayerPluginDocumentPip(userOptions = {}) {
|
||||
const options = {
|
||||
width: 480,
|
||||
height: 270,
|
||||
fallbackToVideoPiP: true,
|
||||
placeholder: `Playing in Document Picture-in-Picture`,
|
||||
...userOptions
|
||||
};
|
||||
return (art)=>{
|
||||
if (!('documentPictureInPicture' in window)) {
|
||||
art.notice.show = 'Document Picture-in-Picture is not supported';
|
||||
return;
|
||||
}
|
||||
const dpipOK = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function';
|
||||
const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip } } } = art;
|
||||
const state = {
|
||||
win: null,
|
||||
@@ -185,21 +183,44 @@ function artplayerPluginPip(userOptions = {}) {
|
||||
placeholder: null
|
||||
};
|
||||
function copyStylesTo(targetDoc) {
|
||||
const baseStyle = `
|
||||
html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }
|
||||
#__art_dpip_root { position:absolute; inset:0; display:flex; }
|
||||
#__art_dpip_root > * { width:100% !important; height:100% !important; }
|
||||
`;
|
||||
const $style = document.querySelector('#artplayer-style');
|
||||
const clone = targetDoc.createElement('style');
|
||||
clone.textContent = baseStyle + $style.textContent;
|
||||
targetDoc.head.appendChild(clone);
|
||||
const meta = targetDoc.createElement('meta');
|
||||
meta.name = 'viewport';
|
||||
meta.content = 'width=device-width,initial-scale=1';
|
||||
targetDoc.head.appendChild(meta);
|
||||
const base = targetDoc.createElement('style');
|
||||
base.textContent = `
|
||||
html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }
|
||||
#__art_dpip_root { position:absolute; inset:0; display:flex; }
|
||||
#__art_dpip_root > * { width:100% !important; height:100% !important; }
|
||||
`;
|
||||
targetDoc.head.appendChild(base);
|
||||
if (!targetDoc.querySelector('meta[name="viewport"]')) {
|
||||
const meta = targetDoc.createElement('meta');
|
||||
meta.name = 'viewport';
|
||||
meta.content = 'width=device-width,initial-scale=1';
|
||||
targetDoc.head.appendChild(meta);
|
||||
}
|
||||
try {
|
||||
document.querySelectorAll('link[rel="stylesheet"]').forEach((link)=>{
|
||||
const clone = targetDoc.createElement('link');
|
||||
clone.rel = 'stylesheet';
|
||||
clone.href = link.href;
|
||||
if (link.media) clone.media = link.media;
|
||||
if (link.crossOrigin) clone.crossOrigin = link.crossOrigin;
|
||||
if (link.referrerPolicy) clone.referrerPolicy = link.referrerPolicy;
|
||||
targetDoc.head.appendChild(clone);
|
||||
});
|
||||
} catch {}
|
||||
try {
|
||||
document.querySelectorAll('style').forEach((style)=>{
|
||||
const clone = targetDoc.createElement('style');
|
||||
clone.textContent = style.textContent;
|
||||
targetDoc.head.appendChild(clone);
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
async function open() {
|
||||
if (!dpipOK && options.fallbackToVideoPiP) {
|
||||
art.pip = true;
|
||||
console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture');
|
||||
return;
|
||||
}
|
||||
if (state.win) return;
|
||||
try {
|
||||
const pipWin = await window.documentPictureInPicture.requestWindow({
|
||||
@@ -223,17 +244,19 @@ function artplayerPluginPip(userOptions = {}) {
|
||||
root.appendChild(adopted);
|
||||
state.currentDoc = pipWin.document;
|
||||
const onResize = ()=>art.resize?.();
|
||||
const onPageHide = ()=>close();
|
||||
const onClose = ()=>close();
|
||||
pipWin.addEventListener('resize', onResize);
|
||||
pipWin.addEventListener('pagehide', onPageHide);
|
||||
pipWin.addEventListener('pagehide', onClose);
|
||||
pipWin.addEventListener('unload', onClose);
|
||||
state.cleanup = ()=>{
|
||||
pipWin.removeEventListener('resize', onResize);
|
||||
pipWin.removeEventListener('pagehide', onPageHide);
|
||||
pipWin.removeEventListener('pagehide', onClose);
|
||||
pipWin.removeEventListener('unload', onClose);
|
||||
};
|
||||
art.emit('document-pip', true);
|
||||
} catch (err) {
|
||||
art.notice.show = 'Document Picture-in-Picture open failed';
|
||||
console.warn('[artplayer-plugin-pip] open failed:', err);
|
||||
console.warn('[artplayer-plugin-document-pip] open failed:', err);
|
||||
}
|
||||
}
|
||||
function restoreToOriginalDocument() {
|
||||
@@ -246,6 +269,10 @@ function artplayerPluginPip(userOptions = {}) {
|
||||
state.currentDoc = backDoc;
|
||||
}
|
||||
function close() {
|
||||
if (!dpipOK && options.fallbackToVideoPiP) {
|
||||
art.pip = false;
|
||||
return;
|
||||
}
|
||||
if (!state.win) return;
|
||||
try {
|
||||
state.cleanup?.();
|
||||
@@ -255,7 +282,7 @@ function artplayerPluginPip(userOptions = {}) {
|
||||
art.emit('document-pip', false);
|
||||
} catch (err) {
|
||||
art.notice.show = 'Document Picture-in-Picture close failed';
|
||||
console.warn('[artplayer-plugin-pip] close failed:', err);
|
||||
console.warn('[artplayer-plugin-document-pip] close failed:', err);
|
||||
}
|
||||
}
|
||||
function toggle() {
|
||||
@@ -277,14 +304,14 @@ function artplayerPluginPip(userOptions = {}) {
|
||||
});
|
||||
art.on('destroy', close);
|
||||
return {
|
||||
name: 'artplayerPluginPip',
|
||||
name: 'artplayerPluginDocumentPip',
|
||||
open,
|
||||
close,
|
||||
toggle
|
||||
};
|
||||
};
|
||||
}
|
||||
if (typeof window !== 'undefined') window.artplayerPluginPip = artplayerPluginPip;
|
||||
if (typeof window !== 'undefined') window.artplayerPluginDocumentPip = artplayerPluginDocumentPip;
|
||||
|
||||
},{"@parcel/transformer-js/src/esmodule-helpers.js":"8oCsH"}],"8oCsH":[function(require,module,exports,__globalThis) {
|
||||
exports.interopDefault = function(a) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAAwB;AAAT,SAAS,mBAAmB,cAAc,CAAC,CAAC;IACzD,MAAM,UAAU;QACd,OAAO;QACP,QAAQ;QACR,aAAa,CAAC,sCAAsC,CAAC;QACrD,GAAG,WAAW;IAChB;IAEA,OAAO,CAAC;QACN,IAAI,CAAE,CAAA,8BAA8B,MAAK,GAAI;YAC3C,IAAI,MAAM,CAAC,IAAI,GAAG;YAClB;QACF;QAEA,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG;QAEtG,MAAM,QAAQ;YACZ,KAAK;YACL,gBAAgB;YAChB,cAAc;YACd,YAAY;YACZ,aAAa;QACf;QAEA,SAAS,aAAa,SAAS;YAC7B,MAAM,YAAY,CAAC;;;;QAIjB,CAAC;YAEH,MAAM,SAAS,SAAS,aAAa,CAAC;YACtC,MAAM,QAAQ,UAAU,aAAa,CAAC;YACtC,MAAM,WAAW,GAAG,YAAY,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AAC;IAClC,OAAO,KAAK,EAAE,UAAU,GAAG,IAAI;QAAC,SAAS;IAAC;AAC5C;AAEA,QAAQ,iBAAiB,GAAG,SAAU,CAAC;IACrC,OAAO,cAAc,CAAC,GAAG,cAAc;QAAC,OAAO;IAAI;AACrD;AAEA,QAAQ,SAAS,GAAG,SAAU,MAAM,EAAE,IAAI;IACxC,OAAO,IAAI,CAAC,QAAQ,OAAO,CAAC,SAAU,GAAG;QACvC,IACE,QAAQ,aACR,QAAQ,gBACR,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,MAE3C;QAGF,OAAO,cAAc,CAAC,MAAM,KAAK;YAC/B,YAAY;YACZ,KAAK;gBACH,OAAO,MAAM,CAAC,IAAI;YACpB;QACF;IACF;IAEA,OAAO;AACT;AAEA,QAAQ,MAAM,GAAG,SAAU,IAAI,EAAE,QAAQ,EAAE,GAAG;IAC5C,OAAO,cAAc,CAAC,MAAM,UAAU;QACpC,YAAY;QACZ,KAAK;IACP;AACF","sources":["packages/artplayer-plugin-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["export default function artplayerPluginPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n if (!('documentPictureInPicture' in window)) {\n art.notice.show = 'Document Picture-in-Picture is not supported'\n return\n }\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const baseStyle = `\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 `\n\n const $style = document.querySelector('#artplayer-style')\n const clone = targetDoc.createElement('style')\n clone.textContent = baseStyle + $style.textContent\n targetDoc.head.appendChild(clone)\n\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n async function open() {\n if (state.win)\n return\n\n try {\n consLine truncated
|
||||
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAAwB;AAAT,SAAS,mBAAmB,cAAc,CAAC,CAAC;IACzD,MAAM,UAAU;QACd,OAAO;QACP,QAAQ;QACR,oBAAoB;QACpB,aAAa,CAAC,sCAAsC,CAAC;QACrD,GAAG,WAAW;IAChB;IAEA,OAAO,CAAC;QACN,MAAM,SAAS,8BAA8B,UACxC,OAAO,OAAO,wBAAwB,EAAE,kBAAkB;QAE/D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG;QAEtG,MAAM,QAAQ;YACZ,KAAK;YACL,gBAAgB;YAChB,cAAc;YACd,YAAY;YACZ,aAAa;QACf;QAEA,SAAS,aAAa,SAAS;YAC7B,MAAM,OAAO,UAAU,aAAa,CAAC;YACrC,KAAK,WAAW,GAAG,CAAC;;;;MAIpB,CAAC;YACD,UAAU,IAAI,CAAC,WAAW,CAAC;YAC3B,IAAI,CAAC,UAAU,aAAa,CAAC,0BAA0B;gBACrD,MAAM,OAAO,UAAU,aAAa,CAAC;gBACrC,KAAK,IAAI,GAAG;gBACZ,KAAK,OAAO,GAAG;gBACf,UAAU,IAAI,CAAC,WAAW,CAAC;YAC7B;YAEA,IAAI;gBACF,SAAS,gBAAgB,CAAC,0BAA0B,OAAO,CAAC,CAAC;oBAC3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QACpC,YAAY;QACZ,KAAK;IACP;AACF","sources":["packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const dpipOK = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('sLine truncated
|
||||
Reference in new issue
Block a user