@mottosports/motto-video-player 1.0.1-rc.60 → 1.0.1-rc.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +57 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1201,7 +1201,6 @@ var isPlayReadySupported = () => {
|
|
|
1201
1201
|
return isXbox || (isEdge || isIE) && isWindows;
|
|
1202
1202
|
};
|
|
1203
1203
|
var supportsWidevinePersistentLicenses = () => {
|
|
1204
|
-
return false;
|
|
1205
1204
|
if (typeof navigator === "undefined") {
|
|
1206
1205
|
return false;
|
|
1207
1206
|
}
|
|
@@ -1226,7 +1225,7 @@ var supportsWidevinePersistentLicenses = () => {
|
|
|
1226
1225
|
var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
1227
1226
|
|
|
1228
1227
|
// package.json
|
|
1229
|
-
var version = "1.0.1-rc.
|
|
1228
|
+
var version = "1.0.1-rc.61";
|
|
1230
1229
|
|
|
1231
1230
|
// src/utils/licenseCache.ts
|
|
1232
1231
|
var PERSISTENT_LICENSE_PREFIX = "motto_lic_";
|
|
@@ -1396,6 +1395,8 @@ var useShakaPlayer = ({
|
|
|
1396
1395
|
const waitingForKeyHandlerRef = (0, import_react.useRef)(null);
|
|
1397
1396
|
const playbackResumedHandlerRef = (0, import_react.useRef)(null);
|
|
1398
1397
|
const usingPersistentLicenseRef = (0, import_react.useRef)(false);
|
|
1398
|
+
const storedPersistentThisLoadRef = (0, import_react.useRef)(false);
|
|
1399
|
+
const drmExpirationHandlerRef = (0, import_react.useRef)(null);
|
|
1399
1400
|
const getManifestUrl = (0, import_react.useCallback)(() => {
|
|
1400
1401
|
let manifestUrl = src.url;
|
|
1401
1402
|
const isDRM = Boolean(src.drm);
|
|
@@ -1427,6 +1428,7 @@ var useShakaPlayer = ({
|
|
|
1427
1428
|
const manifestUrl = getManifestUrl();
|
|
1428
1429
|
let playlistId = src.id;
|
|
1429
1430
|
const isDRM = Boolean(src.drm);
|
|
1431
|
+
storedPersistentThisLoadRef.current = false;
|
|
1430
1432
|
let storedSessionsMetadata = [];
|
|
1431
1433
|
if (isDRM && playlistId) {
|
|
1432
1434
|
storedSessionsMetadata = retrievePersistentLicense(playlistId, src.drm.licenseCacheKey ?? "");
|
|
@@ -1434,7 +1436,8 @@ var useShakaPlayer = ({
|
|
|
1434
1436
|
if (isDRM) {
|
|
1435
1437
|
const drmConfig2 = {
|
|
1436
1438
|
servers: {
|
|
1437
|
-
"com.widevine.alpha":
|
|
1439
|
+
"com.widevine.alpha": "http://localhost:8787/drm/widevine",
|
|
1440
|
+
// src.drm.widevine?.licenseUrl,
|
|
1438
1441
|
"com.microsoft.playready": src.drm.playready?.licenseUrl,
|
|
1439
1442
|
"com.apple.fps": src.drm.fairplay?.licenseUrl
|
|
1440
1443
|
},
|
|
@@ -1539,6 +1542,36 @@ var useShakaPlayer = ({
|
|
|
1539
1542
|
});
|
|
1540
1543
|
}
|
|
1541
1544
|
}
|
|
1545
|
+
if (isDRM && playlistId) {
|
|
1546
|
+
const onDRMSessionUpdate = () => {
|
|
1547
|
+
try {
|
|
1548
|
+
if (storedPersistentThisLoadRef.current) return;
|
|
1549
|
+
const activeDrmSessions = player.getActiveSessionsMetadata?.();
|
|
1550
|
+
if (!activeDrmSessions) return;
|
|
1551
|
+
const persistentSessions = activeDrmSessions.filter(
|
|
1552
|
+
(session) => session.sessionType === "persistent-license"
|
|
1553
|
+
);
|
|
1554
|
+
if (persistentSessions.length > 0) {
|
|
1555
|
+
const sessionsToStore = persistentSessions.map((session) => ({
|
|
1556
|
+
sessionId: session.sessionId,
|
|
1557
|
+
initData: session.initData,
|
|
1558
|
+
initDataType: session.initDataType,
|
|
1559
|
+
keySystem: session.keySystem || "com.widevine.alpha"
|
|
1560
|
+
}));
|
|
1561
|
+
storePersistentLicense(playlistId, src.drm.licenseCacheKey ?? "", sessionsToStore);
|
|
1562
|
+
storedPersistentThisLoadRef.current = true;
|
|
1563
|
+
}
|
|
1564
|
+
} catch (e) {
|
|
1565
|
+
console.warn("Failed to persist licenses on expiration update:", e);
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
try {
|
|
1569
|
+
player.addEventListener("drmsessionupdate", onDRMSessionUpdate);
|
|
1570
|
+
drmExpirationHandlerRef.current = onDRMSessionUpdate;
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
console.warn("Failed to attach drmsessionupdate listener:", e);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1542
1575
|
player?.addEventListener("error", (event) => {
|
|
1543
1576
|
const error = event.detail;
|
|
1544
1577
|
if (error?.code === 7e3) {
|
|
@@ -1602,30 +1635,6 @@ var useShakaPlayer = ({
|
|
|
1602
1635
|
}
|
|
1603
1636
|
}
|
|
1604
1637
|
await player.load(manifestUrl);
|
|
1605
|
-
if (isDRM && playlistId) {
|
|
1606
|
-
try {
|
|
1607
|
-
setTimeout(() => {
|
|
1608
|
-
const activeDrmSessions = player.getActiveSessionsMetadata?.();
|
|
1609
|
-
if (activeDrmSessions) {
|
|
1610
|
-
const persistentSessions = activeDrmSessions.filter(
|
|
1611
|
-
(session) => session.sessionType === "persistent-license"
|
|
1612
|
-
);
|
|
1613
|
-
if (persistentSessions.length > 0) {
|
|
1614
|
-
const sessionsToStore = persistentSessions.map((session) => ({
|
|
1615
|
-
sessionId: session.sessionId,
|
|
1616
|
-
initData: session.initData,
|
|
1617
|
-
initDataType: session.initDataType,
|
|
1618
|
-
keySystem: session.keySystem || "com.widevine.alpha"
|
|
1619
|
-
// fallback
|
|
1620
|
-
}));
|
|
1621
|
-
storePersistentLicense(playlistId, src.drm.licenseCacheKey ?? "", sessionsToStore);
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}, 2e3);
|
|
1625
|
-
} catch (error) {
|
|
1626
|
-
console.warn("Failed to store persistent license sessions:", error);
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
1638
|
onPlayerReady?.(player);
|
|
1630
1639
|
return player;
|
|
1631
1640
|
} catch (error) {
|
|
@@ -1661,11 +1670,21 @@ var useShakaPlayer = ({
|
|
|
1661
1670
|
window.clearTimeout(waitingForKeyTimerRef.current);
|
|
1662
1671
|
waitingForKeyTimerRef.current = null;
|
|
1663
1672
|
}
|
|
1673
|
+
try {
|
|
1674
|
+
if (drmExpirationHandlerRef.current && playerRef.current?.removeEventListener) {
|
|
1675
|
+
playerRef.current.removeEventListener("drmsessionupdate", drmExpirationHandlerRef.current);
|
|
1676
|
+
}
|
|
1677
|
+
} catch (e) {
|
|
1678
|
+
console.warn("Error removing DRM expiration listener:", e);
|
|
1679
|
+
} finally {
|
|
1680
|
+
drmExpirationHandlerRef.current = null;
|
|
1681
|
+
}
|
|
1664
1682
|
await playerRef.current.destroy();
|
|
1665
1683
|
} catch (error) {
|
|
1666
1684
|
console.warn("Error destroying Shaka Player:", error);
|
|
1667
1685
|
} finally {
|
|
1668
1686
|
playerRef.current = null;
|
|
1687
|
+
storedPersistentThisLoadRef.current = false;
|
|
1669
1688
|
}
|
|
1670
1689
|
}
|
|
1671
1690
|
}, [playerRef]);
|
|
@@ -3810,6 +3829,7 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3810
3829
|
const containerRef = (0, import_react12.useRef)(null);
|
|
3811
3830
|
const [isScriptsLoaded, setIsScriptsLoaded] = (0, import_react12.useState)(false);
|
|
3812
3831
|
const [isInitialLoading, setIsInitialLoading] = (0, import_react12.useState)(true);
|
|
3832
|
+
const [bfResetKey, setBfResetKey] = (0, import_react12.useState)(0);
|
|
3813
3833
|
(0, import_react12.useImperativeHandle)(ref, () => videoRef.current, []);
|
|
3814
3834
|
const { playerRef, initializePlayer, destroyPlayer, isRetrying } = useShakaPlayer({
|
|
3815
3835
|
src,
|
|
@@ -3957,6 +3977,15 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3957
3977
|
};
|
|
3958
3978
|
loadRequiredScripts();
|
|
3959
3979
|
}, [imaConfig?.adTagUrl, system73Config?.apiKey]);
|
|
3980
|
+
(0, import_react12.useEffect)(() => {
|
|
3981
|
+
const onPageShow = (e) => {
|
|
3982
|
+
if (e && e.persisted) {
|
|
3983
|
+
setBfResetKey((k) => k + 1);
|
|
3984
|
+
}
|
|
3985
|
+
};
|
|
3986
|
+
window.addEventListener("pageshow", onPageShow);
|
|
3987
|
+
return () => window.removeEventListener("pageshow", onPageShow);
|
|
3988
|
+
}, []);
|
|
3960
3989
|
(0, import_react12.useEffect)(() => {
|
|
3961
3990
|
const video = videoRef.current;
|
|
3962
3991
|
if (!video || !isScriptsLoaded) return;
|
|
@@ -3996,7 +4025,7 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3996
4025
|
destroyMux();
|
|
3997
4026
|
destroyPlayer();
|
|
3998
4027
|
};
|
|
3999
|
-
}, [src, isScriptsLoaded]);
|
|
4028
|
+
}, [src, isScriptsLoaded, bfResetKey]);
|
|
4000
4029
|
(0, import_react12.useEffect)(() => {
|
|
4001
4030
|
const video = videoRef.current;
|
|
4002
4031
|
if (!video) return;
|