@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.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20560,17 +20560,29 @@ function usePipMonitor({
|
|
|
20560
20560
|
const [isPictureInPicture, setIsPictureInPicture] = (0, import_react40.useState)(false);
|
|
20561
20561
|
const [isSupported, setIsSupported] = (0, import_react40.useState)(false);
|
|
20562
20562
|
const [canActivate, setCanActivate] = (0, import_react40.useState)(false);
|
|
20563
|
+
const [videoElement, setVideoElement] = (0, import_react40.useState)(null);
|
|
20563
20564
|
const onEnterPipRef = (0, import_react40.useRef)(onEnterPip);
|
|
20564
20565
|
const onLeavePipRef = (0, import_react40.useRef)(onLeavePip);
|
|
20565
20566
|
onEnterPipRef.current = onEnterPip;
|
|
20566
20567
|
onLeavePipRef.current = onLeavePip;
|
|
20567
20568
|
(0, import_react40.useEffect)(() => {
|
|
20568
|
-
|
|
20569
|
-
|
|
20570
|
-
|
|
20569
|
+
setIsSupported(isPipSupported());
|
|
20570
|
+
}, []);
|
|
20571
|
+
(0, import_react40.useEffect)(() => {
|
|
20572
|
+
if (videoRef.current) {
|
|
20573
|
+
setVideoElement(videoRef.current);
|
|
20574
|
+
return;
|
|
20575
|
+
}
|
|
20576
|
+
const interval = setInterval(() => {
|
|
20577
|
+
if (videoRef.current) {
|
|
20578
|
+
setVideoElement(videoRef.current);
|
|
20579
|
+
clearInterval(interval);
|
|
20580
|
+
}
|
|
20581
|
+
}, 100);
|
|
20582
|
+
return () => clearInterval(interval);
|
|
20571
20583
|
}, [videoRef]);
|
|
20572
20584
|
(0, import_react40.useEffect)(() => {
|
|
20573
|
-
const video =
|
|
20585
|
+
const video = videoElement;
|
|
20574
20586
|
if (!video || !isSupported || !enabled) return;
|
|
20575
20587
|
const handleEnterPip = () => {
|
|
20576
20588
|
var _a;
|
|
@@ -20588,9 +20600,9 @@ function usePipMonitor({
|
|
|
20588
20600
|
video.removeEventListener("enterpictureinpicture", handleEnterPip);
|
|
20589
20601
|
video.removeEventListener("leavepictureinpicture", handleLeavePip);
|
|
20590
20602
|
};
|
|
20591
|
-
}, [
|
|
20603
|
+
}, [videoElement, isSupported, enabled]);
|
|
20592
20604
|
(0, import_react40.useEffect)(() => {
|
|
20593
|
-
const video =
|
|
20605
|
+
const video = videoElement;
|
|
20594
20606
|
if (!video || !isSupported) {
|
|
20595
20607
|
setCanActivate(false);
|
|
20596
20608
|
return;
|
|
@@ -20609,7 +20621,7 @@ function usePipMonitor({
|
|
|
20609
20621
|
video.removeEventListener("loadeddata", updateCanActivate);
|
|
20610
20622
|
video.removeEventListener("canplay", updateCanActivate);
|
|
20611
20623
|
};
|
|
20612
|
-
}, [
|
|
20624
|
+
}, [videoElement, isSupported]);
|
|
20613
20625
|
const enterPip = (0, import_react40.useCallback)(() => __async(null, null, function* () {
|
|
20614
20626
|
const video = videoRef.current;
|
|
20615
20627
|
if (!video || !canActivate) return;
|