我有一个用于视频和音频文件的 PIP 代码......我只是想知道有没有办法在 PIP 模式下打开 HTML 内容(如卡片/图片)这是我的视频文件 PIP......
const video = document.getElementById('myVideo');
const togglePipButton = document.getElementById('togglePipButton');
// Hide button if Picture-in-Picture is not supported or disabled.
togglePipButton.hidden = !document.pictureInPictureEnabled ||
video.disablePictureInPicture;
togglePipButton.addEventListener('click', function() {
// If there is no element in Picture-in-Picture yet, let’s request
// Picture-in-Picture for the video, otherwise leave it.
if (!document.pictureInPictureElement) {
video.requestPictureInPicture()
.catch(error => {
// Video failed to enter Picture-in-Picture mode.
});
} else {
document.exitPictureInPicture()
.catch(error => {
// Video failed to leave Picture-in-Picture mode.
});
}
});
<video id="myVideo" controls="" playsinline="" src="https://storage.googleapis.com/media-session/caminandes/short.mp4" poster="https://storage.googleapis.com/media-session/caminandes/artwork-512.png"></video>
<button id="togglePipButton">tyui</button>
我遇到了如下......
<div class="content" id="myVideo"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/HTML5_logo_and_wordmark.svg/1200px-HTML5_logo_and_wordmark.svg.png" alt="Lights"></div>
<button id="togglePipButton">tyui</button>
使用相同的脚本
实际上,我需要帮助以 PIP 模式打开 HTML 内容,例如卡片/图片