@mottosports/motto-video-player 1.0.1-rc.38 → 1.0.1-rc.40
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 +45 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1151,14 +1151,15 @@ var isChrome64PlusOnMacOrWindows = () => {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
const isMacOS = /Mac OS X|Macintosh/.test(userAgent);
|
|
1153
1153
|
const isWindows = /Windows/.test(userAgent);
|
|
1154
|
-
|
|
1154
|
+
const isAndroid = /Android/.test(userAgent);
|
|
1155
|
+
return isMacOS || isWindows || isAndroid;
|
|
1155
1156
|
};
|
|
1156
1157
|
|
|
1157
1158
|
// src/hooks/useShakaPlayer.ts
|
|
1158
1159
|
import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
|
|
1159
1160
|
|
|
1160
1161
|
// package.json
|
|
1161
|
-
var version = "1.0.1-rc.
|
|
1162
|
+
var version = "1.0.1-rc.40";
|
|
1162
1163
|
|
|
1163
1164
|
// src/utils/licenseCache.ts
|
|
1164
1165
|
var PERSISTENT_LICENSE_PREFIX = "motto_lic_";
|
|
@@ -1303,8 +1304,10 @@ var clearAllPersistentLicenses = () => {
|
|
|
1303
1304
|
localStorage.removeItem(key);
|
|
1304
1305
|
}
|
|
1305
1306
|
console.log(`Cleared ${keys.length} persistent license cache entries`);
|
|
1307
|
+
return keys.length;
|
|
1306
1308
|
} catch (error) {
|
|
1307
1309
|
console.error("Failed to clear persistent licenses:", error);
|
|
1310
|
+
return 0;
|
|
1308
1311
|
}
|
|
1309
1312
|
};
|
|
1310
1313
|
|
|
@@ -1364,6 +1367,10 @@ var useShakaPlayer = ({
|
|
|
1364
1367
|
"com.microsoft.playready": src.drm.playready?.licenseUrl,
|
|
1365
1368
|
"com.apple.fps": src.drm.fairplay?.licenseUrl
|
|
1366
1369
|
},
|
|
1370
|
+
keySystemsMapping: {
|
|
1371
|
+
// Fall back or reroute to the platform’s recommended PlayReady CDM if needed
|
|
1372
|
+
"com.microsoft.playready": "com.microsoft.playready.recommendation"
|
|
1373
|
+
},
|
|
1367
1374
|
...src.drm.fairplay && {
|
|
1368
1375
|
advanced: {
|
|
1369
1376
|
"com.apple.fps": {
|
|
@@ -1377,17 +1384,26 @@ var useShakaPlayer = ({
|
|
|
1377
1384
|
"com.widevine.alpha": {
|
|
1378
1385
|
...drmConfig2.advanced?.["com.widevine.alpha"],
|
|
1379
1386
|
// set to `persistent-license` only on Chrome 64+ on MacOS/Windows: https://shaka-player-demo.appspot.com/docs/api/tutorial-faq.html
|
|
1380
|
-
sessionType: isChrome64PlusOnMacOrWindows() ? "persistent-license" : "temporary"
|
|
1387
|
+
sessionType: isChrome64PlusOnMacOrWindows() ? "persistent-license" : "temporary",
|
|
1388
|
+
"headers": {
|
|
1389
|
+
"x-dt-auth-token": src.drm.token || ""
|
|
1390
|
+
}
|
|
1381
1391
|
},
|
|
1382
1392
|
"com.microsoft.playready": {
|
|
1383
1393
|
...drmConfig2.advanced?.["com.microsoft.playready"],
|
|
1384
|
-
sessionType: "temporary"
|
|
1394
|
+
sessionType: "temporary",
|
|
1385
1395
|
// PlayReady always uses temporary sessions
|
|
1396
|
+
"headers": {
|
|
1397
|
+
"x-dt-auth-token": src.drm.token || ""
|
|
1398
|
+
}
|
|
1386
1399
|
},
|
|
1387
1400
|
"com.apple.fps": {
|
|
1388
1401
|
...drmConfig2.advanced?.["com.apple.fps"],
|
|
1389
|
-
sessionType: "temporary"
|
|
1402
|
+
sessionType: "temporary",
|
|
1390
1403
|
// FairPlay always uses temporary sessions - Safari won't play with persistent-license
|
|
1404
|
+
"headers": {
|
|
1405
|
+
"x-dt-auth-token": src.drm.token || ""
|
|
1406
|
+
}
|
|
1391
1407
|
}
|
|
1392
1408
|
};
|
|
1393
1409
|
if (storedSessionsMetadata.length > 0) {
|
|
@@ -1401,11 +1417,6 @@ var useShakaPlayer = ({
|
|
|
1401
1417
|
player.configure({ drm: drmConfig2 });
|
|
1402
1418
|
const netEngine = player.getNetworkingEngine();
|
|
1403
1419
|
if (netEngine) {
|
|
1404
|
-
netEngine.registerRequestFilter((type, request) => {
|
|
1405
|
-
if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
|
|
1406
|
-
request.headers["x-dt-auth-token"] = src.drm.token;
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
1420
|
netEngine.registerResponseFilter((type, response) => {
|
|
1410
1421
|
if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
|
|
1411
1422
|
const ks = player.keySystem && player.keySystem();
|
|
@@ -1423,26 +1434,31 @@ var useShakaPlayer = ({
|
|
|
1423
1434
|
return;
|
|
1424
1435
|
}
|
|
1425
1436
|
if (error?.code >= 6e3 && error?.code < 7e3 && !isRetrying && videoElementRef.current) {
|
|
1426
|
-
console.warn(`DRM error detected (code: ${error.code}),
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
+
console.warn(`DRM error detected (code: ${error.code}), checking for cached licenses...`);
|
|
1438
|
+
const clearedCount = clearAllPersistentLicenses();
|
|
1439
|
+
if (clearedCount > 0) {
|
|
1440
|
+
console.warn(`Cleared ${clearedCount} cached licenses, retrying...`);
|
|
1441
|
+
setIsRetrying(true);
|
|
1442
|
+
setTimeout(async () => {
|
|
1443
|
+
try {
|
|
1444
|
+
const video2 = videoElementRef.current;
|
|
1445
|
+
const currentPlayer = playerRef.current;
|
|
1446
|
+
if (video2 && currentPlayer) {
|
|
1447
|
+
console.log("Reloading manifest after license cache clear...");
|
|
1448
|
+
await currentPlayer.load(getManifestUrl());
|
|
1449
|
+
console.log("Manifest reloaded successfully");
|
|
1450
|
+
}
|
|
1451
|
+
} catch (retryError) {
|
|
1452
|
+
console.error("Failed to retry after license clear:", retryError);
|
|
1453
|
+
onError?.(retryError);
|
|
1454
|
+
} finally {
|
|
1455
|
+
setIsRetrying(false);
|
|
1437
1456
|
}
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
}
|
|
1444
|
-
}, 500);
|
|
1445
|
-
return;
|
|
1457
|
+
}, 500);
|
|
1458
|
+
return;
|
|
1459
|
+
} else {
|
|
1460
|
+
console.warn(`No cached licenses found to clear for error code ${error.code}, not retrying to avoid infinite loop`);
|
|
1461
|
+
}
|
|
1446
1462
|
}
|
|
1447
1463
|
console.error("Shaka Player Error:", error);
|
|
1448
1464
|
onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
|