mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 02:21:20 -08:00
26 lines
960 B
TypeScript
26 lines
960 B
TypeScript
import type { PipHost, PipProperty } from '../display/types'
|
|
import { nativePip } from '../display/native-pip'
|
|
import { webkitPip } from '../display/webkit-pip'
|
|
import { isClosing } from '../lifecycle/instance'
|
|
import { def } from '../utils'
|
|
|
|
export default function pipMix(art: PipHost): asserts art is PipHost & PipProperty {
|
|
const { i18n, notice, template: { $video } } = art
|
|
const document = $video.ownerDocument
|
|
if (document.pictureInPictureEnabled && typeof $video.requestPictureInPicture === 'function' && typeof document.exitPictureInPicture === 'function') {
|
|
def(art, 'pip', nativePip(art))
|
|
}
|
|
else if (typeof $video.webkitSupportsPresentationMode === 'function' && typeof $video.webkitSetPresentationMode === 'function') {
|
|
def(art, 'pip', webkitPip(art))
|
|
}
|
|
else {
|
|
def(art, 'pip', {
|
|
get: () => false,
|
|
set() {
|
|
if (!isClosing(art))
|
|
notice.show = i18n.get('PIP Not Supported')
|
|
},
|
|
})
|
|
}
|
|
}
|