w3c / picture-in-picture

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

Provide a clear definition of autoPictureInPictureElement #115

Closed beaufortfrancois closed 1 year ago

beaufortfrancois commented 5 years ago

In https://github.com/WICG/picture-in-picture/pull/112/files#r249006604, it was agreed to provide a clear definiton of autoPictureInPictureElement.

beaufortfrancois commented 4 years ago

I think was set most recently would benefit from a clear definition. Happy to have this dealt with in a follow-up though.

@mounirlamouri How were you thinking about explaining "was set most recently" in the spec? For info, here's what we currently do in Chromium to track this.


void PictureInPictureControllerImpl::AddToAutoPictureInPictureElementsList(
    HTMLVideoElement* element) {
  RemoveFromAutoPictureInPictureElementsList(element);
  auto_picture_in_picture_elements_.push_back(element);
}

void PictureInPictureControllerImpl::RemoveFromAutoPictureInPictureElementsList(
    HTMLVideoElement* element) {
  DCHECK(element);
  auto it = std::find(auto_picture_in_picture_elements_.begin(),
                      auto_picture_in_picture_elements_.end(), element);
  if (it != auto_picture_in_picture_elements_.end())
    auto_picture_in_picture_elements_.erase(it);
}

HTMLVideoElement* PictureInPictureControllerImpl::AutoPictureInPictureElement()
    const {
  return auto_picture_in_picture_elements_.IsEmpty()
             ? nullptr
             : auto_picture_in_picture_elements_.back();
}
mounirlamouri commented 4 years ago

We could specify exactly what's above. The document has a list of auto-pip element. When an element is inserted to the document or has auto-pip added to it, it is pushed into that list. When removed from the document or the attribute is removed, it is removed from the list.

Then, the "most recently" becomes the top of the list.

beaufortfrancois commented 4 years ago

Thanks! Here's the PR: https://github.com/w3c/picture-in-picture/pull/190

beaufortfrancois commented 4 years ago

@jernoble Do you have plans to implement Auto Picture-in-Picture in Safari?

pliu6 commented 4 years ago

@beaufortfrancois We don't plan to implement it in Safari.

beaufortfrancois commented 1 year ago

Closing all v2 labels issues as this is replaced by the dedicated WICG Document Picture-in-Picture API proposal.