mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 05:41:20 -08:00
refactor: improve document Picture-in-Picture support checks and update type definitions
- Renamed variable `dpipOK` to `isSupported` for clarity in checking Document Picture-in-Picture support. - Updated the `open` function to use the new `isSupported` variable. - Removed redundant checks in the `close` function related to Document Picture-in-Picture support. - Added `isSupported` and `isActive` properties to the plugin's result interface in TypeScript definitions. - Cleaned up the code for better readability and maintainability.
This commit is contained in:
1 parent
a7d77f4f70
commit
657dd7e77c
13 files changed
+25
-38
No files matched your search
@@ -8,7 +8,7 @@ export default function artplayerPluginDocumentPip(userOptions = {}) {
|
||||
}
|
||||
|
||||
return (art) => {
|
||||
const dpipOK = 'documentPictureInPicture' in window
|
||||
const isSupported = 'documentPictureInPicture' in window
|
||||
&& typeof window.documentPictureInPicture?.requestWindow === 'function'
|
||||
|
||||
const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art
|
||||
@@ -63,7 +63,7 @@ export default function artplayerPluginDocumentPip(userOptions = {}) {
|
||||
}
|
||||
|
||||
async function open() {
|
||||
if (!dpipOK && options.fallbackToVideoPiP) {
|
||||
if (!isSupported && 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
|
||||
@@ -133,11 +133,6 @@ export default function artplayerPluginDocumentPip(userOptions = {}) {
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (!dpipOK && options.fallbackToVideoPiP) {
|
||||
art.pip = false
|
||||
return
|
||||
}
|
||||
|
||||
if (!state.win)
|
||||
return
|
||||
try {
|
||||
@@ -181,7 +176,8 @@ export default function artplayerPluginDocumentPip(userOptions = {}) {
|
||||
|
||||
return {
|
||||
name: 'artplayerPluginDocumentPip',
|
||||
state,
|
||||
get isSupported() { return isSupported },
|
||||
get isActive() { return !!state.win },
|
||||
open,
|
||||
close,
|
||||
toggle,
|
||||
|
||||
Reference in new issue
Block a user