From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/pictureinpicturewindow/index.html | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 files/zh-cn/web/api/pictureinpicturewindow/index.html (limited to 'files/zh-cn/web/api/pictureinpicturewindow') diff --git a/files/zh-cn/web/api/pictureinpicturewindow/index.html b/files/zh-cn/web/api/pictureinpicturewindow/index.html new file mode 100644 index 0000000000..a67dcf8a15 --- /dev/null +++ b/files/zh-cn/web/api/pictureinpicturewindow/index.html @@ -0,0 +1,86 @@ +--- +title: PictureInPictureWindow +slug: Web/API/PictureInPictureWindow +translation_of: Web/API/PictureInPictureWindow +--- +
{{APIRef("Picture-in-Picture API")}}
+ +

PictureInPictureWindow接口是一个对象,它可以通过编程的方式获得浮动视频窗口的宽度和高度,并调整浮动视频窗口的大小。

+ +

使用{{domxref("HTMLVideoElement.requestPictureInPicture()")}}返回一个具有此接口的promise值

+ +

属性

+ +

 PictureInPictureWindow 接口不继承任何属性。

+ +
+
{{domxref("PictureInPictureWindow.width")}} {{ReadOnlyInline}}
+
获取浮动视频窗宽度。
+
{{domxref("PictureInPictureWindow.height")}} {{ReadOnlyInline}}
+
获取浮动视频窗高度。
+
+ +

Methods

+ +

The PictureInPictureWindow interface doesn't inherit any methods.

+ +

Events

+ +

The PictureInPictureWindow interface doesn't inherit any events.

+ +
+
{{domxref("PictureInPictureWindow.resize_event", "PictureInPictureWindow.resize")}}
+
Sent to a {{DOMxRef("PictureInPictureWindow")}} when the floating video window is resized. The associated event handler is {{domxref("PictureInPictureWindow.onresize")}}.
+
+ +

Examples

+ +

Given a <button> and a <video>, clicking the button will make the video enter the picture-in-picture mode; we then attach an event to print the floating video window dimensions to the console.

+ +
const button = document.querySelector("button");
+const video = document.querySelector("video");
+
+function printPipWindowDimensions(evt) {
+  const pipWindow = evt.target;
+  console.log(`The floating window dimensions are: ${pipWindow.width}x${pipWindow.height}px`);
+  // will print:
+  // The floating window dimensions are: 640x360px
+}
+
+button.onclick = function() {
+  video.requestPictureInPicture().then(pictureInPictureWindow => {
+    pictureInPictureWindow.onresize = printPipWindowDimensions;
+  });
+};
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Picture-in-Picture', '#pictureinpicturewindow')}}{{Spec2('Picture-in-Picture')}}Initial specification.
+ +

Browser compatibility

+ + + +

{{Compat("api.PictureInPictureWindow")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf