DocumentPictureInPicture:窗口属性
window
是 DocumentPictureInPicture
接口的只读属性,它返回一个表示画中画窗口内浏览上下文的 Window
实例。
值
如果画中画窗口已使用 DocumentPictureInPicture.requestWindow()
打开,则返回一个 Window
对象实例,否则返回 null
。
示例
js
const videoPlayer = document.getElementById("player");
// ...
await window.documentPictureInPicture.requestWindow({
width: videoPlayer.clientWidth,
height: videoPlayer.clientHeight,
});
// ...
const pipWindow = window.documentPictureInPicture.window;
if (pipWindow) {
// Mute video playing in the Picture-in-Picture window.
const pipVideo = pipWindow.document.querySelector("#video");
pipVideo.muted = true;
}
规范
规范 |
---|
Document Picture-in-Picture # dom-documentpictureinpicture-window |
浏览器兼容性
BCD 表格仅在启用了 JavaScript 的浏览器中加载。