@oddin-gg/havik-player 2.27.0 → 2.27.1
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/havik-player.global.js +2 -2
- package/dist/havik-player.global.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +241 -231
- package/dist/index.js.map +1 -1
- package/embed/index.html +1 -1
- package/examples/vanilla.html +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -315,25 +315,25 @@ function x(e) {
|
|
|
315
315
|
function _e(e) {
|
|
316
316
|
return e.fullscreenElement ?? e.webkitFullscreenElement ?? null;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function ve(e, t) {
|
|
319
319
|
let n = _e(x(e));
|
|
320
320
|
return n != null && (n === e || t != null && n === t) || e.webkitDisplayingFullscreen === !0;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function S(e, t) {
|
|
323
323
|
let n = t ?? e, r = x(e);
|
|
324
324
|
if (typeof n.requestFullscreen == "function") return r.fullscreenEnabled !== !1;
|
|
325
325
|
if (typeof n.webkitRequestFullscreen == "function") return r.webkitFullscreenEnabled !== !1;
|
|
326
326
|
let i = e;
|
|
327
327
|
return i.webkitSupportsFullscreen === !0 && typeof i.webkitEnterFullscreen == "function" || e.readyState < 1;
|
|
328
328
|
}
|
|
329
|
-
async function
|
|
329
|
+
async function C(e, t) {
|
|
330
330
|
let n = t ?? e;
|
|
331
331
|
if (typeof n.requestFullscreen == "function") return await n.requestFullscreen(), !0;
|
|
332
332
|
if (typeof n.webkitRequestFullscreen == "function") return n.webkitRequestFullscreen(), !0;
|
|
333
333
|
let r = e;
|
|
334
334
|
return r.webkitSupportsFullscreen && typeof r.webkitEnterFullscreen == "function" ? (r.webkitEnterFullscreen(), !0) : !1;
|
|
335
335
|
}
|
|
336
|
-
async function
|
|
336
|
+
async function w(e, t) {
|
|
337
337
|
let n = e;
|
|
338
338
|
if (n.webkitDisplayingFullscreen) {
|
|
339
339
|
n.webkitExitFullscreen?.();
|
|
@@ -344,7 +344,7 @@ async function T(e, t) {
|
|
|
344
344
|
}
|
|
345
345
|
//#endregion
|
|
346
346
|
//#region src/core/catalog.ts
|
|
347
|
-
async function
|
|
347
|
+
async function ye(e) {
|
|
348
348
|
let t = new URLSearchParams();
|
|
349
349
|
e.status && t.set("status", Array.isArray(e.status) ? e.status.join(",") : e.status), e.sport && t.set("sport", e.sport);
|
|
350
350
|
let i = t.toString(), a = f(e.baseUrl, "/v1/catalog" + (i ? `?${i}` : "")), o = new Headers();
|
|
@@ -362,12 +362,12 @@ async function ve(e) {
|
|
|
362
362
|
};
|
|
363
363
|
if (!s.ok) throw new n(r(s.status), s.status, `catalog request failed (HTTP ${s.status})`);
|
|
364
364
|
return {
|
|
365
|
-
tournaments:
|
|
365
|
+
tournaments: be(await s.json()),
|
|
366
366
|
etag: s.headers.get("etag") ?? void 0,
|
|
367
367
|
notModified: !1
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function be(e) {
|
|
371
371
|
return (e.tournaments ?? []).map((e) => {
|
|
372
372
|
let t = e.urn ?? "", n = e.name ?? "", r = e.sport ?? "";
|
|
373
373
|
return {
|
|
@@ -389,7 +389,7 @@ function ye(e) {
|
|
|
389
389
|
};
|
|
390
390
|
});
|
|
391
391
|
}
|
|
392
|
-
async function
|
|
392
|
+
async function xe(e) {
|
|
393
393
|
let t = f(e.baseUrl, `/v1/tournaments/${encodeURIComponent(e.urn)}`), i = new Headers();
|
|
394
394
|
e.etag && i.set("If-None-Match", e.etag);
|
|
395
395
|
let a = await m(t, {
|
|
@@ -409,13 +409,13 @@ async function be(e) {
|
|
|
409
409
|
};
|
|
410
410
|
if (!a.ok) throw new n(r(a.status), a.status, `tournament request failed (HTTP ${a.status})`);
|
|
411
411
|
return {
|
|
412
|
-
tournament:
|
|
412
|
+
tournament: Se(await a.json()),
|
|
413
413
|
etag: a.headers.get("etag") ?? void 0,
|
|
414
414
|
notModified: !1,
|
|
415
415
|
notFound: !1
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function Se(e) {
|
|
419
419
|
let t = e.urn ?? "", n = e.name ?? "", r = e.sport ?? "";
|
|
420
420
|
return {
|
|
421
421
|
urn: t,
|
|
@@ -435,18 +435,18 @@ function xe(e) {
|
|
|
435
435
|
}))
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function Ce(e) {
|
|
439
439
|
return e.tournaments.flatMap((e) => e.matches);
|
|
440
440
|
}
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/core/poll.ts
|
|
443
|
-
var
|
|
443
|
+
var we = /* @__PURE__ */ new Set([
|
|
444
444
|
"NOT_FOUND",
|
|
445
445
|
"GEO_DENIED",
|
|
446
446
|
"GONE",
|
|
447
447
|
"INVALID_URN"
|
|
448
448
|
]);
|
|
449
|
-
function
|
|
449
|
+
function Te(e) {
|
|
450
450
|
let t = Math.max(2e3, e.intervalMs ?? 1e4), i = new AbortController(), a, o, s, c = !1, d = () => {
|
|
451
451
|
c || (a = setTimeout(p, t));
|
|
452
452
|
}, p = async () => {
|
|
@@ -479,7 +479,7 @@ function we(e) {
|
|
|
479
479
|
} catch (t) {
|
|
480
480
|
if (!i.signal.aborted) {
|
|
481
481
|
let r = t instanceof n ? t : new n("NETWORK", 0, String(t));
|
|
482
|
-
|
|
482
|
+
we.has(r.code) && (c = !0), e.onError?.(r);
|
|
483
483
|
}
|
|
484
484
|
} finally {
|
|
485
485
|
d();
|
|
@@ -491,16 +491,16 @@ function we(e) {
|
|
|
491
491
|
}
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/core/events.ts
|
|
494
|
-
var
|
|
494
|
+
var Ee = 45e3, T = class extends Error {
|
|
495
495
|
status;
|
|
496
496
|
terminal;
|
|
497
497
|
constructor(e) {
|
|
498
498
|
let t = e === 410;
|
|
499
499
|
super(t ? `live-state subscribe failed: HTTP ${e} — match is gone, not retrying` : e === 404 ? `live-state subscribe failed: HTTP ${e} — match not in the catalog, retrying slowly` : `live-state subscribe failed: HTTP ${e}`), this.name = "LiveStateHttpError", this.status = e, this.terminal = t;
|
|
500
500
|
}
|
|
501
|
-
},
|
|
502
|
-
function
|
|
503
|
-
let t = Math.max(250, e.minBackoffMs ?? 1e3), n = Math.max(t, e.maxBackoffMs ?? 15e3), r = Math.max(t, e.notFoundRetryMs ??
|
|
501
|
+
}, De = 3e5;
|
|
502
|
+
function E(e) {
|
|
503
|
+
let t = Math.max(250, e.minBackoffMs ?? 1e3), n = Math.max(t, e.maxBackoffMs ?? 15e3), r = Math.max(t, e.notFoundRetryMs ?? De), i = e.idleTimeoutMs ?? Ee, a = Number.isFinite(i) && i > 0 ? i : 0, o = new AbortController(), s = !1, l = (e) => new Promise((t) => {
|
|
504
504
|
if (o.signal.aborted) return t();
|
|
505
505
|
let n = setTimeout(t, e);
|
|
506
506
|
o.signal.addEventListener("abort", () => {
|
|
@@ -567,7 +567,7 @@ function D(e) {
|
|
|
567
567
|
});
|
|
568
568
|
if (clearTimeout(_), s) return;
|
|
569
569
|
if (!o.ok || !o.body) {
|
|
570
|
-
let t = new
|
|
570
|
+
let t = new T(o.status);
|
|
571
571
|
h = t.terminal, g = o.status === 404, e.onError?.(t);
|
|
572
572
|
} else await p(o.body, () => {
|
|
573
573
|
i = t;
|
|
@@ -585,7 +585,7 @@ function D(e) {
|
|
|
585
585
|
s || (s = !0, o.abort());
|
|
586
586
|
} };
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function D(e) {
|
|
589
589
|
try {
|
|
590
590
|
let t = new URL(e);
|
|
591
591
|
return t.hostname = `events.${t.hostname}`, t.pathname = "", t.search = "", t.origin;
|
|
@@ -595,27 +595,27 @@ function O(e) {
|
|
|
595
595
|
}
|
|
596
596
|
//#endregion
|
|
597
597
|
//#region src/core/drm/deviceId.ts
|
|
598
|
-
var
|
|
599
|
-
function
|
|
598
|
+
var O = "havik.player.deviceId", k;
|
|
599
|
+
function A() {
|
|
600
600
|
if (k) return k;
|
|
601
601
|
try {
|
|
602
|
-
let e = globalThis.localStorage?.getItem(
|
|
602
|
+
let e = globalThis.localStorage?.getItem(O);
|
|
603
603
|
if (e) return k = e, e;
|
|
604
604
|
} catch {}
|
|
605
|
-
let e =
|
|
605
|
+
let e = ke();
|
|
606
606
|
k = e;
|
|
607
607
|
try {
|
|
608
|
-
globalThis.localStorage?.setItem(
|
|
608
|
+
globalThis.localStorage?.setItem(O, e);
|
|
609
609
|
} catch {}
|
|
610
610
|
return e;
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function Oe() {
|
|
613
613
|
k = void 0;
|
|
614
614
|
try {
|
|
615
|
-
globalThis.localStorage?.removeItem(
|
|
615
|
+
globalThis.localStorage?.removeItem(O);
|
|
616
616
|
} catch {}
|
|
617
617
|
}
|
|
618
|
-
function
|
|
618
|
+
function ke() {
|
|
619
619
|
let e = globalThis.crypto;
|
|
620
620
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
621
621
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
@@ -627,32 +627,32 @@ function Ae() {
|
|
|
627
627
|
}
|
|
628
628
|
//#endregion
|
|
629
629
|
//#region src/core/drm/headers.ts
|
|
630
|
-
function
|
|
630
|
+
function Ae(e, t, n = {}) {
|
|
631
631
|
let r = {
|
|
632
632
|
"x-api-key": t.apiKey,
|
|
633
633
|
"X-Match-Urn": e.matchUrn,
|
|
634
|
-
"X-Device-Id": n.deviceId ??
|
|
634
|
+
"X-Device-Id": n.deviceId ?? A(),
|
|
635
635
|
"Content-Type": "application/octet-stream"
|
|
636
636
|
};
|
|
637
637
|
return n.userId && (r["X-User-Id"] = n.userId), r;
|
|
638
638
|
}
|
|
639
639
|
//#endregion
|
|
640
640
|
//#region src/core/bandwidthMemory.ts
|
|
641
|
-
var
|
|
642
|
-
function
|
|
641
|
+
var j = "havik.player.bandwidth", je = .8, Me = 2e7, Ne = 3e5;
|
|
642
|
+
function Pe() {
|
|
643
643
|
return globalThis.navigator?.connection;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
646
|
-
let e =
|
|
645
|
+
function Fe() {
|
|
646
|
+
let e = Pe()?.type;
|
|
647
647
|
return typeof e == "string" && e !== "" && e !== "unknown" ? e : "any";
|
|
648
648
|
}
|
|
649
|
-
function
|
|
650
|
-
let e =
|
|
649
|
+
function Ie() {
|
|
650
|
+
let e = Pe()?.downlink;
|
|
651
651
|
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e * 1e6 : void 0;
|
|
652
652
|
}
|
|
653
|
-
function
|
|
653
|
+
function Le() {
|
|
654
654
|
try {
|
|
655
|
-
let e = globalThis.localStorage?.getItem(
|
|
655
|
+
let e = globalThis.localStorage?.getItem(j);
|
|
656
656
|
if (!e) return {};
|
|
657
657
|
let t = JSON.parse(e);
|
|
658
658
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
@@ -660,36 +660,36 @@ function ze() {
|
|
|
660
660
|
return {};
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
function
|
|
664
|
-
let t =
|
|
663
|
+
function Re(e = Date.now()) {
|
|
664
|
+
let t = Le()[Fe()];
|
|
665
665
|
if (!t || typeof t.bps != "number" || typeof t.at != "number" || !Number.isFinite(t.bps) || t.bps <= 0) return;
|
|
666
666
|
let n = e - t.at;
|
|
667
667
|
if (n < 0 || n > 2592e5) return;
|
|
668
|
-
let r =
|
|
669
|
-
return Math.round(Math.min(
|
|
668
|
+
let r = Ie(), i = r === void 0 ? t.bps : Math.min(t.bps, r);
|
|
669
|
+
return Math.round(Math.min(Me, Math.max(Ne, i * je)));
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function ze(e, t = Date.now()) {
|
|
672
672
|
if (!Number.isFinite(e) || e <= 0) return;
|
|
673
|
-
let n =
|
|
674
|
-
n[
|
|
673
|
+
let n = Le();
|
|
674
|
+
n[Fe()] = {
|
|
675
675
|
bps: Math.round(e),
|
|
676
676
|
at: t
|
|
677
677
|
};
|
|
678
678
|
try {
|
|
679
|
-
globalThis.localStorage?.setItem(
|
|
679
|
+
globalThis.localStorage?.setItem(j, JSON.stringify(n));
|
|
680
680
|
} catch {}
|
|
681
681
|
}
|
|
682
|
-
function
|
|
682
|
+
function Be() {
|
|
683
683
|
try {
|
|
684
|
-
globalThis.localStorage?.removeItem(
|
|
684
|
+
globalThis.localStorage?.removeItem(j);
|
|
685
685
|
} catch {}
|
|
686
686
|
}
|
|
687
687
|
//#endregion
|
|
688
688
|
//#region src/core/drm/cdm.ts
|
|
689
|
-
var
|
|
690
|
-
function
|
|
691
|
-
let n =
|
|
692
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
689
|
+
var Ve = /* @__PURE__ */ new WeakMap();
|
|
690
|
+
function He(e, t) {
|
|
691
|
+
let n = Ve.get(e);
|
|
692
|
+
n || (n = /* @__PURE__ */ new Map(), Ve.set(e, n));
|
|
693
693
|
let r = n.get(t.keySystem);
|
|
694
694
|
if (r) return r;
|
|
695
695
|
let i = t.createMediaKeys().catch((e) => {
|
|
@@ -697,22 +697,22 @@ function We(e, t) {
|
|
|
697
697
|
});
|
|
698
698
|
return n.set(t.keySystem, i), i;
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function M() {
|
|
701
701
|
return typeof navigator < "u" && typeof navigator.requestMediaKeySystemAccess == "function";
|
|
702
702
|
}
|
|
703
|
-
var
|
|
704
|
-
function
|
|
703
|
+
var Ue = ["SW_SECURE_DECODE", "SW_SECURE_CRYPTO"];
|
|
704
|
+
function We(e) {
|
|
705
705
|
return e.startsWith("com.widevine");
|
|
706
706
|
}
|
|
707
|
-
function
|
|
708
|
-
if (!
|
|
707
|
+
function Ge(e, t) {
|
|
708
|
+
if (!We(e)) return t;
|
|
709
709
|
let n = (e, t) => {
|
|
710
710
|
let n = e.videoCapabilities;
|
|
711
711
|
return !n?.length || !n.some((e) => e.robustness) ? !1 : n.every((e) => {
|
|
712
|
-
let n =
|
|
713
|
-
return n === -1 ||
|
|
712
|
+
let n = Ue.indexOf(e.robustness);
|
|
713
|
+
return n === -1 || Ue.indexOf(t) > n;
|
|
714
714
|
});
|
|
715
|
-
}, r =
|
|
715
|
+
}, r = Ue.flatMap((e) => t.filter((t) => n(t, e)).map((t) => ({
|
|
716
716
|
...t,
|
|
717
717
|
videoCapabilities: t.videoCapabilities?.map((t) => ({
|
|
718
718
|
...t,
|
|
@@ -722,10 +722,10 @@ function M(e, t) {
|
|
|
722
722
|
return [...t, ...r];
|
|
723
723
|
}
|
|
724
724
|
function Ke(e) {
|
|
725
|
-
return (t, n) =>
|
|
725
|
+
return (t, n) => M() ? navigator.requestMediaKeySystemAccess(t, Ge(t, n)).then((t) => ({
|
|
726
726
|
keySystem: t.keySystem,
|
|
727
727
|
getConfiguration: () => t.getConfiguration(),
|
|
728
|
-
createMediaKeys: () =>
|
|
728
|
+
createMediaKeys: () => He(e, t)
|
|
729
729
|
})) : Promise.reject(/* @__PURE__ */ Error("navigator.requestMediaKeySystemAccess is unavailable — EME needs a secure context (https, or localhost)"));
|
|
730
730
|
}
|
|
731
731
|
var N = {
|
|
@@ -734,7 +734,7 @@ var N = {
|
|
|
734
734
|
scheme: "cbcs"
|
|
735
735
|
};
|
|
736
736
|
function qe(e) {
|
|
737
|
-
if (!
|
|
737
|
+
if (!M()) return;
|
|
738
738
|
let t = (e, t) => ({
|
|
739
739
|
contentType: e,
|
|
740
740
|
robustness: t,
|
|
@@ -781,7 +781,7 @@ function Xe(e) {
|
|
|
781
781
|
}]
|
|
782
782
|
}, i = (async () => {
|
|
783
783
|
try {
|
|
784
|
-
return await navigator.requestMediaKeySystemAccess("com.widevine.alpha",
|
|
784
|
+
return await navigator.requestMediaKeySystemAccess("com.widevine.alpha", Ge("com.widevine.alpha", [r])), !0;
|
|
785
785
|
} catch {
|
|
786
786
|
return !1;
|
|
787
787
|
}
|
|
@@ -789,7 +789,7 @@ function Xe(e) {
|
|
|
789
789
|
return Ye.set(t, i), i;
|
|
790
790
|
}
|
|
791
791
|
function Ze() {
|
|
792
|
-
if (
|
|
792
|
+
if (M()) for (let e of Object.values(Je)) Xe(e);
|
|
793
793
|
}
|
|
794
794
|
function Qe(e) {
|
|
795
795
|
let t = P(e);
|
|
@@ -818,7 +818,7 @@ function rt(e) {
|
|
|
818
818
|
robustness: "",
|
|
819
819
|
encryptionScheme: "cbcs"
|
|
820
820
|
}]
|
|
821
|
-
}] :
|
|
821
|
+
}] : Ge("com.widevine.alpha", [{
|
|
822
822
|
initDataTypes: ["cenc"],
|
|
823
823
|
videoCapabilities: [{
|
|
824
824
|
contentType: et,
|
|
@@ -975,26 +975,36 @@ var ht = class {
|
|
|
975
975
|
this.video.removeEventListener("timeupdate", e), this.video.removeEventListener("seeking", e);
|
|
976
976
|
};
|
|
977
977
|
}
|
|
978
|
-
};
|
|
979
|
-
function
|
|
980
|
-
let n =
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
["
|
|
978
|
+
}, gt = .25;
|
|
979
|
+
function _t(e, t) {
|
|
980
|
+
let n = null, r = (r) => {
|
|
981
|
+
n = r === "buffering" ? e.currentTime : null, t(r);
|
|
982
|
+
}, i = [
|
|
983
|
+
["playing", () => r("playing")],
|
|
984
|
+
["waiting", () => r("buffering")],
|
|
985
|
+
["stalled", () => {
|
|
986
|
+
!e.paused && e.readyState < HTMLMediaElement.HAVE_FUTURE_DATA && r("buffering");
|
|
987
|
+
}],
|
|
988
|
+
["seeked", () => {
|
|
989
|
+
n !== null && (n = e.currentTime);
|
|
990
|
+
}],
|
|
991
|
+
["timeupdate", () => {
|
|
992
|
+
n !== null && !e.paused && !e.seeking && e.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA && e.currentTime - n >= gt && r("playing");
|
|
993
|
+
}],
|
|
984
994
|
["pause", () => {
|
|
985
|
-
e.ended ||
|
|
995
|
+
e.ended || r("paused");
|
|
986
996
|
}],
|
|
987
|
-
["ended", () =>
|
|
997
|
+
["ended", () => r("ended")]
|
|
988
998
|
];
|
|
989
|
-
for (let [t,
|
|
999
|
+
for (let [t, n] of i) e.addEventListener(t, n);
|
|
990
1000
|
return () => {
|
|
991
|
-
for (let [t,
|
|
1001
|
+
for (let [t, n] of i) e.removeEventListener(t, n);
|
|
992
1002
|
};
|
|
993
1003
|
}
|
|
994
1004
|
//#endregion
|
|
995
1005
|
//#region src/core/engine/native.ts
|
|
996
|
-
var
|
|
997
|
-
function
|
|
1006
|
+
var vt = 2e3, yt = 3, z = 500, bt = 6e3, xt = .25, St = 250, Ct = .05, wt = 4, Tt = 12e3, Et = .25, Dt = 1e3;
|
|
1007
|
+
function Ot(e) {
|
|
998
1008
|
try {
|
|
999
1009
|
let t = new TextDecoder("utf-8").decode(new Uint8Array(e));
|
|
1000
1010
|
return /^skd:\/\/[0-9a-fA-F-]{36}:([0-9a-fA-F]{32})$/.exec(t)?.[1];
|
|
@@ -1010,7 +1020,7 @@ function V() {
|
|
|
1010
1020
|
let e = "WebKitMediaKeys" in window || typeof HTMLMediaElement < "u" && "webkitSetMediaKeys" in HTMLMediaElement.prototype, t = typeof navigator < "u" && /Apple/i.test(navigator.vendor ?? "");
|
|
1011
1021
|
return e || t;
|
|
1012
1022
|
}
|
|
1013
|
-
function
|
|
1023
|
+
function kt() {
|
|
1014
1024
|
if (typeof navigator > "u" || !V()) return !1;
|
|
1015
1025
|
let e = navigator.userAgent ?? "";
|
|
1016
1026
|
return /iPhone|iPad|iPod/.test(e) ? !0 : /Macintosh/.test(e) && typeof navigator.maxTouchPoints == "number" && navigator.maxTouchPoints > 1;
|
|
@@ -1066,7 +1076,7 @@ var H = class {
|
|
|
1066
1076
|
type: "error",
|
|
1067
1077
|
error: L() ? new n("INTERNAL", 0, "native HLS playback error") : new n("NETWORK", 0, "native HLS playback error while offline"),
|
|
1068
1078
|
fatal: !0
|
|
1069
|
-
}), this.onLoaded && e.addEventListener("loadedmetadata", this.onLoaded, { once: !0 }), e.addEventListener("error", this.onError), e.src =
|
|
1079
|
+
}), this.onLoaded && e.addEventListener("loadedmetadata", this.onLoaded, { once: !0 }), e.addEventListener("error", this.onError), e.src = jt(t.manifestUrl, t.analytics?.sid), e.load();
|
|
1070
1080
|
}
|
|
1071
1081
|
startLoad() {
|
|
1072
1082
|
this.loadStarted || (this.loadStarted = !0, this.restorePreload());
|
|
@@ -1094,7 +1104,7 @@ var H = class {
|
|
|
1094
1104
|
};
|
|
1095
1105
|
this.onEncrypted = (n) => {
|
|
1096
1106
|
let a = n;
|
|
1097
|
-
a.initData && !this.fairplayArmed && (this.fairplayArmed = !0, this.fairplayKeyIV =
|
|
1107
|
+
a.initData && !this.fairplayArmed && (this.fairplayArmed = !0, this.fairplayKeyIV = Ot(a.initData), (async () => {
|
|
1098
1108
|
try {
|
|
1099
1109
|
let n = await (await navigator.requestMediaKeySystemAccess("com.apple.fps", [{
|
|
1100
1110
|
initDataTypes: [a.initDataType],
|
|
@@ -1197,7 +1207,7 @@ var H = class {
|
|
|
1197
1207
|
if (this.cdnHost ||= mt(this.builtAt), this.cdnHost && (n.cdnHost = this.cdnHost), this.deps.descriptor.drmEnabled && (n.keySystem = "fairplay"), e.duration === Infinity) {
|
|
1198
1208
|
n.isLive = !0;
|
|
1199
1209
|
let t = this.liveEdgeEstimate(), r = t == null ? NaN : t - e.currentTime;
|
|
1200
|
-
Number.isFinite(r) && (n.atLiveEdge = r <=
|
|
1210
|
+
Number.isFinite(r) && (n.atLiveEdge = r <= wt, !e.paused && r >= 0 && (n.latencySeconds = r));
|
|
1201
1211
|
} else Number.isFinite(e.duration) && e.duration > 0 && (n.isLive = !1);
|
|
1202
1212
|
return n;
|
|
1203
1213
|
}
|
|
@@ -1215,7 +1225,7 @@ var H = class {
|
|
|
1215
1225
|
return;
|
|
1216
1226
|
}
|
|
1217
1227
|
let t = this.hiddenSince;
|
|
1218
|
-
this.hiddenSince = null, t != null && e - t >=
|
|
1228
|
+
this.hiddenSince = null, t != null && e - t >= vt && this.armRefocus();
|
|
1219
1229
|
}, this.onPageShow = (e) => {
|
|
1220
1230
|
e.persisted && this.armRefocus();
|
|
1221
1231
|
}, document.addEventListener("visibilitychange", this.onVisibility), typeof window < "u" && window.addEventListener("pageshow", this.onPageShow));
|
|
@@ -1225,7 +1235,7 @@ var H = class {
|
|
|
1225
1235
|
let e = this.liveEnd(), t = U, n = t(), r = 0, i = () => {
|
|
1226
1236
|
if (this.refocusTimer = null, Number.isFinite(this.deps.video.duration)) return;
|
|
1227
1237
|
r += z;
|
|
1228
|
-
let a = this.liveEnd(), o = a != null && (e == null || a >= e +
|
|
1238
|
+
let a = this.liveEnd(), o = a != null && (e == null || a >= e + xt), s = Math.max(r, t() - n) >= bt;
|
|
1229
1239
|
if (o || s && a != null) {
|
|
1230
1240
|
this.snapToLive();
|
|
1231
1241
|
return;
|
|
@@ -1245,9 +1255,9 @@ var H = class {
|
|
|
1245
1255
|
}, e.addEventListener("seeking", this.onEdgeReset), e.addEventListener("emptied", this.onEdgeReset), this.edgeTimer = setInterval(() => {
|
|
1246
1256
|
if (e.duration !== Infinity) return;
|
|
1247
1257
|
this.checkEndStale();
|
|
1248
|
-
let t =
|
|
1249
|
-
t != null && ((this.lastBufferedEnd == null || Math.abs(t - this.lastBufferedEnd) >=
|
|
1250
|
-
},
|
|
1258
|
+
let t = At(e, e.currentTime);
|
|
1259
|
+
t != null && ((this.lastBufferedEnd == null || Math.abs(t - this.lastBufferedEnd) >= Ct) && (this.bufferedAdvancedAt = U()), this.lastBufferedEnd = t);
|
|
1260
|
+
}, St);
|
|
1251
1261
|
}
|
|
1252
1262
|
checkEndStale() {
|
|
1253
1263
|
if (this.endedEmitted) return;
|
|
@@ -1255,14 +1265,14 @@ var H = class {
|
|
|
1255
1265
|
this.lastTickAt = e;
|
|
1256
1266
|
let n = this.liveEnd();
|
|
1257
1267
|
if (n == null) return;
|
|
1258
|
-
let r = this.lastSeekableEnd == null || Math.abs(n - this.lastSeekableEnd) >=
|
|
1268
|
+
let r = this.lastSeekableEnd == null || Math.abs(n - this.lastSeekableEnd) >= Et;
|
|
1259
1269
|
this.lastSeekableEnd = n;
|
|
1260
1270
|
let i = this.deps.video, a = typeof document < "u" && document.visibilityState === "hidden";
|
|
1261
|
-
if (r || t >
|
|
1271
|
+
if (r || t > Dt || a || i.paused) {
|
|
1262
1272
|
this.edgeStampedAt = e;
|
|
1263
1273
|
return;
|
|
1264
1274
|
}
|
|
1265
|
-
e - (this.edgeStampedAt ?? e) >
|
|
1275
|
+
e - (this.edgeStampedAt ?? e) > Tt && (this.endedEmitted = !0, this.deps.emit({
|
|
1266
1276
|
type: "ended",
|
|
1267
1277
|
reason: "stalled"
|
|
1268
1278
|
}));
|
|
@@ -1276,7 +1286,7 @@ var H = class {
|
|
|
1276
1286
|
liveEdgeEstimate() {
|
|
1277
1287
|
let e = this.deps.video;
|
|
1278
1288
|
if (e.duration !== Infinity) return null;
|
|
1279
|
-
let t = this.liveEnd(), n =
|
|
1289
|
+
let t = this.liveEnd(), n = At(e, e.currentTime) ?? this.lastBufferedEnd;
|
|
1280
1290
|
if (n != null) {
|
|
1281
1291
|
let e = this.bufferedAdvancedAt, r = n + (e == null ? 0 : Math.max(0, (U() - e) / 1e3));
|
|
1282
1292
|
(t == null || r > t) && (t = r);
|
|
@@ -1292,7 +1302,7 @@ var H = class {
|
|
|
1292
1302
|
snapToLive() {
|
|
1293
1303
|
let e = this.deps.video, t = this.liveEnd();
|
|
1294
1304
|
if (t == null) return;
|
|
1295
|
-
let n = e.seekable.start(e.seekable.length - 1), r = Math.min(e.currentTime, t), i = Math.max(n, t -
|
|
1305
|
+
let n = e.seekable.start(e.seekable.length - 1), r = Math.min(e.currentTime, t), i = Math.max(n, t - yt, r);
|
|
1296
1306
|
try {
|
|
1297
1307
|
e.currentTime = i;
|
|
1298
1308
|
} catch {}
|
|
@@ -1313,7 +1323,7 @@ var H = class {
|
|
|
1313
1323
|
function U() {
|
|
1314
1324
|
return typeof performance < "u" ? performance.now() : Date.now();
|
|
1315
1325
|
}
|
|
1316
|
-
function
|
|
1326
|
+
function At(e, t) {
|
|
1317
1327
|
let n = e.buffered;
|
|
1318
1328
|
if (!n || !Number.isFinite(t)) return null;
|
|
1319
1329
|
for (let e = 0; e < n.length; e += 1) if (n.start(e) <= t + .1 && n.end(e) > t) {
|
|
@@ -1322,7 +1332,7 @@ function kt(e, t) {
|
|
|
1322
1332
|
}
|
|
1323
1333
|
return null;
|
|
1324
1334
|
}
|
|
1325
|
-
function
|
|
1335
|
+
function jt(e, t) {
|
|
1326
1336
|
return t ? `${e}${e.includes("?") ? "&" : "?"}CMCD=${encodeURIComponent(`sid="${t}"`)}` : e;
|
|
1327
1337
|
}
|
|
1328
1338
|
//#endregion
|
|
@@ -1339,13 +1349,13 @@ function W(e, t = Date.now()) {
|
|
|
1339
1349
|
}
|
|
1340
1350
|
//#endregion
|
|
1341
1351
|
//#region src/core/drm/xhrBody.ts
|
|
1342
|
-
var
|
|
1343
|
-
function
|
|
1352
|
+
var Mt = 4096;
|
|
1353
|
+
function Nt(e) {
|
|
1344
1354
|
if (!e || typeof e != "object") return;
|
|
1345
1355
|
let { response: t } = e;
|
|
1346
1356
|
if (typeof t == "string") return t;
|
|
1347
1357
|
let n;
|
|
1348
|
-
if (Object.prototype.toString.call(t) === "[object ArrayBuffer]" ? n = new Uint8Array(t) : ArrayBuffer.isView(t) && (n = new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), !(!n || n.byteLength === 0 || n.byteLength >
|
|
1358
|
+
if (Object.prototype.toString.call(t) === "[object ArrayBuffer]" ? n = new Uint8Array(t) : ArrayBuffer.isView(t) && (n = new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), !(!n || n.byteLength === 0 || n.byteLength > Mt)) try {
|
|
1349
1359
|
return new TextDecoder().decode(n);
|
|
1350
1360
|
} catch {
|
|
1351
1361
|
return;
|
|
@@ -1353,7 +1363,7 @@ function Mt(e) {
|
|
|
1353
1363
|
}
|
|
1354
1364
|
//#endregion
|
|
1355
1365
|
//#region src/core/engine/prefetch.ts
|
|
1356
|
-
var
|
|
1366
|
+
var Pt = 15e3, Ft = 5e3, It = 6, Lt = 4e3, Rt = 2;
|
|
1357
1367
|
function G(e) {
|
|
1358
1368
|
try {
|
|
1359
1369
|
let t = new URL(e);
|
|
@@ -1362,7 +1372,7 @@ function G(e) {
|
|
|
1362
1372
|
return e;
|
|
1363
1373
|
}
|
|
1364
1374
|
}
|
|
1365
|
-
var
|
|
1375
|
+
var zt = class {
|
|
1366
1376
|
cmcd;
|
|
1367
1377
|
entries = /* @__PURE__ */ new Map();
|
|
1368
1378
|
keyed = /* @__PURE__ */ new Set();
|
|
@@ -1394,17 +1404,17 @@ var Rt = class {
|
|
|
1394
1404
|
let r = G(e);
|
|
1395
1405
|
if (this.entries.has(r)) return;
|
|
1396
1406
|
let i = this.perTrack.get(t) ?? 0;
|
|
1397
|
-
i >=
|
|
1407
|
+
i >= It || (this.perTrack.set(t, i + 1), this.start(r, this.withCmcd(e, t, n), !1, Pt), this.stats.started += 1);
|
|
1398
1408
|
}
|
|
1399
1409
|
prefetchHint(e, t) {
|
|
1400
1410
|
let n = G(e);
|
|
1401
1411
|
if (this.entries.has(n)) return;
|
|
1402
1412
|
let r = this.hints.get(t) ?? [];
|
|
1403
|
-
for (; r.length >=
|
|
1413
|
+
for (; r.length >= Rt;) {
|
|
1404
1414
|
let e = r.shift();
|
|
1405
1415
|
e !== void 0 && this.drop(e) && (this.stats.hintDropped += 1);
|
|
1406
1416
|
}
|
|
1407
|
-
r.push(n), this.hints.set(t, r), this.start(n, this.withCmcd(e, t, "media"), !0,
|
|
1417
|
+
r.push(n), this.hints.set(t, r), this.start(n, this.withCmcd(e, t, "media"), !0, Lt), this.stats.hintStarted += 1;
|
|
1408
1418
|
}
|
|
1409
1419
|
dropHints(e) {
|
|
1410
1420
|
for (let t of this.hints.get(e) ?? []) this.drop(t) && (this.stats.hintDropped += 1);
|
|
@@ -1457,14 +1467,14 @@ var Rt = class {
|
|
|
1457
1467
|
}
|
|
1458
1468
|
}
|
|
1459
1469
|
};
|
|
1460
|
-
function
|
|
1470
|
+
function Bt(t, n) {
|
|
1461
1471
|
let r = typeof n == "function" ? n : e.DefaultConfig?.loader;
|
|
1462
1472
|
if (typeof r != "function") return;
|
|
1463
1473
|
class i extends r {
|
|
1464
1474
|
served = !1;
|
|
1465
1475
|
cancelled = !1;
|
|
1466
1476
|
entry;
|
|
1467
|
-
stats =
|
|
1477
|
+
stats = Vt();
|
|
1468
1478
|
load(e, n, r) {
|
|
1469
1479
|
let i = e.rangeEnd ? void 0 : t.take(e.url);
|
|
1470
1480
|
if (!i) {
|
|
@@ -1476,7 +1486,7 @@ function zt(t, n) {
|
|
|
1476
1486
|
i.hint ? t.stats.hintFailed += 1 : t.stats.failed += 1;
|
|
1477
1487
|
}, s = () => {
|
|
1478
1488
|
!this.cancelled && this.served && (i.abort.abort(), o(), this.served = !1, this.entry = void 0, super.load(e, n, r));
|
|
1479
|
-
}, c = n?.loadPolicy, l = c?.maxTimeToFirstByteMs ||
|
|
1489
|
+
}, c = n?.loadPolicy, l = c?.maxTimeToFirstByteMs || Ft, u = setTimeout(s, l);
|
|
1480
1490
|
i.headers.then(() => {
|
|
1481
1491
|
clearTimeout(u);
|
|
1482
1492
|
let e = c?.maxLoadTimeMs;
|
|
@@ -1509,7 +1519,7 @@ function zt(t, n) {
|
|
|
1509
1519
|
}
|
|
1510
1520
|
return i;
|
|
1511
1521
|
}
|
|
1512
|
-
function
|
|
1522
|
+
function Vt() {
|
|
1513
1523
|
return {
|
|
1514
1524
|
aborted: !1,
|
|
1515
1525
|
loaded: 0,
|
|
@@ -1533,10 +1543,10 @@ function Bt() {
|
|
|
1533
1543
|
}
|
|
1534
1544
|
};
|
|
1535
1545
|
}
|
|
1536
|
-
function
|
|
1546
|
+
function Ht(e) {
|
|
1537
1547
|
return e === "audio" ? "audio" : "main";
|
|
1538
1548
|
}
|
|
1539
|
-
function
|
|
1549
|
+
function Ut(e, t) {
|
|
1540
1550
|
let n = [];
|
|
1541
1551
|
t.initSegment?.url && !t.initSegment.data && n.push({
|
|
1542
1552
|
url: t.initSegment.url,
|
|
@@ -1553,7 +1563,7 @@ function Ht(e, t) {
|
|
|
1553
1563
|
});
|
|
1554
1564
|
return n;
|
|
1555
1565
|
}
|
|
1556
|
-
function
|
|
1566
|
+
function Wt(e) {
|
|
1557
1567
|
let t = e, n = t?.preloadHint;
|
|
1558
1568
|
if (!n || !t?.url || n.TYPE !== "PART" || n["BYTERANGE-START"] !== void 0 || n["BYTERANGE-LENGTH"] !== void 0) return null;
|
|
1559
1569
|
let r = n.URI;
|
|
@@ -1571,15 +1581,15 @@ function K(e, t) {
|
|
|
1571
1581
|
}
|
|
1572
1582
|
//#endregion
|
|
1573
1583
|
//#region src/core/engine/hls.ts
|
|
1574
|
-
function
|
|
1584
|
+
function Gt() {
|
|
1575
1585
|
return e.isSupported();
|
|
1576
1586
|
}
|
|
1577
|
-
var
|
|
1578
|
-
function
|
|
1587
|
+
var Kt = 3, qt = 1e6, Jt = 20, Yt = 1e4, Xt = 3, Zt = 5, Qt = 3, $t = 1e4, en = 3e4, tn = 12e3, nn = 3e3, rn = .02, an = 6e3, on = .5, sn = 3, cn = .5, ln = 1.1, un = .25, dn = 5e3, fn = 4e3, pn = 2, mn = 5, hn = 2, gn = 2, _n = 4, vn = 4, yn = 2e3, bn = 3e4, xn = 1, Sn = 2, Cn = .5, wn = .6, Tn = 2, En = 1.5, Dn = 1e4, On = 18e4, kn = .5, An = 2;
|
|
1588
|
+
function jn(e) {
|
|
1579
1589
|
let t = e.config ?? {};
|
|
1580
1590
|
return t.capLevelToPlayerSize === !0 || t.capLevelOnFPSDrop === !0;
|
|
1581
1591
|
}
|
|
1582
|
-
var q = 8,
|
|
1592
|
+
var q = 8, Mn = 12e4, Nn = 6e4;
|
|
1583
1593
|
function J(e, t, n) {
|
|
1584
1594
|
if (n <= 0 || t < 0 || t >= e.length) return t;
|
|
1585
1595
|
let r = (t, n) => e[t].width === e[n].width && e[t].height === e[n].height, i = (t) => {
|
|
@@ -1592,8 +1602,8 @@ function J(e, t, n) {
|
|
|
1592
1602
|
function Y() {
|
|
1593
1603
|
return typeof self < "u" && self.devicePixelRatio > 0 ? self.devicePixelRatio : 1;
|
|
1594
1604
|
}
|
|
1595
|
-
var
|
|
1596
|
-
function
|
|
1605
|
+
var Pn = .2, Fn = 30, In = 2, Ln = 2, Rn = 2, zn = 9, Bn = .5, Vn = 64, Hn = 1e4, Un = 8, Wn = .6, Gn = .4, Kn = .4, qn = 2, Jn = 6e4, X = .5, Yn = 3.5, Xn = 300;
|
|
1606
|
+
function Z(e) {
|
|
1597
1607
|
return (e?.part ?? e?.frag)?.stats;
|
|
1598
1608
|
}
|
|
1599
1609
|
function Zn() {
|
|
@@ -1610,8 +1620,8 @@ function Qn(e) {
|
|
|
1610
1620
|
delete e.liveSyncDuration, delete e.liveMaxLatencyDuration;
|
|
1611
1621
|
return;
|
|
1612
1622
|
}
|
|
1613
|
-
e.liveSyncDuration ??=
|
|
1614
|
-
let t = Math.max(12, e.liveSyncDuration +
|
|
1623
|
+
e.liveSyncDuration ??= Rn;
|
|
1624
|
+
let t = Math.max(12, e.liveSyncDuration + zn);
|
|
1615
1625
|
(e.liveMaxLatencyDuration == null || e.liveMaxLatencyDuration <= e.liveSyncDuration) && (e.liveMaxLatencyDuration = t), $n(e, e.liveSyncDuration);
|
|
1616
1626
|
}
|
|
1617
1627
|
function $n(e, t) {
|
|
@@ -1771,7 +1781,7 @@ var er = class {
|
|
|
1771
1781
|
}
|
|
1772
1782
|
this.loadSuspended = !0;
|
|
1773
1783
|
}
|
|
1774
|
-
},
|
|
1784
|
+
}, dn));
|
|
1775
1785
|
}
|
|
1776
1786
|
resumeLoading() {
|
|
1777
1787
|
if (this.pauseSuspendTimer &&= (clearTimeout(this.pauseSuspendTimer), null), this.resetChaseWindow(), this.resetFrameDropWindow(), this.loadSuspended && (this.loadSuspended = !1, !this.stopped && this.hls)) {
|
|
@@ -1803,7 +1813,7 @@ var er = class {
|
|
|
1803
1813
|
let t = e.liveSyncPosition;
|
|
1804
1814
|
if (typeof t != "number" || !Number.isFinite(t)) return;
|
|
1805
1815
|
let { video: n } = this.deps;
|
|
1806
|
-
n.currentTime <= t +
|
|
1816
|
+
n.currentTime <= t + Bn || (n.currentTime = t);
|
|
1807
1817
|
}
|
|
1808
1818
|
reanchorPartTimeline(e, t) {
|
|
1809
1819
|
let { frag: n, part: r } = t;
|
|
@@ -1815,7 +1825,7 @@ var er = class {
|
|
|
1815
1825
|
let o = n.sn, s = i.fragments.find((e) => e && e.sn === o) ?? (i.fragmentHint?.sn === o ? i.fragmentHint : void 0);
|
|
1816
1826
|
if (!s) return;
|
|
1817
1827
|
let c = a.startPTS - s.start;
|
|
1818
|
-
if (!(!Number.isFinite(c) || Math.abs(c) <
|
|
1828
|
+
if (!(!Number.isFinite(c) || Math.abs(c) < rn)) {
|
|
1819
1829
|
for (let e of i.fragments) e && e.setStart(e.start + c);
|
|
1820
1830
|
i.fragmentHint?.setStart(i.fragmentHint.start + c), this.deps.debug === !0 && console.info(`havik-player: LL-HLS timeline re-anchored by ${c >= 0 ? "+" : ""}${c.toFixed(3)}s at sn ${n.sn} (level ${n.level})`);
|
|
1821
1831
|
}
|
|
@@ -1843,7 +1853,7 @@ var er = class {
|
|
|
1843
1853
|
videoEncryptionScheme: N.scheme,
|
|
1844
1854
|
audioEncryptionScheme: N.scheme
|
|
1845
1855
|
},
|
|
1846
|
-
...
|
|
1856
|
+
...M() ? { requestMediaKeySystemAccessFunc: Ke(t) } : {},
|
|
1847
1857
|
licenseXhrSetup: (e, t) => {
|
|
1848
1858
|
let o = performance.now(), s = () => {
|
|
1849
1859
|
e.open("POST", this.licenseUrl ?? t, !0), e.setRequestHeader("x-api-key", r.apiKey), e.setRequestHeader("X-Match-Urn", n.matchUrn), e.setRequestHeader("X-Device-Id", i), a && e.setRequestHeader("X-User-Id", a), this.licenseRequested = !0, e.addEventListener("loadend", () => {
|
|
@@ -1855,7 +1865,7 @@ var er = class {
|
|
|
1855
1865
|
return;
|
|
1856
1866
|
}
|
|
1857
1867
|
let l = this.hls, u, d = new Promise((e) => {
|
|
1858
|
-
u = setTimeout(() => e(void 0),
|
|
1868
|
+
u = setTimeout(() => e(void 0), $t);
|
|
1859
1869
|
});
|
|
1860
1870
|
return Promise.race([c().catch(() => void 0), d]).finally(() => clearTimeout(u)).then((e) => {
|
|
1861
1871
|
if (!this.hls || this.hls !== l) throw Error("havik-player: engine torn down during refresh");
|
|
@@ -1873,10 +1883,10 @@ var er = class {
|
|
|
1873
1883
|
this.prefetch?.destroy(), this.prefetch = null;
|
|
1874
1884
|
let p = !1, m = !1, h = u && this.deps.mediaDuringKey !== !1, g = this.deps.preloadHints !== !1;
|
|
1875
1885
|
if ((h || g) && !f.fLoader) {
|
|
1876
|
-
let e = new
|
|
1886
|
+
let e = new zt({
|
|
1877
1887
|
sessionId: n.analytics?.sid,
|
|
1878
1888
|
contentId: n.matchUrn
|
|
1879
|
-
}), t =
|
|
1889
|
+
}), t = Bt(e, f.loader);
|
|
1880
1890
|
t && (this.prefetch = e, p = h, m = g, f.fLoader = t);
|
|
1881
1891
|
}
|
|
1882
1892
|
Qn(f), this.catchUpRate = typeof f.maxLiveSyncPlaybackRate == "number" ? f.maxLiveSyncPlaybackRate : 1, this.catchUpEngaged = !1, this.catchUpRate > 1 && (f.maxLiveSyncPlaybackRate = 1), this.sizeCapManaged = f.capLevelToPlayerSize !== !0, this.fpsCapManaged = !(c && "capLevelOnFPSDrop" in c), this.loadStarted = f.autoStartLoad !== !1;
|
|
@@ -1886,15 +1896,15 @@ var er = class {
|
|
|
1886
1896
|
}), _.on(e.Events.FRAG_BUFFERED, (e, t) => {
|
|
1887
1897
|
t?.frag?.type === "main" && (this.kickKind !== "dead" && this.clearKick(), (this.mediaRecoveries > 0 || this.networkRecoveries > 0 || this.licenseRecoveries > 0 || this.starvationKicks > 0 || this.starvationRebuilds > 0) && !this.recoveryResetTimer && (this.recoveryResetTimer = setTimeout(() => {
|
|
1888
1898
|
this.mediaRecoveries = 0, this.networkRecoveries = 0, this.licenseRecoveries = 0, this.starvationKicks = 0, this.starvationRebuilds = 0, this.recoveryResetTimer = null;
|
|
1889
|
-
},
|
|
1899
|
+
}, en)));
|
|
1890
1900
|
}), _.on(e.Events.FRAG_LOADING, (e, t) => {
|
|
1891
1901
|
t?.frag?.type === "main" && (this.lastFragLoadingMs = Date.now());
|
|
1892
1902
|
}), _.on(e.Events.FRAG_LOADED, (e, t) => {
|
|
1893
1903
|
t?.frag?.type === "main" && (this.mainFragsSinceTick += 1, this.bwFragsLoaded += 1, this.maybeRememberBandwidth(!1));
|
|
1894
|
-
let n = t?.frag, r =
|
|
1904
|
+
let n = t?.frag, r = Z(t), i = r?.loaded;
|
|
1895
1905
|
typeof i == "number" && (this.bytesLoaded += i), !this.reportedFirstBytes && typeof i == "number" && i > 0 && (this.reportedFirstBytes = !0, l({ type: "firstBytes" }));
|
|
1896
1906
|
let a = r?.loading;
|
|
1897
|
-
a && a.end > 0 && a.start > 0 && (this.requestCount += 1, this.requestTimesMs.push(Math.max(0, Math.round(a.end - a.start))), this.requestTimesMs.length >
|
|
1907
|
+
a && a.end > 0 && a.start > 0 && (this.requestCount += 1, this.requestTimesMs.push(Math.max(0, Math.round(a.end - a.start))), this.requestTimesMs.length > Vn && this.requestTimesMs.shift()), this.sampleHoldBack(t), this.sampleHeadroom(t);
|
|
1898
1908
|
let o = n?.url;
|
|
1899
1909
|
if (o) {
|
|
1900
1910
|
let e = ft(o);
|
|
@@ -1914,8 +1924,8 @@ var er = class {
|
|
|
1914
1924
|
let i = e;
|
|
1915
1925
|
if (!i?.live || !i.partList?.length || typeof i.edge != "number") return;
|
|
1916
1926
|
let a = n.buffered, o = a.length ? a.end(a.length - 1) : 0;
|
|
1917
|
-
if (i.edge - o >
|
|
1918
|
-
let s =
|
|
1927
|
+
if (i.edge - o > Kt * (i.partTarget || .5)) return;
|
|
1928
|
+
let s = Wt(e);
|
|
1919
1929
|
s && t.prefetchHint(s, r);
|
|
1920
1930
|
};
|
|
1921
1931
|
_.on(e.Events.LEVEL_LOADED, (e, t) => {
|
|
@@ -1927,15 +1937,15 @@ var er = class {
|
|
|
1927
1937
|
if (this.prefetch && p) {
|
|
1928
1938
|
let t = this.prefetch;
|
|
1929
1939
|
_.on(e.Events.KEY_LOADING, (e, n) => {
|
|
1930
|
-
let r = n?.frag, i =
|
|
1931
|
-
if (r && t.isActive(i)) for (let e of
|
|
1932
|
-
}), _.on(e.Events.KEY_LOADED, (e, n) => t.keyUsable(
|
|
1940
|
+
let r = n?.frag, i = Ht(r?.type);
|
|
1941
|
+
if (r && t.isActive(i)) for (let e of Ut(_, r)) t.prefetch(e.url, i, e.kind);
|
|
1942
|
+
}), _.on(e.Events.KEY_LOADED, (e, n) => t.keyUsable(Ht(n?.frag?.type)));
|
|
1933
1943
|
}
|
|
1934
1944
|
_.on(e.Events.KEY_LOADED, () => {
|
|
1935
1945
|
u && !this.reportedDrmReady && (this.reportedDrmReady = !0, l({ type: "drmReady" }));
|
|
1936
1946
|
}), this.endWatchdog && clearInterval(this.endWatchdog), this.endWatchdog = setInterval(() => {
|
|
1937
1947
|
this.checkEndStale(), this.checkStarvation(), this.updateCatchUpBand(), this.checkFutileChase(), this.adaptHoldBack(), this.reviewSizeCapHeadroom(), this.releaseStallCap(), this.checkFrameDrops();
|
|
1938
|
-
},
|
|
1948
|
+
}, nn), _.on(e.Events.LEVEL_SWITCHED, (e, t) => {
|
|
1939
1949
|
this.renditionSwitches += 1;
|
|
1940
1950
|
let n = this.lastLevelIndex >= 0 ? _.levels[this.lastLevelIndex] : void 0, r = _.levels[t.level];
|
|
1941
1951
|
n && r && r.bitrate !== n.bitrate && (r.bitrate > n.bitrate ? this.upshifts += 1 : this.downshifts += 1), this.lastLevelIndex = t.level, this.armFrameDropGrace(), l({
|
|
@@ -1996,8 +2006,8 @@ var er = class {
|
|
|
1996
2006
|
let e = this.hls, t = this.sizeCapCover();
|
|
1997
2007
|
if (!e || !t) return null;
|
|
1998
2008
|
let { cover: n, deviceRatio: r } = t, i = this.deps.sizeCapHeadroom, a = i == null || Number.isNaN(i);
|
|
1999
|
-
if (a && r >=
|
|
2000
|
-
if (a) return this.headroomUngated || this.headroomGranted ? J(e.levels, n,
|
|
2009
|
+
if (a && r >= Sn) return n;
|
|
2010
|
+
if (a) return this.headroomUngated || this.headroomGranted ? J(e.levels, n, xn) : n;
|
|
2001
2011
|
let o = i === Infinity ? e.levels.length : Math.max(0, Math.floor(i));
|
|
2002
2012
|
return J(e.levels, n, o);
|
|
2003
2013
|
}
|
|
@@ -2014,11 +2024,11 @@ var er = class {
|
|
|
2014
2024
|
return;
|
|
2015
2025
|
}
|
|
2016
2026
|
this.capTimer && clearTimeout(this.capTimer);
|
|
2017
|
-
let t = e > this.sizeCapLevel ?
|
|
2027
|
+
let t = e > this.sizeCapLevel ? yn : bn;
|
|
2018
2028
|
this.capTimer = setTimeout(() => {
|
|
2019
2029
|
this.capTimer = null;
|
|
2020
2030
|
let n = this.computeSizeCapTarget();
|
|
2021
|
-
n === e || t ===
|
|
2031
|
+
n === e || t === bn && n != null && n < e ? this.applySizeCap() : this.onMediaResize();
|
|
2022
2032
|
}, t);
|
|
2023
2033
|
}
|
|
2024
2034
|
measureLadder(e) {
|
|
@@ -2045,7 +2055,7 @@ var er = class {
|
|
|
2045
2055
|
}
|
|
2046
2056
|
defaultHeadroomApplies() {
|
|
2047
2057
|
let e = this.deps.sizeCapHeadroom;
|
|
2048
|
-
return e != null && !Number.isNaN(e) || this.headroomUngated ? !1 : Y() <
|
|
2058
|
+
return e != null && !Number.isNaN(e) || this.headroomUngated ? !1 : Y() < Sn;
|
|
2049
2059
|
}
|
|
2050
2060
|
applySizeCapUnlessPending() {
|
|
2051
2061
|
this.capTimer || this.applySizeCap();
|
|
@@ -2054,7 +2064,7 @@ var er = class {
|
|
|
2054
2064
|
if (!this.sizeCapManaged || !this.defaultHeadroomApplies() || e.frag?.type !== "main" || typeof e.frag.level != "number" || typeof document < "u" && document.hidden) return;
|
|
2055
2065
|
let t = e.part ? e.part.duration : this.detectedLowLatency ? 0 : e.frag.duration;
|
|
2056
2066
|
if (typeof t != "number" || !(t > 0)) return;
|
|
2057
|
-
let n =
|
|
2067
|
+
let n = Z(e)?.loading;
|
|
2058
2068
|
if (!n || !(n.start > 0) || !(n.end >= n.start)) return;
|
|
2059
2069
|
let r = this.hls?.levels?.[e.frag.level]?.bitrate;
|
|
2060
2070
|
if (!(typeof r == "number" && r > 0)) return;
|
|
@@ -2067,7 +2077,7 @@ var er = class {
|
|
|
2067
2077
|
}
|
|
2068
2078
|
onPlaybackStall(e) {
|
|
2069
2079
|
let t = Date.now();
|
|
2070
|
-
this.deps.video.seeking || !this.playingSince || t - this.playingSince <
|
|
2080
|
+
this.deps.video.seeking || !this.playingSince || t - this.playingSince < Dn || (this.lastStallAt = t, this.stepStallCapDown(t, e), this.headroomGranted && (this.headroomGranted = !1, this.applySizeCapUnlessPending()));
|
|
2071
2081
|
}
|
|
2072
2082
|
stallCapLevel(e) {
|
|
2073
2083
|
if (this.stallCapBitrate == null) return -1;
|
|
@@ -2078,7 +2088,7 @@ var er = class {
|
|
|
2078
2088
|
}
|
|
2079
2089
|
stepStallCapDown(e, t) {
|
|
2080
2090
|
let n = this.hls;
|
|
2081
|
-
if (!n || !this.stallCapEnabled ||
|
|
2091
|
+
if (!n || !this.stallCapEnabled || jn(n) || !n.autoLevelEnabled || typeof t == "number" && t >= kn || this.isLiveEdgeWait(n, t ?? 0)) return;
|
|
2082
2092
|
this.stallCapBitrate != null && (this.stallCapSince = e);
|
|
2083
2093
|
let r = Math.max(n.levels[n.currentLevel]?.bitrate ?? 0, n.levels[n.loadLevel]?.bitrate ?? 0);
|
|
2084
2094
|
if (!(r > 0)) return;
|
|
@@ -2089,7 +2099,7 @@ var er = class {
|
|
|
2089
2099
|
let n = e.latestLevelDetails;
|
|
2090
2100
|
if (!n?.live) return !1;
|
|
2091
2101
|
let r = n.partTarget || n.targetduration;
|
|
2092
|
-
return !(r > 0) || !(n.edge > 0) ? !1 : n.edge - (this.deps.video.currentTime + t) <
|
|
2102
|
+
return !(r > 0) || !(n.edge > 0) ? !1 : n.edge - (this.deps.video.currentTime + t) < An * r;
|
|
2093
2103
|
}
|
|
2094
2104
|
releaseStallCap() {
|
|
2095
2105
|
let e = this.hls, t = Date.now(), n = this.stallCapTickAt;
|
|
@@ -2098,7 +2108,7 @@ var er = class {
|
|
|
2098
2108
|
n && (this.stallCapSince += t - Math.max(n, this.stallCapSince));
|
|
2099
2109
|
return;
|
|
2100
2110
|
}
|
|
2101
|
-
if (t - this.stallCapSince <
|
|
2111
|
+
if (t - this.stallCapSince < On) return;
|
|
2102
2112
|
let r = this.stallCapBitrate, i = e.levels.map((e) => e.bitrate).filter((e) => e > r).sort((e, t) => e - t)[0];
|
|
2103
2113
|
this.stallCapBitrate = i ?? null, this.stallCapSince = t, this.pushCap();
|
|
2104
2114
|
}
|
|
@@ -2111,26 +2121,26 @@ var er = class {
|
|
|
2111
2121
|
this.headroomGranted = !1, this.headroomSamples = [];
|
|
2112
2122
|
return;
|
|
2113
2123
|
}
|
|
2114
|
-
this.headroomSamples = this.headroomSamples.filter((t) => t.t >= e -
|
|
2124
|
+
this.headroomSamples = this.headroomSamples.filter((t) => t.t >= e - Hn);
|
|
2115
2125
|
let r = this.headroomEarned(n, e);
|
|
2116
|
-
r !== this.headroomGranted && (r || (this.headroomRegrantAt = e +
|
|
2126
|
+
r !== this.headroomGranted && (r || (this.headroomRegrantAt = e + Nn), this.headroomGranted = r, this.applySizeCapUnlessPending());
|
|
2117
2127
|
}
|
|
2118
2128
|
headroomEarned(e, t) {
|
|
2119
|
-
if (t - this.lastStallAt <
|
|
2129
|
+
if (t - this.lastStallAt < Mn || !this.headroomGranted && t < this.headroomRegrantAt || !this.headroomGranted && this.headroomSamples.length < q) return !1;
|
|
2120
2130
|
let n = e.levels, r = this.sizeCapCoverLevel();
|
|
2121
2131
|
if (r == null) return this.headroomGranted;
|
|
2122
|
-
let i = J(n, r,
|
|
2132
|
+
let i = J(n, r, xn);
|
|
2123
2133
|
if (i === r) return this.headroomGranted;
|
|
2124
|
-
let a = n[i]?.bitrate, o = e.bandwidthEstimate, s = this.headroomGranted ?
|
|
2134
|
+
let a = n[i]?.bitrate, o = e.bandwidthEstimate, s = this.headroomGranted ? En : Tn;
|
|
2125
2135
|
if (!(a > 0) || !(o >= s * a)) return !1;
|
|
2126
2136
|
let c = (e) => K([...e].sort((e, t) => e - t), 90);
|
|
2127
2137
|
if (this.headroomGranted) {
|
|
2128
2138
|
let e = this.headroomSamples.filter((e) => e.bitrate >= a).map((e) => e.ratio);
|
|
2129
|
-
return e.length < q || c(e) <=
|
|
2139
|
+
return e.length < q || c(e) <= wn;
|
|
2130
2140
|
}
|
|
2131
2141
|
let l = [];
|
|
2132
2142
|
for (let e of this.headroomSamples) e.bitrate < a && l.push(e.ratio * (a / e.bitrate));
|
|
2133
|
-
return l.length >= q && c(l) <=
|
|
2143
|
+
return l.length >= q && c(l) <= Cn;
|
|
2134
2144
|
}
|
|
2135
2145
|
applySizeCap() {
|
|
2136
2146
|
if (!this.sizeCapManaged) return;
|
|
@@ -2205,7 +2215,7 @@ var er = class {
|
|
|
2205
2215
|
let t = e.currentLevel >= 0 ? e.levels[e.currentLevel] : void 0;
|
|
2206
2216
|
t && (n.levelHeight = t.height);
|
|
2207
2217
|
let r = e.autoLevelCapping, i = r >= 0 ? e.levels[r] : void 0;
|
|
2208
|
-
i && i.height > 0 && (n.maxLevelHeight = i.height, !
|
|
2218
|
+
i && i.height > 0 && (n.maxLevelHeight = i.height, !jn(e) && r === this.pushedCapLevel && this.pushedCapReason && (n.capReason = this.pushedCapReason)), t?.videoCodec && (n.videoCodec = t.videoCodec), t?.audioCodec && (n.audioCodec = t.audioCodec), t && typeof t.bitrate == "number" && (n.renditionBitrateKbps = Math.round(t.bitrate / 1e3)), typeof t?.details?.live == "boolean" && (n.isLive = t.details.live, typeof e.liveSyncPosition == "number" && (n.atLiveEdge = this.deps.video.currentTime >= e.liveSyncPosition - 1.5));
|
|
2209
2219
|
}
|
|
2210
2220
|
return n;
|
|
2211
2221
|
}
|
|
@@ -2233,7 +2243,7 @@ var er = class {
|
|
|
2233
2243
|
return;
|
|
2234
2244
|
}
|
|
2235
2245
|
let e = Date.now() - this.lastAdvanceMs;
|
|
2236
|
-
!this.chaseSuspended && e >
|
|
2246
|
+
!this.chaseSuspended && e > an && this.suspendChasing(), e > tn && this.emitEnded("stalled");
|
|
2237
2247
|
}
|
|
2238
2248
|
resetStarvationWindow() {
|
|
2239
2249
|
this.starvedTicks = 0, this.deadTicks = 0, this.mainFragsSinceTick = 0, this.recentMainFrags = [];
|
|
@@ -2248,7 +2258,7 @@ var er = class {
|
|
|
2248
2258
|
this.resetStarvationWindow();
|
|
2249
2259
|
return;
|
|
2250
2260
|
}
|
|
2251
|
-
let n = Date.now(), r = this.lastAdvanceMs !== 0 && n - this.lastAdvanceMs <
|
|
2261
|
+
let n = Date.now(), r = this.lastAdvanceMs !== 0 && n - this.lastAdvanceMs < an, i = this.lastFragLoadingMs !== 0 && n - this.lastFragLoadingMs > fn, a = t.readyState < HTMLMediaElement.HAVE_FUTURE_DATA && !t.paused, { totalFrames: o, dropped: s } = R(t), c = o - s, l = c !== this.starvedFrames;
|
|
2252
2262
|
if (this.starvedFrames = c, !a || l) {
|
|
2253
2263
|
(t.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA || l) && this.clearKick(), this.resetStarvationWindow();
|
|
2254
2264
|
return;
|
|
@@ -2257,12 +2267,12 @@ var er = class {
|
|
|
2257
2267
|
this.resetStarvationWindow();
|
|
2258
2268
|
return;
|
|
2259
2269
|
}
|
|
2260
|
-
if (this.kickPending && (this.kickKind === "dead" || i) && (this.kickTicks += 1), this.starvedTicks = i ? this.starvedTicks + 1 : 0, this.deadTicks += 1, this.recentMainFrags.push(this.mainFragsSinceTick), this.mainFragsSinceTick = 0, this.recentMainFrags.length >
|
|
2270
|
+
if (this.kickPending && (this.kickKind === "dead" || i) && (this.kickTicks += 1), this.starvedTicks = i ? this.starvedTicks + 1 : 0, this.deadTicks += 1, this.recentMainFrags.push(this.mainFragsSinceTick), this.mainFragsSinceTick = 0, this.recentMainFrags.length > _n && this.recentMainFrags.shift(), this.clearRecoveryReset(), this.kickPending && this.kickTicks >= hn && (this.clearKick(), this.starvationRebuilds < gn)) {
|
|
2261
2271
|
this.starvationRebuilds += 1, this.resetStarvationWindow(), this.clearRecoveryReset(), console.warn("havik-player: restarting the load did not resume video (the wedge is in hls.js state that only a rebuild clears) — rebuilding the player"), this.rebuildInstance("starvation rebuild");
|
|
2262
2272
|
return;
|
|
2263
2273
|
}
|
|
2264
|
-
let u = i && this.starvedTicks >=
|
|
2265
|
-
if ((u || d) && (this.resetStarvationWindow(), !(this.starvationKicks >=
|
|
2274
|
+
let u = i && this.starvedTicks >= pn, d = !i && this.deadTicks >= _n && this.recentMainFrags.reduce((e, t) => e + t, 0) >= vn;
|
|
2275
|
+
if ((u || d) && (this.resetStarvationWindow(), !(this.starvationKicks >= mn))) {
|
|
2266
2276
|
this.starvationKicks += 1, this.kickPending = !0, this.kickTicks = 0, this.kickKind = d ? "dead" : "quiet", this.clearRecoveryReset(), console.warn(d ? "havik-player: video starved while hls.js keeps loading media it never plays (dead pipeline at the live edge) — restarting the load" : "havik-player: video starved while the live playlist advances (wedged hls.js fragment pipeline) — restarting the load");
|
|
2267
2277
|
try {
|
|
2268
2278
|
e.stopLoad(), e.startLoad(-1);
|
|
@@ -2277,7 +2287,7 @@ var er = class {
|
|
|
2277
2287
|
let t = e.latency, n = e.targetLatency;
|
|
2278
2288
|
if (typeof t != "number" || typeof n != "number" || !Number.isFinite(t)) return;
|
|
2279
2289
|
let r = t - n;
|
|
2280
|
-
!this.catchUpEngaged && r >
|
|
2290
|
+
!this.catchUpEngaged && r > on ? this.catchUpEngaged = !0 : this.catchUpEngaged && r <= on && this.deps.video.playbackRate === 1 && (this.catchUpEngaged = !1);
|
|
2281
2291
|
let i = this.catchUpEngaged ? this.catchUpRate : 1;
|
|
2282
2292
|
e.config.maxLiveSyncPlaybackRate !== i && (e.config.maxLiveSyncPlaybackRate = i);
|
|
2283
2293
|
}
|
|
@@ -2290,7 +2300,7 @@ var er = class {
|
|
|
2290
2300
|
}), n < 0 ? 0 : n;
|
|
2291
2301
|
}
|
|
2292
2302
|
armFrameDropGrace() {
|
|
2293
|
-
this.fpsGraceTicks > 0 || (this.fpsGraceTicks =
|
|
2303
|
+
this.fpsGraceTicks > 0 || (this.fpsGraceTicks = Ln, this.fpsBadTicks = 0);
|
|
2294
2304
|
}
|
|
2295
2305
|
resetFrameDropWindow() {
|
|
2296
2306
|
this.fpsLastFrames = -1, this.fpsLastDropped = -1, this.fpsBadTicks = 0;
|
|
@@ -2302,7 +2312,7 @@ var er = class {
|
|
|
2302
2312
|
return;
|
|
2303
2313
|
}
|
|
2304
2314
|
let { totalFrames: n, dropped: r } = R(t), i = this.fpsLastFrames < 0, a = n - this.fpsLastFrames, o = r - this.fpsLastDropped;
|
|
2305
|
-
if (this.fpsLastFrames = n, this.fpsLastDropped = r, i || a <
|
|
2315
|
+
if (this.fpsLastFrames = n, this.fpsLastDropped = r, i || a < Fn || o < 0) {
|
|
2306
2316
|
this.fpsBadTicks = 0;
|
|
2307
2317
|
return;
|
|
2308
2318
|
}
|
|
@@ -2310,11 +2320,11 @@ var er = class {
|
|
|
2310
2320
|
--this.fpsGraceTicks, this.fpsBadTicks = 0;
|
|
2311
2321
|
return;
|
|
2312
2322
|
}
|
|
2313
|
-
if (o <=
|
|
2323
|
+
if (o <= Pn * a) {
|
|
2314
2324
|
this.fpsBadTicks = 0;
|
|
2315
2325
|
return;
|
|
2316
2326
|
}
|
|
2317
|
-
if (this.fpsBadTicks += 1, this.fpsBadTicks <
|
|
2327
|
+
if (this.fpsBadTicks += 1, this.fpsBadTicks < In) return;
|
|
2318
2328
|
this.fpsBadTicks = 0;
|
|
2319
2329
|
let s = e.levels, c = s[e.currentLevel];
|
|
2320
2330
|
if (!c) return;
|
|
@@ -2331,22 +2341,22 @@ var er = class {
|
|
|
2331
2341
|
return;
|
|
2332
2342
|
}
|
|
2333
2343
|
let n = e.latency, r = t.playbackRate, i = e.config.maxLiveSyncPlaybackRate;
|
|
2334
|
-
if (!(!t.paused && typeof i == "number" && i > 1 && r >= Math.min(
|
|
2344
|
+
if (!(!t.paused && typeof i == "number" && i > 1 && r >= Math.min(ln, i) && r <= i && typeof n == "number" && Number.isFinite(n))) {
|
|
2335
2345
|
this.resetChaseWindow();
|
|
2336
2346
|
return;
|
|
2337
2347
|
}
|
|
2338
|
-
if (this.chaseLatency < 0 || this.chaseLatency - n >=
|
|
2348
|
+
if (this.chaseLatency < 0 || this.chaseLatency - n >= cn) {
|
|
2339
2349
|
this.chaseLatency = n, this.chaseTicks = 0;
|
|
2340
2350
|
return;
|
|
2341
2351
|
}
|
|
2342
|
-
if (this.chaseTicks += 1, this.chaseTicks <
|
|
2352
|
+
if (this.chaseTicks += 1, this.chaseTicks < sn) return;
|
|
2343
2353
|
this.resetChaseWindow();
|
|
2344
2354
|
let a = typeof e.config.liveMaxLatencyDuration == "number" ? e.config.liveMaxLatencyDuration : e.maxLatency;
|
|
2345
2355
|
if (!(a > 1)) return;
|
|
2346
2356
|
let o = e.targetLatency;
|
|
2347
2357
|
if (typeof o != "number" || !(o > 0)) return;
|
|
2348
2358
|
let s = Math.min(n, a - 1);
|
|
2349
|
-
s < o +
|
|
2359
|
+
s < o + un || (console.warn(`havik-player: catch-up at ${r}x not gaining on the live edge (latency ${n.toFixed(1)}s); holding at ${s.toFixed(1)}s`), this.liveRetargets += 1, e.targetLatency = s, this.deps.emit({
|
|
2350
2360
|
type: "livetargetchange",
|
|
2351
2361
|
change: {
|
|
2352
2362
|
targetSeconds: s,
|
|
@@ -2364,12 +2374,12 @@ var er = class {
|
|
|
2364
2374
|
let t = e.targetLatency;
|
|
2365
2375
|
if (this.holdBackBase < 0 && typeof t == "number" && t > 0 && (this.holdBackBase = t), this.holdBackBase < 0) return;
|
|
2366
2376
|
let n = Zn();
|
|
2367
|
-
if (!(n >=
|
|
2377
|
+
if (!(n >= Xn)) return;
|
|
2368
2378
|
let r = typeof t == "number" && t > 0 ? t : this.holdBackBase, i = Math.min(this.holdBackCeiling(e), this.holdBackBase + X);
|
|
2369
2379
|
i > r && (this.holdBackStepCount = 1, this.moveHoldBack(e, r, i, "connection-rtt", `connection rtt ${n} ms`));
|
|
2370
2380
|
}
|
|
2371
2381
|
holdBackCeiling(e) {
|
|
2372
|
-
let t = this.deps.adaptiveHoldBackCeiling, n = typeof t == "number" && Number.isFinite(t) ? t :
|
|
2382
|
+
let t = this.deps.adaptiveHoldBackCeiling, n = typeof t == "number" && Number.isFinite(t) ? t : Yn, r = typeof e.config.liveMaxLatencyDuration == "number" ? e.config.liveMaxLatencyDuration : e.maxLatency;
|
|
2373
2383
|
return r > 1 ? Math.min(n, r - 1) : n;
|
|
2374
2384
|
}
|
|
2375
2385
|
sampleHoldBack(e) {
|
|
@@ -2378,7 +2388,7 @@ var er = class {
|
|
|
2378
2388
|
if (t !== "main" && t !== "audio") return;
|
|
2379
2389
|
let n = e.part ? e.part.duration : this.detectedLowLatency ? 0 : e.frag?.duration;
|
|
2380
2390
|
if (typeof n != "number" || !(n > 0)) return;
|
|
2381
|
-
let r =
|
|
2391
|
+
let r = Z(e)?.loading;
|
|
2382
2392
|
if (!r || !(r.start > 0) || !(r.end > 0)) return;
|
|
2383
2393
|
let i = r.first > r.start ? r.first : r.end, a = Math.max(0, i - r.start) / (n * 1e3);
|
|
2384
2394
|
this.holdBackSamples.push({
|
|
@@ -2393,20 +2403,20 @@ var er = class {
|
|
|
2393
2403
|
this.holdBackSlowTicks = 0, this.holdBackFastSince = 0, this.holdBackSamples = [];
|
|
2394
2404
|
return;
|
|
2395
2405
|
}
|
|
2396
|
-
let t = Date.now(), n = t -
|
|
2406
|
+
let t = Date.now(), n = t - Hn, r = this.holdBackSamples, i = 0;
|
|
2397
2407
|
for (; i < r.length && r[i].t < n;) i += 1;
|
|
2398
2408
|
i > 0 && r.splice(0, i);
|
|
2399
2409
|
let a = e.targetLatency;
|
|
2400
2410
|
if (typeof a != "number" || !(a > 0)) return;
|
|
2401
2411
|
this.holdBackBase < 0 && (this.holdBackBase = a);
|
|
2402
2412
|
let o = this.holdBackBase, s = this.holdBackCeiling(e);
|
|
2403
|
-
if (r.length <
|
|
2413
|
+
if (r.length < Un) {
|
|
2404
2414
|
this.holdBackSlowTicks = 0;
|
|
2405
2415
|
return;
|
|
2406
2416
|
}
|
|
2407
2417
|
let c = r.map((e) => e.ratio).sort((e, t) => e - t), l = K(c, 95), u = K(c, 50), d = Math.round(l * 1e3);
|
|
2408
|
-
if (l >=
|
|
2409
|
-
if (this.holdBackFastSince = 0, this.holdBackSlowTicks += 1, this.holdBackSlowTicks <
|
|
2418
|
+
if (l >= Wn && u >= Gn) {
|
|
2419
|
+
if (this.holdBackFastSince = 0, this.holdBackSlowTicks += 1, this.holdBackSlowTicks < qn) return;
|
|
2410
2420
|
this.holdBackSlowTicks = 0;
|
|
2411
2421
|
let t = Math.ceil((s - o) / X), n = Math.ceil((a - o) / X - 1e-9);
|
|
2412
2422
|
if (n > this.holdBackStepCount && (this.holdBackStepCount = n), this.holdBackStepCount >= t) return;
|
|
@@ -2416,7 +2426,7 @@ var er = class {
|
|
|
2416
2426
|
this.moveHoldBack(e, a, r, "slow-fetches", `part fetches slow (first byte p50 ${Math.round(u * 1e3)} / p95 ${d} ms per 1 s of media)`);
|
|
2417
2427
|
return;
|
|
2418
2428
|
}
|
|
2419
|
-
if (this.holdBackSlowTicks = 0, l >=
|
|
2429
|
+
if (this.holdBackSlowTicks = 0, l >= Kn) {
|
|
2420
2430
|
this.holdBackFastSince = 0;
|
|
2421
2431
|
return;
|
|
2422
2432
|
}
|
|
@@ -2424,7 +2434,7 @@ var er = class {
|
|
|
2424
2434
|
this.holdBackFastSince = t;
|
|
2425
2435
|
return;
|
|
2426
2436
|
}
|
|
2427
|
-
if (t - this.holdBackFastSince <
|
|
2437
|
+
if (t - this.holdBackFastSince < Jn || (this.holdBackFastSince = t, this.holdBackStepCount === 0 || a !== this.holdBackApplied)) return;
|
|
2428
2438
|
--this.holdBackStepCount;
|
|
2429
2439
|
let f = Math.max(o, o + this.holdBackStepCount * X);
|
|
2430
2440
|
f >= a || this.moveHoldBack(e, a, f, "fast-fetches", `part fetches fast again (p95 first byte ${d} ms per 1 s of media)`);
|
|
@@ -2467,14 +2477,14 @@ var er = class {
|
|
|
2467
2477
|
} catch {}
|
|
2468
2478
|
}
|
|
2469
2479
|
startEstimate() {
|
|
2470
|
-
return this.deps.rememberBandwidth === !1 ?
|
|
2480
|
+
return this.deps.rememberBandwidth === !1 ? qt : Re() ?? qt;
|
|
2471
2481
|
}
|
|
2472
2482
|
maybeRememberBandwidth(e) {
|
|
2473
|
-
if (this.deps.rememberBandwidth === !1 || this.bwFragsLoaded <
|
|
2483
|
+
if (this.deps.rememberBandwidth === !1 || this.bwFragsLoaded < Jt) return;
|
|
2474
2484
|
let t = Date.now();
|
|
2475
|
-
if (!e && t - this.bwSavedAt <
|
|
2485
|
+
if (!e && t - this.bwSavedAt < Yt) return;
|
|
2476
2486
|
let n = this.hls?.bandwidthEstimate;
|
|
2477
|
-
typeof n != "number" || !Number.isFinite(n) || n <= 0 || (this.bwSavedAt = t,
|
|
2487
|
+
typeof n != "number" || !Number.isFinite(n) || n <= 0 || (this.bwSavedAt = t, ze(n));
|
|
2478
2488
|
}
|
|
2479
2489
|
destroy() {
|
|
2480
2490
|
if (this.maybeRememberBandwidth(!0), this.detachFrames?.(), this.detachFrames = null, this.prefetch?.destroy(), this.prefetch = null, this.clearRecoveryReset(), this.capTimer &&= (clearTimeout(this.capTimer), null), this.capObserver &&= (this.capObserver.disconnect(), null), this.unwatchDprChanges(), this.endWatchdog &&= (clearInterval(this.endWatchdog), null), this.onVisibility && typeof document < "u" && (document.removeEventListener("visibilitychange", this.onVisibility), this.onVisibility = null), this.onOffline && typeof window < "u" && (window.removeEventListener("offline", this.onOffline), this.onOffline = null), this.onOnline && typeof window < "u" && (window.removeEventListener("online", this.onOnline), this.onOnline = null), this.onSeeking &&= (this.deps.video.removeEventListener("seeking", this.onSeeking), null), this.onTimeUpdate &&= (this.deps.video.removeEventListener("timeupdate", this.onTimeUpdate), null), this.onPause &&= (this.deps.video.removeEventListener("pause", this.onPause), null), this.onPlay &&= (this.deps.video.removeEventListener("play", this.onPlay), null), this.pauseSuspendTimer &&= (clearTimeout(this.pauseSuspendTimer), null), this.networkRetryTimer &&= (clearTimeout(this.networkRetryTimer), null), this.licenseRetryTimer &&= (clearTimeout(this.licenseRetryTimer), null), this.hls) {
|
|
@@ -2492,7 +2502,7 @@ var er = class {
|
|
|
2492
2502
|
scheduleLicenseRetry(t) {
|
|
2493
2503
|
if (t.details !== e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED && t.details !== e.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) return !1;
|
|
2494
2504
|
let n = t.response?.code ?? 0;
|
|
2495
|
-
if (!(n === 0 || n === 408 || n === 429 || n >= 500) || this.licenseRecoveries >=
|
|
2505
|
+
if (!(n === 0 || n === 408 || n === 429 || n >= 500) || this.licenseRecoveries >= Qt) return !1;
|
|
2496
2506
|
this.licenseRecoveries += 1;
|
|
2497
2507
|
let r = Math.min(8e3, 500 * 2 ** (this.licenseRecoveries - 1));
|
|
2498
2508
|
return this.licenseRetryTimer = setTimeout(() => {
|
|
@@ -2528,7 +2538,7 @@ var er = class {
|
|
|
2528
2538
|
this.offlineHold = !0, this.networkRetryTimer &&= (clearTimeout(this.networkRetryTimer), null);
|
|
2529
2539
|
return;
|
|
2530
2540
|
}
|
|
2531
|
-
if (this.networkRecoveries <
|
|
2541
|
+
if (this.networkRecoveries < Zt) {
|
|
2532
2542
|
this.networkRecoveries += 1;
|
|
2533
2543
|
let e = Math.min(8e3, 1e3 * 2 ** (this.networkRecoveries - 1));
|
|
2534
2544
|
this.networkRetryTimer = setTimeout(() => {
|
|
@@ -2545,7 +2555,7 @@ var er = class {
|
|
|
2545
2555
|
return;
|
|
2546
2556
|
}
|
|
2547
2557
|
if (t.type === e.ErrorTypes.MEDIA_ERROR) {
|
|
2548
|
-
if (this.mediaRecoveries <
|
|
2558
|
+
if (this.mediaRecoveries < Xt) {
|
|
2549
2559
|
this.mediaRecoveries += 1, n.recoverMediaError();
|
|
2550
2560
|
return;
|
|
2551
2561
|
}
|
|
@@ -2566,10 +2576,10 @@ var er = class {
|
|
|
2566
2576
|
}
|
|
2567
2577
|
}
|
|
2568
2578
|
toError(t, r = "PLAYBACK") {
|
|
2569
|
-
let o = t.response?.code ?? 0, s = t.details ?? t.type, c = t.reason ?? t.error?.message ?? "", l = r === "DRM" && o === 403 && t.details === e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED ? i(
|
|
2579
|
+
let o = t.response?.code ?? 0, s = t.details ?? t.type, c = t.reason ?? t.error?.message ?? "", l = r === "DRM" && o === 403 && t.details === e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED ? i(Nt(t.networkDetails)) : void 0;
|
|
2570
2580
|
return new n(r === "DRM" ? a(o, l) : r === "NETWORK" && o === 0 ? "NETWORK" : o === 401 ? "UNAUTHORIZED" : o === 403 ? "FORBIDDEN" : "INTERNAL", o, `${r} error: ${s}${c ? ` (${c})` : ""}`, l ? { serverCode: l } : void 0);
|
|
2571
2581
|
}
|
|
2572
|
-
}, tr = 15e3, nr = 6e5, rr = 3e5, ir = 100,
|
|
2582
|
+
}, tr = 15e3, nr = 6e5, rr = 3e5, ir = 100, Q = 1, ar = 1e3, or = 3e4, sr = 1e3, cr = {
|
|
2573
2583
|
inline: "PRESENTATION_INLINE",
|
|
2574
2584
|
fullscreen: "PRESENTATION_FULLSCREEN",
|
|
2575
2585
|
pip: "PRESENTATION_PIP"
|
|
@@ -2756,10 +2766,10 @@ var xr = class {
|
|
|
2756
2766
|
noteStateChange(e, t, n, r) {
|
|
2757
2767
|
if (this.endedFlag || e === t) return;
|
|
2758
2768
|
let i = this.now();
|
|
2759
|
-
if (t === "playing" ? (this.playingSinceMs === null && (this.playingSinceMs = i), this.startupTimeMs === 0 && (this.startupTimeMs = Math.max(
|
|
2769
|
+
if (t === "playing" ? (this.playingSinceMs === null && (this.playingSinceMs = i), this.startupTimeMs === 0 && (this.startupTimeMs = Math.max(Q, i - this.startupAnchorMs)), this.firstAudioMs === 0 && !this.isMuted && (this.firstAudioMs = Math.max(Q, i - this.startupAnchorMs)), this.isMuted && this.mutedSinceMs === null && (this.mutedSinceMs = i)) : this.playingSinceMs !== null && (this.playingTotalMs += i - this.playingSinceMs, this.playingSinceMs = null, this.mutedSinceMs !== null && (this.mutedTotalMs += i - this.mutedSinceMs, this.mutedSinceMs = null)), this.isPlaying = t === "playing", this.syncActive(), t === "waiting" ? this.waitingSinceMs = i : this.waitingSinceMs !== null && (this.waitingTotalMs += i - this.waitingSinceMs, this.waitingSinceMs = null), t === "buffering" && e === "playing") {
|
|
2760
2770
|
this.stallIsSeekInduced = this.seekInduced(i);
|
|
2761
2771
|
let e = !this.isHidden && !this.stallIsSeekInduced;
|
|
2762
|
-
e && (this.rebufferCount += 1), this.isBuffering = !0, this.lastStallMs = i, e && this.timeToFirstStallMs === 0 && (this.timeToFirstStallMs = Math.max(
|
|
2772
|
+
e && (this.rebufferCount += 1), this.isBuffering = !0, this.lastStallMs = i, e && this.timeToFirstStallMs === 0 && (this.timeToFirstStallMs = Math.max(Q, Math.round(this.playingTotalMs)));
|
|
2763
2773
|
} else e === "buffering" && (this.isBuffering = !1, this.stallIsSeekInduced = !1);
|
|
2764
2774
|
this.syncBuffering(), t === "paused" && (this.pauseCount += 1), this.syncIdle(t);
|
|
2765
2775
|
let a = {
|
|
@@ -2807,25 +2817,25 @@ var xr = class {
|
|
|
2807
2817
|
}
|
|
2808
2818
|
this.muteChanges += 1;
|
|
2809
2819
|
let r = this.now();
|
|
2810
|
-
n ? this.isPlaying && this.mutedSinceMs === null && (this.mutedSinceMs = r) : (this.mutedSinceMs !== null && (this.mutedTotalMs += r - this.mutedSinceMs, this.mutedSinceMs = null), this.firstAudioMs === 0 && this.isPlaying && (this.firstAudioMs = Math.max(
|
|
2820
|
+
n ? this.isPlaying && this.mutedSinceMs === null && (this.mutedSinceMs = r) : (this.mutedSinceMs !== null && (this.mutedTotalMs += r - this.mutedSinceMs, this.mutedSinceMs = null), this.firstAudioMs === 0 && this.isPlaying && (this.firstAudioMs = Math.max(Q, r - this.startupAnchorMs))), this.isMuted = n, this.syncActive();
|
|
2811
2821
|
}
|
|
2812
2822
|
notePresentation(e) {
|
|
2813
2823
|
this.endedFlag || e === this.presentation || (this.closePresentation(), this.presentation = e);
|
|
2814
2824
|
}
|
|
2815
2825
|
notePlayIntent() {
|
|
2816
|
-
this.endedFlag || this.startupTimeMs > 0 || (this.startupAnchorMs = this.now(), this.manifestLoadMs > 0 && (this.manifestLoadMs =
|
|
2826
|
+
this.endedFlag || this.startupTimeMs > 0 || (this.startupAnchorMs = this.now(), this.manifestLoadMs > 0 && (this.manifestLoadMs = Q), this.firstPlaylistMs > 0 && (this.firstPlaylistMs = Q), this.firstFragLoadMs > 0 && (this.firstFragLoadMs = Q), this.drmSetupMs > 0 && (this.drmSetupMs = Q));
|
|
2817
2827
|
}
|
|
2818
2828
|
noteReady() {
|
|
2819
|
-
this.manifestLoadMs === 0 && (this.manifestLoadMs = Math.max(
|
|
2829
|
+
this.manifestLoadMs === 0 && (this.manifestLoadMs = Math.max(Q, this.now() - this.startupAnchorMs));
|
|
2820
2830
|
}
|
|
2821
2831
|
noteFirstPlaylist() {
|
|
2822
|
-
this.firstPlaylistMs === 0 && (this.firstPlaylistMs = Math.max(
|
|
2832
|
+
this.firstPlaylistMs === 0 && (this.firstPlaylistMs = Math.max(Q, this.now() - this.startupAnchorMs));
|
|
2823
2833
|
}
|
|
2824
2834
|
noteDrmReady() {
|
|
2825
|
-
this.drmSetupMs === 0 && (this.drmSetupMs = Math.max(
|
|
2835
|
+
this.drmSetupMs === 0 && (this.drmSetupMs = Math.max(Q, this.now() - this.startupAnchorMs));
|
|
2826
2836
|
}
|
|
2827
2837
|
noteFirstBytes() {
|
|
2828
|
-
this.sawFirstBytes = !0, this.firstFragLoadMs === 0 && (this.firstFragLoadMs = Math.max(
|
|
2838
|
+
this.sawFirstBytes = !0, this.firstFragLoadMs === 0 && (this.firstFragLoadMs = Math.max(Q, this.now() - this.startupAnchorMs));
|
|
2829
2839
|
}
|
|
2830
2840
|
noteSeek() {
|
|
2831
2841
|
this.endedFlag || (this.seekCount += 1, this.lastSeekMs = this.now());
|
|
@@ -2918,7 +2928,7 @@ var xr = class {
|
|
|
2918
2928
|
let c = r?.positionMs ?? 0;
|
|
2919
2929
|
c > 0 && (i.exitPositionMs = Math.round(c)), this.activeTotalMs > 0 && (i.activeWatchTimeMs = Math.round(this.activeTotalMs)), this.mutedTotalMs > 0 && (i.mutedTimeMs = Math.round(this.mutedTotalMs));
|
|
2920
2930
|
let l = e !== "END_REASON_ENDED";
|
|
2921
|
-
l && this.lastStallMs > 0 && n - this.lastStallMs <= or && (i.abandonAfterStallMs = Math.max(
|
|
2931
|
+
l && this.lastStallMs > 0 && n - this.lastStallMs <= or && (i.abandonAfterStallMs = Math.max(Q, Math.round(n - this.lastStallMs))), l && this.lastErrorMs > 0 && n - this.lastErrorMs <= or && (i.abandonAfterErrorMs = Math.max(Q, Math.round(n - this.lastErrorMs))), this.fullscreenTotalMs > 0 && (i.fullscreenTimeMs = Math.round(this.fullscreenTotalMs)), this.pipTotalMs > 0 && (i.pipTimeMs = Math.round(this.pipTotalMs)), this.volumeChanges > 0 && (i.volumeChanges = this.volumeChanges), this.muteChanges > 0 && (i.muteChanges = this.muteChanges);
|
|
2922
2932
|
let u = r?.decodedFrames ?? this.lastDecoded;
|
|
2923
2933
|
u > 0 && (i.decodedFramesTotal = u), e === "END_REASON_STOPPED" && this.startupTimeMs === 0 && this.lastErrorStage === null && (e = "END_REASON_ABORTED", i.reason = e), this.startupTimeMs === 0 && e !== "END_REASON_ABORTED" && (i.failedStage = this.lastErrorStage ?? (this.manifestLoadMs === 0 ? "ERROR_STAGE_MANIFEST" : this.firstFragLoadMs === 0 ? "ERROR_STAGE_FIRST_SEGMENT" : "ERROR_STAGE_OTHER")), this.pending.push(this.wrap({ sessionEnd: i })), this.flush(e === "END_REASON_PAGEHIDE");
|
|
2924
2934
|
}
|
|
@@ -3044,7 +3054,7 @@ async function Er() {
|
|
|
3044
3054
|
}
|
|
3045
3055
|
//#endregion
|
|
3046
3056
|
//#region src/core/version.ts
|
|
3047
|
-
var Dr = "2.27.
|
|
3057
|
+
var Dr = "2.27.1", Or = {
|
|
3048
3058
|
accent: "#E1B600",
|
|
3049
3059
|
accentText: "#1B1C23",
|
|
3050
3060
|
background: "#0e0f13",
|
|
@@ -3099,7 +3109,7 @@ var Fr = {
|
|
|
3099
3109
|
liveDot: "<circle cx=\"12\" cy=\"12\" r=\"6\"/>",
|
|
3100
3110
|
retry: "<path d=\"M17.65 6.35A8 8 0 1 0 19.73 13h-2.08A6 6 0 1 1 12 6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z\"/>"
|
|
3101
3111
|
};
|
|
3102
|
-
function
|
|
3112
|
+
function $(e) {
|
|
3103
3113
|
return `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="currentColor">${Fr[e]}</svg>`;
|
|
3104
3114
|
}
|
|
3105
3115
|
//#endregion
|
|
@@ -3180,12 +3190,12 @@ var Hr = class {
|
|
|
3180
3190
|
"aria-label": r,
|
|
3181
3191
|
title: r
|
|
3182
3192
|
});
|
|
3183
|
-
return i.innerHTML =
|
|
3193
|
+
return i.innerHTML = $(n), i;
|
|
3184
3194
|
};
|
|
3185
3195
|
this.overlay = t("div", "havik-overlay"), this.center = t("button", "havik-center", {
|
|
3186
3196
|
type: "button",
|
|
3187
3197
|
"aria-label": "Play"
|
|
3188
|
-
}), this.center.innerHTML =
|
|
3198
|
+
}), this.center.innerHTML = $("play"), this.spinner = t("div", "havik-spinner"), this.spinner.style.display = "none", this.overlay.append(this.center, this.spinner), this.gradient = t("div", "havik-gradient"), this.bar = t("div", "havik-bar"), this.seek = t("div", "havik-seek", {
|
|
3189
3199
|
role: "slider",
|
|
3190
3200
|
"aria-label": "Seek",
|
|
3191
3201
|
"aria-valuemin": "0",
|
|
@@ -3203,7 +3213,7 @@ var Hr = class {
|
|
|
3203
3213
|
"aria-label": "Volume"
|
|
3204
3214
|
});
|
|
3205
3215
|
let a = t("div", "havik-vol");
|
|
3206
|
-
a.append(this.muteBtn, this.volSlider), this.live = t("div", "havik-live"), this.live.innerHTML =
|
|
3216
|
+
a.append(this.muteBtn, this.volSlider), this.live = t("div", "havik-live"), this.live.innerHTML = $("liveDot");
|
|
3207
3217
|
let o = this.doc.createElement("span");
|
|
3208
3218
|
o.textContent = "LIVE", this.liveGo = t("button", "havik-live__go", { type: "button" }), this.liveGo.textContent = "Go live", this.live.append(o, this.liveGo), this.time = t("div", "havik-time"), this.time.textContent = "0:00", this.time.style.display = "none";
|
|
3209
3219
|
let s = t("div", "havik-spacer");
|
|
@@ -3294,12 +3304,12 @@ var Hr = class {
|
|
|
3294
3304
|
}
|
|
3295
3305
|
if (e === "preplay") {
|
|
3296
3306
|
let e = this.doc.createElement("button");
|
|
3297
|
-
e.type = "button", e.className = "havik-status__btn havik-status__btn--play", e.setAttribute("aria-label", "Play"), e.innerHTML =
|
|
3307
|
+
e.type = "button", e.className = "havik-status__btn havik-status__btn--play", e.setAttribute("aria-label", "Play"), e.innerHTML = $("play"), e.addEventListener("click", () => void this.player.play()), n.append(e);
|
|
3298
3308
|
} else {
|
|
3299
3309
|
let r = this.doc.createElement("div");
|
|
3300
3310
|
if (r.className = "havik-status__msg", r.textContent = t ?? "", n.append(r), e === "error" && this.lastError && !Rr.has(this.lastError.code)) {
|
|
3301
3311
|
let e = this.doc.createElement("button");
|
|
3302
|
-
e.type = "button", e.className = "havik-status__btn", e.innerHTML = `${
|
|
3312
|
+
e.type = "button", e.className = "havik-status__btn", e.innerHTML = `${$("retry")}<span>Retry</span>`, e.addEventListener("click", () => void this.player.retry()), n.append(e);
|
|
3303
3313
|
}
|
|
3304
3314
|
}
|
|
3305
3315
|
this.root.append(n), this.statusBox = n, this.show();
|
|
@@ -3418,14 +3428,14 @@ var Hr = class {
|
|
|
3418
3428
|
}
|
|
3419
3429
|
async toggleFullscreen() {
|
|
3420
3430
|
try {
|
|
3421
|
-
|
|
3431
|
+
ve(this.video, this.root) ? await w(this.video, this.root) : await C(this.video, this.root);
|
|
3422
3432
|
} catch {}
|
|
3423
3433
|
}
|
|
3424
3434
|
syncFullscreenSupport() {
|
|
3425
|
-
this.fsSupported =
|
|
3435
|
+
this.fsSupported = S(this.video, this.root), this.fsBtn.style.display = this.fsSupported ? "" : "none";
|
|
3426
3436
|
}
|
|
3427
3437
|
syncFullscreen() {
|
|
3428
|
-
let e =
|
|
3438
|
+
let e = ve(this.video, this.root);
|
|
3429
3439
|
this.setIcon(this.fsBtn, e ? "fullscreenExit" : "fullscreen"), this.fsBtn.setAttribute("aria-label", e ? "Exit fullscreen" : "Fullscreen");
|
|
3430
3440
|
}
|
|
3431
3441
|
poke() {
|
|
@@ -3486,7 +3496,7 @@ var Hr = class {
|
|
|
3486
3496
|
}
|
|
3487
3497
|
}
|
|
3488
3498
|
setIcon(e, t) {
|
|
3489
|
-
e.innerHTML =
|
|
3499
|
+
e.innerHTML = $(t);
|
|
3490
3500
|
}
|
|
3491
3501
|
destroy() {
|
|
3492
3502
|
this.hideTimer && clearTimeout(this.hideTimer), this.tapTimer && clearTimeout(this.tapTimer);
|
|
@@ -3626,7 +3636,7 @@ var ai = class {
|
|
|
3626
3636
|
};
|
|
3627
3637
|
}
|
|
3628
3638
|
beginArming(e, t, n = !1) {
|
|
3629
|
-
let r = this.opts.liveStateEvents === !1 ? void 0 : this.opts.eventsBaseUrl ??
|
|
3639
|
+
let r = this.opts.liveStateEvents === !1 ? void 0 : this.opts.eventsBaseUrl ?? D(this.opts.baseUrl);
|
|
3630
3640
|
r ? this.armWithSse(e, r, t, n) : this.beginArmingByPolling(e);
|
|
3631
3641
|
}
|
|
3632
3642
|
beginArmingByPolling(e) {
|
|
@@ -3686,7 +3696,7 @@ var ai = class {
|
|
|
3686
3696
|
!a && !p() && h();
|
|
3687
3697
|
}, e);
|
|
3688
3698
|
};
|
|
3689
|
-
_(qr), this.armingSub =
|
|
3699
|
+
_(qr), this.armingSub = E({
|
|
3690
3700
|
eventsBaseUrl: t,
|
|
3691
3701
|
matchUrn: this.opts.matchUrn,
|
|
3692
3702
|
credential: this.opts.credential,
|
|
@@ -3715,7 +3725,7 @@ var ai = class {
|
|
|
3715
3725
|
let n = await c(this.opts.credential);
|
|
3716
3726
|
if (this.destroyed || t !== this.loadGen) return;
|
|
3717
3727
|
this.setState("loading");
|
|
3718
|
-
let r = this.opts.autoplay === !1 && !this.playRequested, i = this.createEngine(e, n, r), a =
|
|
3728
|
+
let r = this.opts.autoplay === !1 && !this.playRequested, i = this.createEngine(e, n, r), a = _t(this.opts.video, (e) => {
|
|
3719
3729
|
this._state !== "ended" && this._state !== "error" && this.setState(e);
|
|
3720
3730
|
});
|
|
3721
3731
|
if (await i.load(), this.destroyed || t !== this.loadGen) {
|
|
@@ -3785,7 +3795,7 @@ var ai = class {
|
|
|
3785
3795
|
video: this.opts.video,
|
|
3786
3796
|
descriptor: e,
|
|
3787
3797
|
credential: t,
|
|
3788
|
-
deviceId:
|
|
3798
|
+
deviceId: A(),
|
|
3789
3799
|
userId: this.opts.userId,
|
|
3790
3800
|
lowLatency: this.opts.lowLatency === void 0 || this.opts.lowLatency === "auto" || this.opts.lowLatency,
|
|
3791
3801
|
snapToLiveOnRefocus: this.opts.snapToLiveOnRefocus,
|
|
@@ -3804,8 +3814,8 @@ var ai = class {
|
|
|
3804
3814
|
}, o = this.opts.engine ?? "auto";
|
|
3805
3815
|
if (o === "native") return new H(a);
|
|
3806
3816
|
if (o === "hls") return new er(a);
|
|
3807
|
-
if (e.drmEnabled && e.drm?.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && B(this.opts.video) && V() || !e.drmEnabled &&
|
|
3808
|
-
if (
|
|
3817
|
+
if (e.drmEnabled && e.drm?.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && B(this.opts.video) && V() || !e.drmEnabled && kt() && B(this.opts.video)) return new H(a);
|
|
3818
|
+
if (Gt()) return new er(a);
|
|
3809
3819
|
if (B(this.opts.video)) return new H(a);
|
|
3810
3820
|
throw new n("INTERNAL", 0, "no supported HLS playback engine in this browser");
|
|
3811
3821
|
}
|
|
@@ -3856,11 +3866,11 @@ var ai = class {
|
|
|
3856
3866
|
}
|
|
3857
3867
|
startLiveState(e) {
|
|
3858
3868
|
if (this.opts.liveStateEvents === !1) return;
|
|
3859
|
-
let t = this.opts.eventsBaseUrl ??
|
|
3869
|
+
let t = this.opts.eventsBaseUrl ?? D(this.opts.baseUrl);
|
|
3860
3870
|
if (!t) return;
|
|
3861
3871
|
this.closeLiveState();
|
|
3862
3872
|
let i = 0, a = !1;
|
|
3863
|
-
this.liveStateSub =
|
|
3873
|
+
this.liveStateSub = E({
|
|
3864
3874
|
eventsBaseUrl: t,
|
|
3865
3875
|
matchUrn: this.opts.matchUrn,
|
|
3866
3876
|
credential: this.opts.credential,
|
|
@@ -3872,7 +3882,7 @@ var ai = class {
|
|
|
3872
3882
|
},
|
|
3873
3883
|
onError: (o) => {
|
|
3874
3884
|
if (!(this.destroyed || e !== this.loadGen || a) && !this.endedHandled) {
|
|
3875
|
-
if (o instanceof
|
|
3885
|
+
if (o instanceof T && (o.terminal || o.status === 404)) {
|
|
3876
3886
|
a = !0, this.emit("warning", new n(r(o.status), o.status, `live-state events answered HTTP ${o.status} for ${this.opts.matchUrn}: the match is ` + (o.terminal ? "gone, so the subscription stopped" : "not in the catalog (ended and dropped, or not listed yet), so it retries every 5 min") + " — end-of-stream detection falls back to the HLS staleness watchdog."));
|
|
3877
3887
|
return;
|
|
3878
3888
|
}
|
|
@@ -4112,13 +4122,13 @@ var ai = class {
|
|
|
4112
4122
|
e.pictureInPictureElement === this.opts.video && typeof e.exitPictureInPicture == "function" && await e.exitPictureInPicture();
|
|
4113
4123
|
}
|
|
4114
4124
|
async enterFullscreen() {
|
|
4115
|
-
return !this.destroyed &&
|
|
4125
|
+
return !this.destroyed && C(this.opts.video, this.container ?? void 0);
|
|
4116
4126
|
}
|
|
4117
4127
|
async exitFullscreen() {
|
|
4118
|
-
await
|
|
4128
|
+
await w(this.opts.video, this.container ?? void 0);
|
|
4119
4129
|
}
|
|
4120
4130
|
fullscreenSupported() {
|
|
4121
|
-
return !this.destroyed &&
|
|
4131
|
+
return !this.destroyed && S(this.opts.video, this.container ?? void 0);
|
|
4122
4132
|
}
|
|
4123
4133
|
retry() {
|
|
4124
4134
|
return this.reload();
|
|
@@ -4181,12 +4191,12 @@ var ai = class {
|
|
|
4181
4191
|
};
|
|
4182
4192
|
//#endregion
|
|
4183
4193
|
//#region src/embed/protocol.ts
|
|
4184
|
-
function
|
|
4194
|
+
function oi(e) {
|
|
4185
4195
|
return !!e && typeof e == "object" && typeof e.type == "string" && e.type.startsWith("oddin:");
|
|
4186
4196
|
}
|
|
4187
4197
|
//#endregion
|
|
4188
4198
|
//#region src/embed/host.ts
|
|
4189
|
-
function
|
|
4199
|
+
function si(e) {
|
|
4190
4200
|
if (!e.container || typeof e.container.appendChild != "function") throw Error("mountEmbed: opts.container must be a DOM element");
|
|
4191
4201
|
if (!e.src) throw Error("mountEmbed: opts.src is required");
|
|
4192
4202
|
if (!e.baseUrl || !e.matchUrn) throw Error("mountEmbed: opts.baseUrl and opts.matchUrn are required");
|
|
@@ -4195,7 +4205,7 @@ function oi(e) {
|
|
|
4195
4205
|
let r = document.createElement("iframe");
|
|
4196
4206
|
r.src = t.toString(), r.allow = "autoplay; encrypted-media; fullscreen", r.setAttribute("allowfullscreen", ""), r.referrerPolicy = "no-referrer", r.setAttribute("sandbox", e.sandbox ?? "allow-scripts allow-same-origin allow-presentation"), r.style.cssText = "border:0;width:100%;height:100%;display:block", e.container.appendChild(r);
|
|
4197
4207
|
let i = /* @__PURE__ */ new Set(), a = (t) => {
|
|
4198
|
-
if (t.source !== r.contentWindow || t.origin !== n ||
|
|
4208
|
+
if (t.source !== r.contentWindow || t.origin !== n || !oi(t.data)) return;
|
|
4199
4209
|
let a = t.data;
|
|
4200
4210
|
a.type === "oddin:ready" && a.protocol !== 1 && console.warn(`havik-player: embed protocol v${a.protocol} != host v1. Pin the embed page version to the SDK version to avoid skew.`), e.onEvent?.(a), i.forEach((e) => e(a));
|
|
4201
4211
|
};
|
|
@@ -4245,15 +4255,15 @@ function oi(e) {
|
|
|
4245
4255
|
}
|
|
4246
4256
|
//#endregion
|
|
4247
4257
|
//#region src/embed/page.ts
|
|
4248
|
-
var
|
|
4249
|
-
function
|
|
4258
|
+
var ci = /^[A-Za-z0-9:_.-]{1,128}$/;
|
|
4259
|
+
function li(e) {
|
|
4250
4260
|
if (typeof e == "boolean") return e;
|
|
4251
4261
|
if (typeof e == "object" && e) {
|
|
4252
4262
|
let t = e.endpoint;
|
|
4253
4263
|
return typeof t == "string" ? { endpoint: t } : {};
|
|
4254
4264
|
}
|
|
4255
4265
|
}
|
|
4256
|
-
function
|
|
4266
|
+
function ui() {
|
|
4257
4267
|
let e = window.HAVIK_EMBED_CONFIG;
|
|
4258
4268
|
if (e) return {
|
|
4259
4269
|
baseUrl: e.baseUrl ?? "",
|
|
@@ -4263,7 +4273,7 @@ function li() {
|
|
|
4263
4273
|
autoplay: e.autoplay ?? !0,
|
|
4264
4274
|
muted: e.muted ?? !0,
|
|
4265
4275
|
waitForLive: e.waitForLive ?? !0,
|
|
4266
|
-
analytics:
|
|
4276
|
+
analytics: li(e.analytics)
|
|
4267
4277
|
};
|
|
4268
4278
|
let t = new URLSearchParams(location.search);
|
|
4269
4279
|
return {
|
|
@@ -4276,9 +4286,9 @@ function li() {
|
|
|
4276
4286
|
waitForLive: !0
|
|
4277
4287
|
};
|
|
4278
4288
|
}
|
|
4279
|
-
async function
|
|
4280
|
-
let e =
|
|
4281
|
-
|
|
4289
|
+
async function di() {
|
|
4290
|
+
let e = ui();
|
|
4291
|
+
pi();
|
|
4282
4292
|
let t = document.createElement("video");
|
|
4283
4293
|
t.setAttribute("playsinline", ""), t.muted = e.muted ?? !0, t.style.cssText = "width:100%;height:100%;object-fit:contain;background:#000;aspect-ratio:auto", document.body.appendChild(t);
|
|
4284
4294
|
let r = e.parentOrigin && e.parentOrigin !== "null" ? e.parentOrigin : null;
|
|
@@ -4334,7 +4344,7 @@ async function ui() {
|
|
|
4334
4344
|
message: e.message,
|
|
4335
4345
|
...e.country === void 0 ? {} : { country: e.country }
|
|
4336
4346
|
})), e.on("autoplayblocked", () => {
|
|
4337
|
-
i({ type: "oddin:autoplayblocked" }),
|
|
4347
|
+
i({ type: "oddin:autoplayblocked" }), fi(t, e);
|
|
4338
4348
|
});
|
|
4339
4349
|
}, s = async (r) => {
|
|
4340
4350
|
a?.destroy(), a = null;
|
|
@@ -4402,30 +4412,30 @@ async function ui() {
|
|
|
4402
4412
|
a?.retry();
|
|
4403
4413
|
break;
|
|
4404
4414
|
case "oddin:load":
|
|
4405
|
-
typeof e.matchUrn == "string" &&
|
|
4415
|
+
typeof e.matchUrn == "string" && ci.test(e.matchUrn) && s(e.matchUrn);
|
|
4406
4416
|
break;
|
|
4407
4417
|
case "oddin:destroy": c();
|
|
4408
4418
|
}
|
|
4409
4419
|
}, u = (e) => {
|
|
4410
|
-
r && e.origin === r &&
|
|
4420
|
+
r && e.origin === r && oi(e.data) && l(e.data);
|
|
4411
4421
|
};
|
|
4412
4422
|
r && window.addEventListener("message", u), window.addEventListener("pagehide", c, { once: !0 }), await s(e.matchUrn), i({
|
|
4413
4423
|
type: "oddin:ready",
|
|
4414
4424
|
protocol: 1
|
|
4415
4425
|
});
|
|
4416
4426
|
}
|
|
4417
|
-
function
|
|
4427
|
+
function fi(e, t) {
|
|
4418
4428
|
if (document.getElementById("havik-tap")) return;
|
|
4419
4429
|
let n = document.createElement("button");
|
|
4420
4430
|
n.id = "havik-tap", n.textContent = "▶ Tap to play", n.style.cssText = "position:fixed;inset:0;width:100%;height:100%;border:0;background:rgba(0,0,0,.55);color:#fff;font:600 18px system-ui,sans-serif;cursor:pointer;z-index:9", n.addEventListener("click", () => {
|
|
4421
4431
|
n.remove(), t.play();
|
|
4422
4432
|
}), document.body.appendChild(n);
|
|
4423
4433
|
}
|
|
4424
|
-
function
|
|
4434
|
+
function pi() {
|
|
4425
4435
|
let e = document.createElement("style");
|
|
4426
4436
|
e.textContent = "html,body{margin:0;height:100%;background:#000;overflow:hidden}body{display:flex}", document.head.appendChild(e);
|
|
4427
4437
|
}
|
|
4428
4438
|
//#endregion
|
|
4429
|
-
export {
|
|
4439
|
+
export { T as LiveStateHttpError, Or as ODDIN_THEME, n as PlaybackError, Ar as applyTheme, lt as baseUrlForEnv, di as bootEmbed, Oe as clearDeviceId, Be as clearRememberedBandwidth, ii as createPlayer, D as deriveEventsBaseUrl, at as detectDrmSupport, C as enterVideoFullscreen, w as exitVideoFullscreen, ye as fetchCatalog, xe as fetchTournament, Ce as flattenMatches, S as fullscreenSupported, A as getDeviceId, st as isLowLatencyManifest, oi as isOddinMessage, Ae as licenseRequestHeaders, si as mountEmbed, fe as pollToLive, y as resolveStream, E as subscribeLiveState, ve as videoFullscreenActive, Te as watchStatus };
|
|
4430
4440
|
|
|
4431
4441
|
//# sourceMappingURL=index.js.map
|