@hyperstream/videoplayer 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -20551,17 +20551,29 @@ function usePipMonitor({
20551
20551
  const [isPictureInPicture, setIsPictureInPicture] = useState9(false);
20552
20552
  const [isSupported, setIsSupported] = useState9(false);
20553
20553
  const [canActivate, setCanActivate] = useState9(false);
20554
+ const [videoElement, setVideoElement] = useState9(null);
20554
20555
  const onEnterPipRef = useRef14(onEnterPip);
20555
20556
  const onLeavePipRef = useRef14(onLeavePip);
20556
20557
  onEnterPipRef.current = onEnterPip;
20557
20558
  onLeavePipRef.current = onLeavePip;
20558
20559
  useEffect13(() => {
20559
- const video = videoRef.current;
20560
- const supported = isPipSupported() && video && "requestPictureInPicture" in video;
20561
- setIsSupported(!!supported);
20560
+ setIsSupported(isPipSupported());
20561
+ }, []);
20562
+ useEffect13(() => {
20563
+ if (videoRef.current) {
20564
+ setVideoElement(videoRef.current);
20565
+ return;
20566
+ }
20567
+ const interval = setInterval(() => {
20568
+ if (videoRef.current) {
20569
+ setVideoElement(videoRef.current);
20570
+ clearInterval(interval);
20571
+ }
20572
+ }, 100);
20573
+ return () => clearInterval(interval);
20562
20574
  }, [videoRef]);
20563
20575
  useEffect13(() => {
20564
- const video = videoRef.current;
20576
+ const video = videoElement;
20565
20577
  if (!video || !isSupported || !enabled) return;
20566
20578
  const handleEnterPip = () => {
20567
20579
  var _a;
@@ -20579,9 +20591,9 @@ function usePipMonitor({
20579
20591
  video.removeEventListener("enterpictureinpicture", handleEnterPip);
20580
20592
  video.removeEventListener("leavepictureinpicture", handleLeavePip);
20581
20593
  };
20582
- }, [videoRef, isSupported, enabled]);
20594
+ }, [videoElement, isSupported, enabled]);
20583
20595
  useEffect13(() => {
20584
- const video = videoRef.current;
20596
+ const video = videoElement;
20585
20597
  if (!video || !isSupported) {
20586
20598
  setCanActivate(false);
20587
20599
  return;
@@ -20600,7 +20612,7 @@ function usePipMonitor({
20600
20612
  video.removeEventListener("loadeddata", updateCanActivate);
20601
20613
  video.removeEventListener("canplay", updateCanActivate);
20602
20614
  };
20603
- }, [videoRef, isSupported]);
20615
+ }, [videoElement, isSupported]);
20604
20616
  const enterPip = useCallback12(() => __async(null, null, function* () {
20605
20617
  const video = videoRef.current;
20606
20618
  if (!video || !canActivate) return;