-
Notifications
You must be signed in to change notification settings - Fork 8.1k
/
index.md
66 lines (41 loc) · 2.13 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: DocumentPictureInPicture
slug: Web/API/DocumentPictureInPicture
l10n:
sourceCommit: 26aaa0b6f92933d915563b1d1210cc46f4ec0e09
---
{{APIRef("Document Picture-in-Picture API")}}{{SeeCompatTable}}{{securecontext_header}}
{{domxref("Document Picture-in-Picture API", "Document Picture-in-Picture API", "", "nocode")}} 的 **`DocumentPictureInPicture`** 接口是创建和处理文档画中画窗口的入口点。
它是通过 {{domxref("Window.documentPictureInPicture")}} 属性访问的。
{{InheritanceDiagram}}
## 实例属性
_从其父接口 {{DOMxRef("EventTarget")}} 继承属性。_
- {{domxref("DocumentPictureInPicture.window", "window")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : 返回一个 {{domxref("Window")}} 实例,代表画中画窗口内的浏览上下文。
## 实例方法
_从其父接口 {{DOMxRef("EventTarget")}} 继承方法。_
- {{domxref("DocumentPictureInPicture.requestWindow", "requestWindow()")}} {{Experimental_Inline}}
- : 为当前主浏览环境打开画中画窗口。返回一个 {{jsxref("Promise")}},其兑现一个 {{domxref("Window")}} 实例,代表画中画窗口内的浏览环境。
## 事件
_从其父接口 {{DOMxRef("EventTarget")}} 继承事件。_
- {{domxref("DocumentPictureInPicture/enter_event", "enter")}} {{Experimental_Inline}}
- : 当画中画窗口成功打开时触发。
## 示例
```js
const videoPlayer = document.getElementById("player");
// ...
// 打开画中画窗口。
const pipWindow = await window.documentPictureInPicture.requestWindow({
width: videoPlayer.clientWidth,
height: videoPlayer.clientHeight,
});
// ...
```
请参阅 [Document Picture-in-Picture API 示例](https://mdn.github.io/dom-examples/document-picture-in-picture/)获取完整的可运行演示(另请参阅完整的[源代码](https://github.com/mdn/dom-examples/tree/main/document-picture-in-picture))。
## 规范
{{Specifications}}
## 浏览器兼容性
{{Compat}}
## 参见
- {{domxref("Document Picture-in-Picture API", "Document Picture-in-Picture API", "", "nocode")}}
- [使用 Document Picture-in-Picture API](/zh-CN/docs/Web/API/Document_Picture-in-Picture_API/Using)