Skip to content
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

Feature Request: Use Document Picture-in-Picture Web API #4964

Closed
beaufortfrancois opened this issue Feb 3, 2023 · 3 comments · Fixed by #4969
Closed

Feature Request: Use Document Picture-in-Picture Web API #4964

beaufortfrancois opened this issue Feb 3, 2023 · 3 comments · Fixed by #4969
Assignees
Labels
component: UI The issue involves the Shaka Player UI priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@beaufortfrancois
Copy link
Contributor

Users should be able to use the Shaka Player in a Picture-in-Picture window, not just the HTML video inside the web player.

image

Before the Document Picture-in-Picture API, it was only possible to put an HTML <video> element into a Picture-in-Picture window. This new API makes it possible to open an always-on-top window that can be populated with arbitrary HTML content. It is available as an origin trial starting in Chrome 111 on desktop.

async function togglePictureInPicture() {
  // Close Picture-in-Picture window if any.
  if (documentPictureInPicture.window) {
    documentPictureInPicture.window.close();
    return;
  }

  // Open a Picture-in-Picture window.
  const pipWindow = await documentPictureInPicture.requestWindow({
    initialAspectRatio: 640 / 360,
    copyStyleSheets: true,
  });

  // Move video to the Picture-in-Picture window.
  const video = document.querySelector("#video");
  pipWindow.document.body.append(video);

  // Listen for the PiP closing event to move the video back.
  pipWindow.addEventListener("unload", (event) => {
    const videoContainer = document.querySelector("#videoContainer");
    const pipVideo = event.target.querySelector("#video");
    videoContainer.append(pipVideo);
  });
}

Documentation:

@beaufortfrancois beaufortfrancois added the type: enhancement New feature or request label Feb 3, 2023
@avelad
Copy link
Collaborator

avelad commented Feb 3, 2023

@beaufortfrancois are you interested on send a PR for this?

@avelad avelad added component: UI The issue involves the Shaka Player UI priority: P3 Useful but not urgent labels Feb 3, 2023
@avelad avelad added this to the Backlog milestone Feb 3, 2023
@beaufortfrancois
Copy link
Contributor Author

Sure. I've opened #4969 ;)

@avelad
Copy link
Collaborator

avelad commented Feb 6, 2023

joeyparrish added a commit that referenced this issue Feb 10, 2023
This PR adds _experimental_ support for the Document Picture-in-Picture
API in the Shaka Player.

Closes #4964

Co-authored-by: Alvaro Velad Galvan <ladvan91@hotmail.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Apr 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2023
@avelad avelad modified the milestones: Backlog, v4.4 Apr 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: UI The issue involves the Shaka Player UI priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
2 participants