w3c / picture-in-picture

Picture-in-Picture (PiP)
https://w3c.github.io/picture-in-picture
Other
311 stars 42 forks source link

leavepictureinpicture event should be fired with the Picture-in-Picture window #188

Closed beaufortfrancois closed 4 years ago

beaufortfrancois commented 4 years ago

Ohh... um... ok... this seems like an odd API design choice here... why not fire an EnterPictureInPictureEvent with "leavepictureinpicture" (yes, it has "Enter" on the front, boo!) if the developer still needs to access pictureInPictureWindow? Otherwise, the API forces the developer to keep an unnecessary reference to a variable in the global or some outer scope?

Originally posted by @marcoscaceres in https://github.com/w3c/picture-in-picture/pull/149

beaufortfrancois commented 4 years ago

This seems like a good suggestion to me. What do you think @mounirlamouri @jernoble?

When the exit Picture-in-Picture algorithm is invoked, the user agent MUST run the following steps:

  1. If pictureInPictureElement is null, throw a InvalidStateError and abort these steps.
  2. Run the close window algorithm with the Picture-in-Picture window associated with pictureInPictureElement.
  3. Unset pictureInPictureElement.
  4. Queue a task to fire an event with the name leavepictureinpicture at the video with its bubbles attribute initialized to true.
  5. Queue a task to fire an event with the name leavepictureinpicture using PictureInPictureEvent at the video with its bubbles attribute initialized to true and its pictureInPictureWindow attribute initialized to "Picture-in-Picture window".
beaufortfrancois commented 4 years ago

For info, here's the potential spec change: https://github.com/w3c/picture-in-picture/pull/189

mounirlamouri commented 4 years ago

@jernoble any concern from Apple here?

jernoble commented 4 years ago

LGTM.