{
+ const video = e.currentTarget.parentNode!.parentNode!.querySelector("video")!;
+ const videoClone = document.body.appendChild(video.cloneNode(true)) as HTMLVideoElement;
+
+ videoClone.loop = settings.store.loop;
+ videoClone.style.display = "none";
+ videoClone.onleavepictureinpicture = () => videoClone.remove();
+
+ function launchPiP() {
+ videoClone.currentTime = video.currentTime;
+ videoClone.requestPictureInPicture();
+ video.pause();
+ videoClone.play();
+ }
+
+ if (videoClone.readyState === 4 /* HAVE_ENOUGH_DATA */)
+ launchPiP();
+ else
+ videoClone.onloadedmetadata = launchPiP;
+ }}
+ >
+
+
+ )}
+