Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Picture-in-Picture API: Document Windows, Video Element, and Meeting Controls

How the Document and video Picture-in-Picture APIs work, browser limits, opening PiP windows, and enabling PiP in realtime meeting apps.

This page summarizes how web Picture-in-Picture (PiP) is documented on Chrome for Developers for arbitrary HTML in a floating window, and how Cloudflare Realtime Kit wires PiP for live meetings. People usually look this up when they want video or UI to stay visible while switching tabs or apps, or when PiP silently fails because the browser or platform does not support it.

Picture-in-Picture on the web usually means a small always-on-top window that keeps content visible outside the main tab. There are two related mechanisms:

API What goes in the PiP window Typical use
Picture-in-Picture API for <video> Only an HTML <video> element Built-in browser video PiP
Document Picture-in-Picture API Arbitrary HTML (same-origin document) Custom players, multi-stream calls, tools

The Document Picture-in-Picture API makes it possible to open an always-on-top window that can be populated with arbitrary HTML content. It extends the existing Picture-in-Picture API for <video> that only allows an HTML <video> element to be put into a Picture-in-Picture (PiP) window.

— Chrome for Developers, Picture-in-Picture for any Element, not just <video>

How a Document PiP window differs from window.open()

Section titled “How a Document PiP window differs from window.open()”

A Document PiP window behaves like a blank same-origin window opened with window.open(), but with fixed rules:

The Picture-in-Picture window floats on top of other windows. The Picture-in-Picture window never outlives the opening window. The Picture-in-Picture window cannot be navigated. The Picture-in-Picture window position cannot be set by the website.

— Chrome for Developers, Picture-in-Picture for any Element, not just <video>

That last point matters for UX: you can suggest size via options, but not pin exact screen coordinates.

Document Picture-in-Picture: browser support and feature detection

Section titled “Document Picture-in-Picture: browser support and feature detection”

Before calling any PiP API, detect support. For Document PiP, Chrome documents:

if ('documentPictureInPicture' in window) {
// The Document Picture-in-Picture API is supported.
}

Cluster browser notes for Document PiP list Chrome 116+, Edge 116+, Firefox 151+, and Safari as not supported on the Document Picture-in-Picture page.

For meeting video via Cloudflare, support is narrower and must be checked at runtime:

Picture-in-Picture API might not be supported in your browser. Always check for support before using the API.

— Cloudflare, Picture in Picture

const isSupported = meeting.participants.pip.isSupported();

A website can provide a Picture-in-Picture video experience with the existing Picture-in-Picture API for <video>, however it is very limited. The existing PiP window accepts few inputs, and has limited ability for styling them. With a full Document in Picture-in-Picture, the website can provide custom controls and inputs (for example, captions, playlists, time scrubber, liking and disliking videos) to improve the user’s PiP video experience.

— Chrome for Developers, Picture-in-Picture for any Element, not just <video>

Users often, temporarily leave the browser tab during a video conferencing session, such as when presenting from another tab to the call, taking notes, or other multi-tasking activities. However, in most cases, the user still wants to see the call, thus this is an ideal use case for Picture-in-Picture. Once again, the current experience a video conferencing website can provide with the Picture-in-Picture API for <video> is limited in style and input. With a full Document in Picture-in-Picture, the website can easily combine multiple video streams into a single PiP window, without relying on canvas hacks, and provide custom controls, such as sending a message, muting another user, or raising a hand.

— Chrome for Developers, Picture-in-Picture for any Element, not just <video>

Cloudflare’s meeting integration follows the same user goal with less custom code: the Picture in Picture guide exposes active participant video as a floating tile outside the page. UI kits ship a toggle—for example rtk-pip-toggle (core), Angular, and React RtkPipToggle—described as “a button to turn Picture-in-Picture mode on or off when available.”

Research has shown that users need more ways to be productive on the web. Document in Picture-in-Picture gives web apps the flexibility to accomplish more. Whether it’s text editing, note-taking, task lists, messaging and chat, or design and development tools, web apps can now keep their content always accessible.

— Chrome for Developers, Picture-in-Picture for any Element, not just <video>

documentPictureInPicture.requestWindow(): open, size, and options

Section titled “documentPictureInPicture.requestWindow(): open, size, and options”

documentPictureInPicture.requestWindow(options) returns a promise that resolves when a PiP window opens. Chrome documents that the promise rejects if it is called without a user gesture—typical pattern: a button click handler.

The options dictionary can include:

Option Purpose
width, height Initial window size (browser may clamp unreasonable values)
disallowReturnToOpener If true, hides the “back to tab” control (Chrome 124+)
preferInitialWindowPlacement If true, default position/size instead of reusing last PiP placement (Chrome 130+)

documentPictureInPicture.window returns the current PiP window or null. An enter event on documentPictureInPicture fires when a window opens; the event carries event.window.

Minimal open-and-move pattern from Chrome’s docs:

pipButton.addEventListener('click', async () => {
const player = document.querySelector("#player");
const pipWindow = await documentPictureInPicture.requestWindow();
pipWindow.document.body.append(player);
});

See Open a Picture-in-Picture window on Chrome for Developers for sizing, stylesheet copy, and close handling.

Styling, resize, focus, and closing the PiP window

Section titled “Styling, resize, focus, and closing the PiP window”

The PiP document starts empty. To match the opener’s look, loop document.styleSheets and copy rules or <link rel="stylesheet"> into pipWindow.document.head (one-time copy). Chrome notes that an older copyStyleSheets option is no longer in the specification—manual copying is the documented approach. Details: Copy style sheets to PiP.

From Chrome 123+, target PiP-only layout:

@media all and (display-mode: picture-in-picture) {
body { margin: 0; }
}
  • pipWindow.resizeBy() / resizeTo() require a user gesture (Chrome 121+).
  • window.focus() from the PiP window to return attention to the opener tab requires a user gesture (Chrome 123+). This aligns with allowed “focusing the app window” when a user-initiated background task completes, as listed under allowed behaviors in Chrome IWA developer policy.

Listen for pagehide on the PiP window to move nodes back to the opener when the user or site closes PiP. Call pipWindow.close() to close programmatically; pagehide still fires.

Cloudflare Realtime Kit: enable and disable meeting PiP

Section titled “Cloudflare Realtime Kit: enable and disable meeting PiP”

For hosted meetings, Cloudflare wraps platform PiP on meeting.participants.pip:

await meeting.participants.pip.enable();
await meeting.participants.pip.disable();

See Picture in Picture and the RTKPip API reference (meeting.participants.pip.enable()). The PiP surface shows an active remote participant’s video as a floating tile—useful when the participant keeps the call visible while using another app, matching the toggle descriptions in the ui-kit PiP components.

Picture-in-Picture API allows you to render meeting.participants.active participant’s video as a floating tile outside of the current webpage’s context.

— Cloudflare, Picture in Picture

  • Calling requestWindow() without a click or tap — the promise rejects; always tie PiP to explicit user action.
  • Assuming Safari or all platforms work — Document PiP and Cloudflare meeting PiP have documented gaps; use feature detection and isSupported() before showing controls.
  • Forgetting to restore UI on close — moving DOM nodes into PiP without a pagehide handler leaves the main page broken.
  • Expecting to set window position — sites cannot set PiP screen position; only size hints and browser defaults apply.
  • Relying on removed copyStyleSheets — use the manual stylesheet loop from Chrome’s documentation.
  • Resize or focus without gesture — resizeBy, resizeTo, and opener focus() from PiP need user activation where Chrome specifies.
  1. In the target browser, run Document PiP feature detection ('documentPictureInPicture' in window) or, for Realtime Kit, log meeting.participants.pip.isSupported() per Picture in Picture.

  2. Open your app in a supported Chromium browser (and Edge if applicable), trigger PiP from a real user click, and confirm a floating window appears and survives tab switches.

  3. Close PiP manually and via pipWindow.close() (Document PiP) or disable() (Realtime Kit); confirm elements return to the main page and media state is correct.

  4. On unsupported browsers, confirm PiP controls are hidden or disabled and the app still works without PiP.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.