@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260422062852 → 0.8.1-dev.20260422065945
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.
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import React, { useRef, useEffect, useState, useCallback } from "react";
|
|
3
3
|
import Hls from "hls.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var resolveActiveSource = (sources) => {
|
|
6
|
+
for (const { src, media } of sources) {
|
|
7
|
+
if (media && window.matchMedia(media).matches) return src;
|
|
8
|
+
}
|
|
9
|
+
const fallback = sources.find((s) => !s.media);
|
|
10
|
+
return fallback?.src ?? sources[0]?.src ?? "";
|
|
11
|
+
};
|
|
5
12
|
var HlsPlayer = React.memo(
|
|
6
13
|
({
|
|
7
14
|
sources,
|
|
@@ -34,41 +41,41 @@ var HlsPlayer = React.memo(
|
|
|
34
41
|
window.addEventListener("resize", checkMobile);
|
|
35
42
|
return () => window.removeEventListener("resize", checkMobile);
|
|
36
43
|
}, []);
|
|
44
|
+
const [activeSrc, setActiveSrc] = useState("");
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (resolvedSources.length === 0) return;
|
|
47
|
+
const update = () => setActiveSrc(resolveActiveSource(resolvedSources));
|
|
48
|
+
update();
|
|
49
|
+
const mqls = resolvedSources.filter((s) => s.media).map((s) => window.matchMedia(s.media));
|
|
50
|
+
mqls.forEach((mql) => mql.addEventListener("change", update));
|
|
51
|
+
return () => mqls.forEach((mql) => mql.removeEventListener("change", update));
|
|
52
|
+
}, [JSON.stringify(resolvedSources)]);
|
|
37
53
|
useEffect(() => {
|
|
38
54
|
const v = videoRef.current;
|
|
39
|
-
if (!v ||
|
|
55
|
+
if (!v || !activeSrc) return;
|
|
40
56
|
if (hlsRef.current) {
|
|
41
57
|
hlsRef.current.destroy();
|
|
42
58
|
hlsRef.current = null;
|
|
43
59
|
}
|
|
44
60
|
if (Hls.isSupported()) {
|
|
45
61
|
const hls = new Hls();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
v.play().catch(console.error);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
v.addEventListener("loadstart", onLoadStart, { once: true });
|
|
58
|
-
v.load();
|
|
62
|
+
hls.loadSource(activeSrc);
|
|
63
|
+
hls.attachMedia(v);
|
|
64
|
+
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
|
65
|
+
if (isPlaying && !wasManuallyPausedRef.current) {
|
|
66
|
+
v.play().catch(console.error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
59
69
|
hlsRef.current = hls;
|
|
60
70
|
return () => {
|
|
61
|
-
v.removeEventListener("loadstart", onLoadStart);
|
|
62
71
|
hls.destroy();
|
|
63
72
|
hlsRef.current = null;
|
|
64
73
|
};
|
|
65
74
|
} else if (v.canPlayType("application/vnd.apple.mpegurl")) {
|
|
75
|
+
v.src = activeSrc;
|
|
66
76
|
v.load();
|
|
67
77
|
}
|
|
68
|
-
}, [
|
|
69
|
-
// Serialise the source array so the dependency is a stable primitive.
|
|
70
|
-
JSON.stringify(resolvedSources)
|
|
71
|
-
]);
|
|
78
|
+
}, [activeSrc]);
|
|
72
79
|
const handlePlayPause = useCallback(() => {
|
|
73
80
|
const v = videoRef.current;
|
|
74
81
|
if (!v) return;
|
|
@@ -116,16 +123,7 @@ var HlsPlayer = React.memo(
|
|
|
116
123
|
autoPlay: playOptions === "autoplay",
|
|
117
124
|
loop,
|
|
118
125
|
playsInline: true,
|
|
119
|
-
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
120
|
-
children: resolvedSources.map(({ src, media }, i) => /* @__PURE__ */ jsx(
|
|
121
|
-
"source",
|
|
122
|
-
{
|
|
123
|
-
src,
|
|
124
|
-
type: "application/x-mpegURL",
|
|
125
|
-
...media ? { media } : {}
|
|
126
|
-
},
|
|
127
|
-
i
|
|
128
|
-
))
|
|
126
|
+
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
129
127
|
}
|
|
130
128
|
),
|
|
131
129
|
!isMobile && playOptions === "playOnHover" && posterUrl && /* @__PURE__ */ jsx(
|
package/dist/index.js
CHANGED
|
@@ -271,7 +271,7 @@ var HlsPlayer_exports = {};
|
|
|
271
271
|
__export(HlsPlayer_exports, {
|
|
272
272
|
default: () => HlsPlayer_default
|
|
273
273
|
});
|
|
274
|
-
var import_react33, import_hls, import_jsx_runtime42, HlsPlayer, HlsPlayer_default;
|
|
274
|
+
var import_react33, import_hls, import_jsx_runtime42, resolveActiveSource, HlsPlayer, HlsPlayer_default;
|
|
275
275
|
var init_HlsPlayer = __esm({
|
|
276
276
|
"src/components/HlsPlayer.tsx"() {
|
|
277
277
|
"use strict";
|
|
@@ -279,6 +279,13 @@ var init_HlsPlayer = __esm({
|
|
|
279
279
|
import_react33 = __toESM(require("react"));
|
|
280
280
|
import_hls = __toESM(require("hls.js"));
|
|
281
281
|
import_jsx_runtime42 = require("react/jsx-runtime");
|
|
282
|
+
resolveActiveSource = (sources) => {
|
|
283
|
+
for (const { src, media } of sources) {
|
|
284
|
+
if (media && window.matchMedia(media).matches) return src;
|
|
285
|
+
}
|
|
286
|
+
const fallback = sources.find((s) => !s.media);
|
|
287
|
+
return fallback?.src ?? sources[0]?.src ?? "";
|
|
288
|
+
};
|
|
282
289
|
HlsPlayer = import_react33.default.memo(
|
|
283
290
|
({
|
|
284
291
|
sources,
|
|
@@ -311,41 +318,41 @@ var init_HlsPlayer = __esm({
|
|
|
311
318
|
window.addEventListener("resize", checkMobile);
|
|
312
319
|
return () => window.removeEventListener("resize", checkMobile);
|
|
313
320
|
}, []);
|
|
321
|
+
const [activeSrc, setActiveSrc] = (0, import_react33.useState)("");
|
|
322
|
+
(0, import_react33.useEffect)(() => {
|
|
323
|
+
if (resolvedSources.length === 0) return;
|
|
324
|
+
const update = () => setActiveSrc(resolveActiveSource(resolvedSources));
|
|
325
|
+
update();
|
|
326
|
+
const mqls = resolvedSources.filter((s) => s.media).map((s) => window.matchMedia(s.media));
|
|
327
|
+
mqls.forEach((mql) => mql.addEventListener("change", update));
|
|
328
|
+
return () => mqls.forEach((mql) => mql.removeEventListener("change", update));
|
|
329
|
+
}, [JSON.stringify(resolvedSources)]);
|
|
314
330
|
(0, import_react33.useEffect)(() => {
|
|
315
331
|
const v = videoRef.current;
|
|
316
|
-
if (!v ||
|
|
332
|
+
if (!v || !activeSrc) return;
|
|
317
333
|
if (hlsRef.current) {
|
|
318
334
|
hlsRef.current.destroy();
|
|
319
335
|
hlsRef.current = null;
|
|
320
336
|
}
|
|
321
337
|
if (import_hls.default.isSupported()) {
|
|
322
338
|
const hls = new import_hls.default();
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
v.play().catch(console.error);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
};
|
|
334
|
-
v.addEventListener("loadstart", onLoadStart, { once: true });
|
|
335
|
-
v.load();
|
|
339
|
+
hls.loadSource(activeSrc);
|
|
340
|
+
hls.attachMedia(v);
|
|
341
|
+
hls.on(import_hls.default.Events.MANIFEST_PARSED, () => {
|
|
342
|
+
if (isPlaying && !wasManuallyPausedRef.current) {
|
|
343
|
+
v.play().catch(console.error);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
336
346
|
hlsRef.current = hls;
|
|
337
347
|
return () => {
|
|
338
|
-
v.removeEventListener("loadstart", onLoadStart);
|
|
339
348
|
hls.destroy();
|
|
340
349
|
hlsRef.current = null;
|
|
341
350
|
};
|
|
342
351
|
} else if (v.canPlayType("application/vnd.apple.mpegurl")) {
|
|
352
|
+
v.src = activeSrc;
|
|
343
353
|
v.load();
|
|
344
354
|
}
|
|
345
|
-
}, [
|
|
346
|
-
// Serialise the source array so the dependency is a stable primitive.
|
|
347
|
-
JSON.stringify(resolvedSources)
|
|
348
|
-
]);
|
|
355
|
+
}, [activeSrc]);
|
|
349
356
|
const handlePlayPause = (0, import_react33.useCallback)(() => {
|
|
350
357
|
const v = videoRef.current;
|
|
351
358
|
if (!v) return;
|
|
@@ -393,16 +400,7 @@ var init_HlsPlayer = __esm({
|
|
|
393
400
|
autoPlay: playOptions === "autoplay",
|
|
394
401
|
loop,
|
|
395
402
|
playsInline: true,
|
|
396
|
-
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
397
|
-
children: resolvedSources.map(({ src, media }, i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
398
|
-
"source",
|
|
399
|
-
{
|
|
400
|
-
src,
|
|
401
|
-
type: "application/x-mpegURL",
|
|
402
|
-
...media ? { media } : {}
|
|
403
|
-
},
|
|
404
|
-
i
|
|
405
|
-
))
|
|
403
|
+
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
406
404
|
}
|
|
407
405
|
),
|
|
408
406
|
!isMobile && playOptions === "playOnHover" && posterUrl && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HlsPlayer_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VVEZGWP4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Button_default,
|
|
6
6
|
ServiceClient_default,
|
|
@@ -2638,7 +2638,7 @@ var DeviceAssetSelector_default = DeviceAssetSelector;
|
|
|
2638
2638
|
|
|
2639
2639
|
// src/components/pageRenderingEngine/nodes/ImageNode.tsx
|
|
2640
2640
|
import { Fragment as Fragment3, jsx as jsx39 } from "react/jsx-runtime";
|
|
2641
|
-
var HlsPlayer = dynamic(() => import("./HlsPlayer-
|
|
2641
|
+
var HlsPlayer = dynamic(() => import("./HlsPlayer-O6BEBDTQ.mjs"), {
|
|
2642
2642
|
ssr: false
|
|
2643
2643
|
});
|
|
2644
2644
|
var getNestedValue = (obj, path) => {
|
|
@@ -4107,7 +4107,7 @@ var Pagination_default = Pagination;
|
|
|
4107
4107
|
// src/components/pageRenderingEngine/nodes/ImageGalleryNode.tsx
|
|
4108
4108
|
import dynamic5 from "next/dynamic";
|
|
4109
4109
|
import { Fragment as Fragment9, jsx as jsx58, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
4110
|
-
var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-
|
|
4110
|
+
var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-O6BEBDTQ.mjs"), { ssr: false });
|
|
4111
4111
|
var deviceToMediaQuery = (device) => {
|
|
4112
4112
|
switch (device) {
|
|
4113
4113
|
case "sm":
|
package/package.json
CHANGED