Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Only play one video in PiP at once. #181

Merged
merged 3 commits into from
Feb 1, 2022
Merged

Conversation

dero
Copy link
Collaborator

@dero dero commented Jan 31, 2022

Summary

When initializing the PiP experience, make sure no other video is playing. If it is, exit that PiP experience first and pause the previously playing video before opening a new PiP window.

Fixes #106 #178

// If another video is already in PiP, pause it and exit PiP mode.
if (document.pictureInPictureElement instanceof VideoPlayer) {
document.pictureInPictureElement.videoElement.pause();
await document.exitPictureInPicture();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe await document.exitPictureInPicture(); is not necessary as document.pictureInPictureElement will exit Picture-in-Picture.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beaufortfrancois You're right, thank you. Updated in 599d9ab.

Copy link
Member

@beaufortfrancois beaufortfrancois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit

src/js/web-components/video-player/VideoPlayer.js Outdated Show resolved Hide resolved
@derekherman derekherman merged commit 14d0740 into develop Feb 1, 2022
@derekherman derekherman deleted the fix/ghost-pip-bug branch February 1, 2022 07:27
@felipebochehin87
Copy link

LGTM. PiP displays one video at a time, and if a second video start on PiP, the first one stops.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offline Mode: picture-in-picture behavior allows multiple videos to play at the same time
4 participants