此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。
DocumentPictureInPictureEvent
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
DocumentPictureInPictureEvent 接口是Document Picture-in-Picture API 的enter 事件(会在画中画窗口打开时触发)的对象。
In this article
构造函数
DocumentPictureInPictureEvent()实验性创建一个新的
DocumentPictureInPictureEvent对象实例。
实例属性
继承其父接口Event 的属性。
实例方法
继承其父接口Event 的方法。
示例
js
documentPictureInPicture.addEventListener("enter", (event) => { const pipWindow = event.window; console.log("视频播放器已进入画中画窗口"); const pipMuteButton = pipWindow.document.createElement("button"); pipMuteButton.textContent = "静音"; pipMuteButton.addEventListener("click", () => { const pipVideo = pipWindow.document.querySelector("#video"); if (!pipVideo.muted) { pipVideo.muted = true; pipMuteButton.textContent = "取消静音"; } else { pipVideo.muted = false; pipMuteButton.textContent = "静音"; } }); pipWindow.document.body.append(pipMuteButton);});规范
| Specification |
|---|
| Document Picture-in-Picture Specification> # documentpictureinpictureevent> |