DocumentPictureInPicture:window 属性
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
DocumentPictureInPicture 接口的 window 只读属性返回一个 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) {
// 使画中画窗口中播放的视频静音。
const pipVideo = pipWindow.document.querySelector("#video");
pipVideo.muted = true;
}
规范
| Specification |
|---|
| Document Picture-in-Picture Specification> # dom-documentpictureinpicture-window> |
浏览器兼容性
Loading…