Closed jeremysjones closed 6 years ago
Thanks @jeremysjones for raising this issue.
Instead of adding a pictureInPictureWindow
property to the HTMLVideoElement
or document
, how about adding it as part of the enterpictureinpicture
event.
[
Constructor(DOMString type, EnterPictureInPictureEventInit eventInitDict)
]
interface EnterPictureInPictureEvent : Event {
attribute PictureInPictureWindow pictureInPictureWindow;
};
This would allow web developers to do something like this:
video.addEventListener('enterpictureinpicture', function(event) {
const pipWindow = event.pictureInPictureWindow;
// TODO: Update video size based on `pipWindow.width` and `pipWindow.height`;
});
@jeremysjones WDYT of @beaufortfrancois proposal? I think it's cleaner and would avoid footguns with some components of the page reading the state of the PIP window and changing behaviour when it's actually the PIP window of another video.
@mounirlamouri @beaufortfrancois I agree. Adding it to the event is an even better solution.
FYI I've just opened a PR to add pictureInPictureWindow
to the enterpictureinpicture
event at https://github.com/WICG/picture-in-picture/pull/84
When the user agent initiates picture in picture there is no way for the page to get access to the PictureInPictureWindow.
Normally the page would gain access to the PictureInPictureWindow when calling requestPictureInPicture().
Mobile Safari initiates picture-in-picture when app is suspended while playing fullscreen video or the user can press the picture-in-picture button on the video fullscreen window. In these cases, the page will still need access to the PictureInPictureWindow in order to respond to window size changes.
Proposed solutions: Add a pictureInPictureWindow property to the element or document.