HTMLVideoElement: enterpictureinpicture event - Web APIs 编辑
The enterpictureinpicture
event is fired when the HTMLVideoElement
enters picture-in-picture mode successfully.
Bubbles | No |
---|---|
Cancelable | No |
Interface | PictureInPictureEvent |
Target | HTMLVideoElement |
Default Action | None |
Event handler property | HTMLVideoElement.onenterpictureinpicture |
Examples
These examples add an event listener for the HTMLVideoElement's enterpictureinpicture
event, then post a message when that event handler has reacted to the event firing.
Using addEventListener()
:
const video = document.querySelector('#video');
const button = document.querySelector('#button');
function onEnterPip() {
console.log("Picture-in-Picture mode activated!");
}
video.addEventListener('enterpictureinpicture', onEnterPip, false);
button.onclick = function() => {
video.requestPictureInPicture();
}
Using the onenterpictureinpicture
event handler property:
const video = document.querySelector('#video');
const button = document.querySelector('#button');
function onEnterPip() {
console.log("Picture-in-Picture mode activated!");
}
video.onenterpictureinpicture = onEnterPip;
button.onclick = function() => {
video.requestPictureInPicture();
}
Specifications
Specification | Status |
---|---|
Picture-in-Picture API The definition of 'enterpictureinpicture event' in that specification. | Draft |
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论