@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260521115630 → 0.8.1-dev.20260522043844
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/{HlsPlayer-4VB65GYW.mjs → HlsPlayer-GZR4QXJY.mjs} +1 -1
- package/dist/{chunk-JGRYFWF6.mjs → chunk-72PHGKW4.mjs} +34 -11
- package/dist/index.js +1112 -1061
- package/dist/index.mjs +579 -551
- package/package.json +1 -1
|
@@ -53,6 +53,7 @@ var HlsPlayer = React.memo(
|
|
|
53
53
|
const wasManuallyPausedRef = useRef(false);
|
|
54
54
|
const inactivityTimerRef = useRef(null);
|
|
55
55
|
const clickTimerRef = useRef(null);
|
|
56
|
+
const hlsInitializedRef = useRef(false);
|
|
56
57
|
const INACTIVITY_DELAY = 2500;
|
|
57
58
|
const CLICK_DEBOUNCE = 220;
|
|
58
59
|
const resolvedSources = sources && sources.length > 0 ? sources : assetUrl ? [{ src: assetUrl, posterUrl }] : [];
|
|
@@ -110,7 +111,7 @@ var HlsPlayer = React.memo(
|
|
|
110
111
|
if (clickTimerRef.current) clearTimeout(clickTimerRef.current);
|
|
111
112
|
};
|
|
112
113
|
}, []);
|
|
113
|
-
|
|
114
|
+
const initHls = useCallback((autoPlayAfterLoad) => {
|
|
114
115
|
const v = videoRef.current;
|
|
115
116
|
if (!v || resolvedSources.length === 0) return;
|
|
116
117
|
if (hlsRef.current) {
|
|
@@ -119,25 +120,39 @@ var HlsPlayer = React.memo(
|
|
|
119
120
|
}
|
|
120
121
|
const chosenSrc = pickSource(resolvedSources);
|
|
121
122
|
if (!chosenSrc) return;
|
|
123
|
+
hlsInitializedRef.current = true;
|
|
122
124
|
if (Hls.isSupported()) {
|
|
123
125
|
const hls = new Hls();
|
|
124
126
|
hls.loadSource(chosenSrc);
|
|
125
127
|
hls.attachMedia(v);
|
|
126
128
|
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
|
127
|
-
if (
|
|
128
|
-
v.play().catch(console.error);
|
|
129
|
+
if (autoPlayAfterLoad && !wasManuallyPausedRef.current) {
|
|
130
|
+
v.play().catch(console.error).then(() => setIsPlaying(true));
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
hlsRef.current = hls;
|
|
132
|
-
return () => {
|
|
133
|
-
hls.destroy();
|
|
134
|
-
hlsRef.current = null;
|
|
135
|
-
};
|
|
136
134
|
} else if (v.canPlayType("application/vnd.apple.mpegurl")) {
|
|
137
135
|
v.src = chosenSrc;
|
|
138
136
|
v.load();
|
|
137
|
+
if (autoPlayAfterLoad) {
|
|
138
|
+
v.play().catch(console.error).then(() => setIsPlaying(true));
|
|
139
|
+
}
|
|
139
140
|
}
|
|
140
141
|
}, [JSON.stringify(resolvedSources)]);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (isPlayOnHover) return;
|
|
144
|
+
initHls(
|
|
145
|
+
/* autoPlayAfterLoad */
|
|
146
|
+
playOptions === "autoplay"
|
|
147
|
+
);
|
|
148
|
+
return () => {
|
|
149
|
+
if (hlsRef.current) {
|
|
150
|
+
hlsRef.current.destroy();
|
|
151
|
+
hlsRef.current = null;
|
|
152
|
+
}
|
|
153
|
+
hlsInitializedRef.current = false;
|
|
154
|
+
};
|
|
155
|
+
}, [JSON.stringify(resolvedSources), isPlayOnHover]);
|
|
141
156
|
const handlePlayPause = useCallback(() => {
|
|
142
157
|
const v = videoRef.current;
|
|
143
158
|
if (!v) return;
|
|
@@ -182,10 +197,17 @@ var HlsPlayer = React.memo(
|
|
|
182
197
|
if (isMobile) return;
|
|
183
198
|
setIsHovered(true);
|
|
184
199
|
resetInactivityTimer();
|
|
185
|
-
if (isPlayOnHover &&
|
|
186
|
-
|
|
200
|
+
if (isPlayOnHover && !wasManuallyPausedRef.current) {
|
|
201
|
+
if (!hlsInitializedRef.current) {
|
|
202
|
+
initHls(
|
|
203
|
+
/* autoPlayAfterLoad */
|
|
204
|
+
true
|
|
205
|
+
);
|
|
206
|
+
} else if (videoRef.current) {
|
|
207
|
+
videoRef.current.play().then(() => setIsPlaying(true)).catch(console.error);
|
|
208
|
+
}
|
|
187
209
|
}
|
|
188
|
-
}, [isPlayOnHover, isMobile, resetInactivityTimer]);
|
|
210
|
+
}, [isPlayOnHover, isMobile, resetInactivityTimer, initHls]);
|
|
189
211
|
const handleMouseLeave = useCallback(() => {
|
|
190
212
|
if (isMobile) return;
|
|
191
213
|
setIsHovered(false);
|
|
@@ -247,9 +269,10 @@ var HlsPlayer = React.memo(
|
|
|
247
269
|
autoPlay: playOptions === "autoplay",
|
|
248
270
|
loop,
|
|
249
271
|
playsInline: true,
|
|
272
|
+
preload: isPlayOnHover ? "none" : "auto",
|
|
250
273
|
onClick: handleVideoClick,
|
|
251
274
|
onDoubleClick: handleVideoDoubleClick,
|
|
252
|
-
children: resolvedSources.map(({ src, media }, i) => /* @__PURE__ */ jsx(
|
|
275
|
+
children: !isPlayOnHover && resolvedSources.map(({ src, media }, i) => /* @__PURE__ */ jsx(
|
|
253
276
|
"source",
|
|
254
277
|
{
|
|
255
278
|
src,
|