fix: avoid actively closing PiP mode
This commit is contained in:
parent
f7087517e4
commit
92fe2524e5
1 changed files with 2 additions and 15 deletions
|
|
@ -25,24 +25,11 @@ export default function VideoPlayer({
|
||||||
|
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
async ([entry]) => {
|
async ([entry]) => {
|
||||||
const isVisible = entry.isIntersecting
|
if (!entry.isIntersecting && !video.paused) {
|
||||||
|
|
||||||
if (!isVisible && !video.paused) {
|
|
||||||
await videoManager.enterPiP(video)
|
await videoManager.enterPiP(video)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVisible) {
|
|
||||||
if (
|
|
||||||
document.pictureInPictureElement === video ||
|
|
||||||
(video as any).webkitPresentationMode === 'picture-in-picture'
|
|
||||||
) {
|
|
||||||
await videoManager.exitPiP(video)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{ threshold: 0.5 }
|
||||||
threshold: 0.5
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
observer.observe(container)
|
observer.observe(container)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue