@mottosports/motto-video-player 1.0.1-rc.76 → 1.0.1-rc.78
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.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +32 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -200,9 +200,10 @@ interface IconSizes {
|
|
|
200
200
|
}
|
|
201
201
|
interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'onError'> {
|
|
202
202
|
/**
|
|
203
|
-
* The source URL of the video (DASH, HLS, or regular MP4) or playlist object with DRM info
|
|
203
|
+
* The source URL of the video (DASH, HLS, or regular MP4) or playlist object with DRM info.
|
|
204
|
+
* Can be a plain URL string or a Playlist object.
|
|
204
205
|
*/
|
|
205
|
-
src: Playlist;
|
|
206
|
+
src: Playlist | string;
|
|
206
207
|
/**
|
|
207
208
|
* When true, player only reinitializes based on playlist presence rather than src changes.
|
|
208
209
|
* Used internally by Event, CreativeWork, and Video wrappers to optimize reinitialization.
|
package/dist/index.d.ts
CHANGED
|
@@ -200,9 +200,10 @@ interface IconSizes {
|
|
|
200
200
|
}
|
|
201
201
|
interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'onError'> {
|
|
202
202
|
/**
|
|
203
|
-
* The source URL of the video (DASH, HLS, or regular MP4) or playlist object with DRM info
|
|
203
|
+
* The source URL of the video (DASH, HLS, or regular MP4) or playlist object with DRM info.
|
|
204
|
+
* Can be a plain URL string or a Playlist object.
|
|
204
205
|
*/
|
|
205
|
-
src: Playlist;
|
|
206
|
+
src: Playlist | string;
|
|
206
207
|
/**
|
|
207
208
|
* When true, player only reinitializes based on playlist presence rather than src changes.
|
|
208
209
|
* Used internally by Event, CreativeWork, and Video wrappers to optimize reinitialization.
|
package/dist/index.js
CHANGED
|
@@ -490,7 +490,7 @@ var supportsWidevinePersistentLicenses = () => {
|
|
|
490
490
|
var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
491
491
|
|
|
492
492
|
// package.json
|
|
493
|
-
var version = "1.0.1-rc.
|
|
493
|
+
var version = "1.0.1-rc.78";
|
|
494
494
|
|
|
495
495
|
// src/utils/licenseCache.ts
|
|
496
496
|
var PERSISTENT_LICENSE_PREFIX = "motto_lic_";
|
|
@@ -643,6 +643,17 @@ var clearAllPersistentLicenses = () => {
|
|
|
643
643
|
};
|
|
644
644
|
|
|
645
645
|
// src/hooks/useShakaPlayer.ts
|
|
646
|
+
var normalizeSource = (src) => {
|
|
647
|
+
if (typeof src === "string") {
|
|
648
|
+
return {
|
|
649
|
+
id: "",
|
|
650
|
+
url: src,
|
|
651
|
+
format: "auto",
|
|
652
|
+
drm: {}
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
return src;
|
|
656
|
+
};
|
|
646
657
|
var useShakaPlayer = ({
|
|
647
658
|
src,
|
|
648
659
|
shakaConfig,
|
|
@@ -671,16 +682,17 @@ var useShakaPlayer = ({
|
|
|
671
682
|
const storedPersistentThisLoadRef = (0, import_react.useRef)(false);
|
|
672
683
|
const drmExpirationHandlerRef = (0, import_react.useRef)(null);
|
|
673
684
|
const getManifestUrl = (0, import_react.useCallback)(() => {
|
|
674
|
-
|
|
675
|
-
|
|
685
|
+
const playlistSrc = normalizeSource(src);
|
|
686
|
+
let manifestUrl = playlistSrc.url;
|
|
687
|
+
const isDRM = Boolean(playlistSrc.drm?.widevine || playlistSrc.drm?.fairplay || playlistSrc.drm?.playready);
|
|
676
688
|
if (isDRM) {
|
|
677
689
|
const isPlayReady = isPlayReadySupported();
|
|
678
|
-
if (isAppleDevice() &&
|
|
679
|
-
manifestUrl =
|
|
680
|
-
} else if (isPlayReady &&
|
|
681
|
-
manifestUrl =
|
|
690
|
+
if (isAppleDevice() && playlistSrc.drm?.fairplay?.certificateUrl) {
|
|
691
|
+
manifestUrl = playlistSrc.drm.fairplay.playlistUrl;
|
|
692
|
+
} else if (isPlayReady && playlistSrc.drm?.playready?.licenseUrl) {
|
|
693
|
+
manifestUrl = playlistSrc.drm.playready.playlistUrl;
|
|
682
694
|
} else {
|
|
683
|
-
manifestUrl =
|
|
695
|
+
manifestUrl = playlistSrc.drm?.widevine?.playlistUrl || "";
|
|
684
696
|
}
|
|
685
697
|
}
|
|
686
698
|
return manifestUrl;
|
|
@@ -725,9 +737,10 @@ var useShakaPlayer = ({
|
|
|
725
737
|
if (shakaConfig) {
|
|
726
738
|
player.configure(shakaConfig);
|
|
727
739
|
}
|
|
740
|
+
const playlistSrc = normalizeSource(src);
|
|
728
741
|
const manifestUrl = getManifestUrl();
|
|
729
|
-
let playlistId =
|
|
730
|
-
const isDRM = Boolean(
|
|
742
|
+
let playlistId = playlistSrc.id;
|
|
743
|
+
const isDRM = Boolean(playlistSrc.drm?.widevine || playlistSrc.drm?.fairplay || playlistSrc.drm?.playready);
|
|
731
744
|
storedPersistentThisLoadRef.current = false;
|
|
732
745
|
if (activeInitIdRef.current !== myInitId || isDestroyingRef.current) {
|
|
733
746
|
try {
|
|
@@ -739,23 +752,23 @@ var useShakaPlayer = ({
|
|
|
739
752
|
}
|
|
740
753
|
let storedSessionsMetadata = [];
|
|
741
754
|
if (isDRM && playlistId) {
|
|
742
|
-
storedSessionsMetadata = retrievePersistentLicense(playlistId,
|
|
755
|
+
storedSessionsMetadata = retrievePersistentLicense(playlistId, playlistSrc.drm?.licenseCacheKey ?? "");
|
|
743
756
|
}
|
|
744
757
|
if (isDRM) {
|
|
745
758
|
const drmConfig2 = {
|
|
746
759
|
servers: {
|
|
747
|
-
"com.widevine.alpha":
|
|
748
|
-
"com.microsoft.playready":
|
|
749
|
-
"com.apple.fps":
|
|
760
|
+
"com.widevine.alpha": playlistSrc.drm?.widevine?.licenseUrl,
|
|
761
|
+
"com.microsoft.playready": playlistSrc.drm?.playready?.licenseUrl,
|
|
762
|
+
"com.apple.fps": playlistSrc.drm?.fairplay?.licenseUrl
|
|
750
763
|
},
|
|
751
764
|
keySystemsMapping: {
|
|
752
|
-
// Fall back or reroute to the platform
|
|
765
|
+
// Fall back or reroute to the platform's recommended PlayReady CDM if needed
|
|
753
766
|
"com.microsoft.playready": "com.microsoft.playready.recommendation"
|
|
754
767
|
},
|
|
755
|
-
...
|
|
768
|
+
...playlistSrc.drm?.fairplay && {
|
|
756
769
|
advanced: {
|
|
757
770
|
"com.apple.fps": {
|
|
758
|
-
serverCertificateUri:
|
|
771
|
+
serverCertificateUri: playlistSrc.drm.fairplay.certificateUrl
|
|
759
772
|
}
|
|
760
773
|
}
|
|
761
774
|
}
|
|
@@ -876,7 +889,7 @@ var useShakaPlayer = ({
|
|
|
876
889
|
initDataType: session.initDataType,
|
|
877
890
|
keySystem: session.keySystem || "com.widevine.alpha"
|
|
878
891
|
}));
|
|
879
|
-
storePersistentLicense(playlistId,
|
|
892
|
+
storePersistentLicense(playlistId, playlistSrc.drm?.licenseCacheKey ?? "", sessionsToStore);
|
|
880
893
|
storedPersistentThisLoadRef.current = true;
|
|
881
894
|
}
|
|
882
895
|
} catch (e) {
|
|
@@ -2248,7 +2261,7 @@ var Player = (0, import_react13.forwardRef)(
|
|
|
2248
2261
|
const [isScriptsLoaded, setIsScriptsLoaded] = (0, import_react13.useState)(false);
|
|
2249
2262
|
const [isInitialLoading, setIsInitialLoading] = (0, import_react13.useState)(true);
|
|
2250
2263
|
const [bfResetKey, setBfResetKey] = (0, import_react13.useState)(0);
|
|
2251
|
-
const hasPlaylist = !!src && !!(src.url || src.drm?.widevine?.playlistUrl || src.drm?.playready?.playlistUrl || src.drm?.fairplay?.playlistUrl);
|
|
2264
|
+
const hasPlaylist = !!src && (typeof src === "string" || !!(src.url || src.drm?.widevine?.playlistUrl || src.drm?.playready?.playlistUrl || src.drm?.fairplay?.playlistUrl));
|
|
2252
2265
|
(0, import_react13.useImperativeHandle)(ref, () => videoRef.current, []);
|
|
2253
2266
|
const { playerRef, initializePlayer, loadManifest, destroyPlayer, isRetrying } = useShakaPlayer({
|
|
2254
2267
|
src,
|