Skip to content

Set PIP support based on the Picture in Picture API #2849

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions src/js/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,8 @@ const support = {
},

// Picture-in-picture support
// Safari & Chrome only currently
pip: (() => {
// While iPhone's support picture-in-picture for some apps, seemingly Safari isn't one of them
// It will throw the following error when trying to enter picture-in-picture
// `NotSupportedError: The Picture-in-Picture mode is not supported.`
if (browser.isIPhone) {
return false;
}

// Safari
// https://developer.apple.com/documentation/webkitjs/adding_picture_in_picture_to_your_safari_media_controls
if (is.function(createElement('video').webkitSetPresentationMode)) {
return true;
}

// Chrome
// https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture
if (document.pictureInPictureEnabled && !createElement('video').disablePictureInPicture) {
return true;
}

return false;
return (document.pictureInPictureEnabled && !createElement('video').disablePictureInPicture);
})(),

// Airplay support
Expand Down