HTMLVideoElement.requestPictureInPicture() - Web APIs 编辑
The HTMLVideoElement
method requestPictureInPicture()
issues an asynchronous request to display the video in picture-in-picture mode.
It's not guaranteed that the video will be put into picture-in-picture. If permission to enter that mode is granted, the returned Promise
will resolve and the video will receive a enterpictureinpicture
event to let it know that it's now in picture-in-picture.
Syntax
videoElement.requestPictureInPicture();
Return value
A Promise
that will resolve to a PictureInPictureWindow
object. that can be used to listen when a user will resize that floating window.
Examples
This example requests that the video enters Picture-in-Picture mode, and sets an event listener to handle the floating window resizing.
function enterPictureInPicture() {
videoElement.requestPictureInPicture()
.then(pictureInPictureWindow => {
pictureInPictureWindow.addEventListener("resize", () => onPipWindowResize(), false);
})
}
Specifications
Specification | Status | Comment |
---|---|---|
Picture-in-Picture API The definition of 'HTMLVideoElement.requestPictureInPicture()' in that specification. | Draft | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论