Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-CN]: Sync translation for Using the Document Picture-in-Picture API guide #25811

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 使用 Document Picture-in-Picture API
slug: Web/API/Document_Picture-in-Picture_API/Using
l10n:
sourceCommit: d0b23f3f26637aa405ee9ee0a0892fc6e9b742ef
sourceCommit: f7ddd45a6bd53eb7fc10dbacc07a3acb168c1352
---

{{SeeCompatTable}}{{DefaultAPISidebar("Document Picture-in-Picture API")}}{{securecontext_header}}
Expand Down Expand Up @@ -36,7 +36,7 @@ l10n:
</a>
</div>

<div id="controlbar">
<div id="control-bar">
<p class="no-picture-in-picture">
Document Picture-in-Picture API 不可用
</p>
Expand All @@ -59,7 +59,7 @@ if ("documentPictureInPicture" in window) {
togglePipButton.textContent = "切换画中画";
togglePipButton.addEventListener("click", togglePictureInPicture, false);

document.getElementById("controlbar").appendChild(togglePipButton);
document.getElementById("control-bar").appendChild(togglePipButton);
}
```

Expand Down Expand Up @@ -171,7 +171,7 @@ window.documentPictureInPicture.window.close();

在这里,我们恢复 DOM 更改——隐藏消息并将视频播放器放回主应用窗口中的播放器容器中。我们还使用 {{domxref("Window.close()")}} 方法以编程方式关闭画中画窗口。

但是,你还需要考虑用户通过按下窗口本身上浏览器提供的关闭(X)按钮来关闭画中画窗口的情况。你可以通过使用 [`pagehide`](/zh-CN/docs/Web/API/Window/pagehide_event) 事件检测窗口何时关闭来处理这种情况:
但是,你还需要考虑用户通过按下窗口本身上浏览器提供的 UI 关闭控件来关闭画中画窗口的情况。你可以通过使用 [`pagehide`](/zh-CN/docs/Web/API/Window/pagehide_event) 事件检测窗口何时关闭来处理这种情况:

```js
pipWindow.addEventListener("pagehide", (event) => {
Expand All @@ -180,6 +180,9 @@ pipWindow.addEventListener("pagehide", (event) => {
});
```

> [!NOTE]
> 在调用 `DocumentPictureInPicture.requestWindow()` 打开画中画窗口时,可以通过将选项对象中的 [`disallowReturnToOpener`](/zh-CN/docs/Web/API/DocumentPictureInPicture/requestWindow#disallowreturntoopener) 选项设置为 `true` 来隐藏浏览器提供的 UI 关闭控件。

## 监听网站何时进入画中画模式

监听 `DocumentPictureInPicture` 实例上的 {{domxref("DocumentPictureInPicture.enter_event", "enter")}} 事件,了解画中画窗口何时打开。
Expand Down