@mottosports/motto-video-player 1.0.1-rc.21 → 1.0.1-rc.23
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 +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +29 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -112,10 +112,6 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
|
|
|
112
112
|
* The source URL of the video (DASH, HLS, or regular MP4)
|
|
113
113
|
*/
|
|
114
114
|
src: string;
|
|
115
|
-
/**
|
|
116
|
-
* The name of the player (used for Mux analytics. For example, 'Web' or 'Mobile App')
|
|
117
|
-
*/
|
|
118
|
-
playerName?: string;
|
|
119
115
|
/**
|
|
120
116
|
* Whether the video should autoplay
|
|
121
117
|
*/
|
|
@@ -397,7 +393,6 @@ declare enum CreativeWorksSortDirection {
|
|
|
397
393
|
interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
398
394
|
videoId?: string;
|
|
399
395
|
publicKey?: string;
|
|
400
|
-
mottoToken?: string;
|
|
401
396
|
videoData?: VideoData;
|
|
402
397
|
refetchInterval?: number;
|
|
403
398
|
playerName?: string;
|
|
@@ -415,6 +410,13 @@ interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
|
415
410
|
};
|
|
416
411
|
children?: React.ReactNode;
|
|
417
412
|
className?: string;
|
|
413
|
+
auth?: {
|
|
414
|
+
mottoToken?: string;
|
|
415
|
+
userId?: string;
|
|
416
|
+
};
|
|
417
|
+
settings?: {
|
|
418
|
+
backgroundImageUrl?: string;
|
|
419
|
+
};
|
|
418
420
|
queryOptions?: {
|
|
419
421
|
enabled?: boolean;
|
|
420
422
|
staleTime?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -112,10 +112,6 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
|
|
|
112
112
|
* The source URL of the video (DASH, HLS, or regular MP4)
|
|
113
113
|
*/
|
|
114
114
|
src: string;
|
|
115
|
-
/**
|
|
116
|
-
* The name of the player (used for Mux analytics. For example, 'Web' or 'Mobile App')
|
|
117
|
-
*/
|
|
118
|
-
playerName?: string;
|
|
119
115
|
/**
|
|
120
116
|
* Whether the video should autoplay
|
|
121
117
|
*/
|
|
@@ -397,7 +393,6 @@ declare enum CreativeWorksSortDirection {
|
|
|
397
393
|
interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
398
394
|
videoId?: string;
|
|
399
395
|
publicKey?: string;
|
|
400
|
-
mottoToken?: string;
|
|
401
396
|
videoData?: VideoData;
|
|
402
397
|
refetchInterval?: number;
|
|
403
398
|
playerName?: string;
|
|
@@ -415,6 +410,13 @@ interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
|
415
410
|
};
|
|
416
411
|
children?: React.ReactNode;
|
|
417
412
|
className?: string;
|
|
413
|
+
auth?: {
|
|
414
|
+
mottoToken?: string;
|
|
415
|
+
userId?: string;
|
|
416
|
+
};
|
|
417
|
+
settings?: {
|
|
418
|
+
backgroundImageUrl?: string;
|
|
419
|
+
};
|
|
418
420
|
queryOptions?: {
|
|
419
421
|
enabled?: boolean;
|
|
420
422
|
staleTime?: number;
|
package/dist/index.js
CHANGED
|
@@ -1336,10 +1336,10 @@ var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
|
1336
1336
|
var import_shaka_player2 = __toESM(require("shaka-player/dist/shaka-player.ui"));
|
|
1337
1337
|
|
|
1338
1338
|
// package.json
|
|
1339
|
-
var version = "1.0.1-rc.
|
|
1339
|
+
var version = "1.0.1-rc.23";
|
|
1340
1340
|
|
|
1341
1341
|
// src/hooks/useMuxAnalytics.ts
|
|
1342
|
-
var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate
|
|
1342
|
+
var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
|
|
1343
1343
|
const shakaPlayerMuxRef = (0, import_react4.useRef)(null);
|
|
1344
1344
|
const initializeMux = (0, import_react4.useCallback)(() => {
|
|
1345
1345
|
if (!muxConfig || !playerRef.current) return;
|
|
@@ -1354,9 +1354,12 @@ var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate, player
|
|
|
1354
1354
|
...muxConfig.errorTranslator && { errorTranslator: muxConfig.errorTranslator },
|
|
1355
1355
|
data: {
|
|
1356
1356
|
env_key: muxConfig.envKey,
|
|
1357
|
-
player_name:
|
|
1357
|
+
player_name: muxConfig?.metadata?.player_name,
|
|
1358
1358
|
player_version: version,
|
|
1359
1359
|
player_init_time: playerInitTime,
|
|
1360
|
+
video_title: muxConfig?.metadata?.video_title ?? "",
|
|
1361
|
+
video_id: muxConfig?.metadata?.video_id ?? "",
|
|
1362
|
+
viewer_user_id: muxConfig?.metadata?.viewer_user_id ?? "",
|
|
1360
1363
|
...muxConfig.metadata
|
|
1361
1364
|
}
|
|
1362
1365
|
};
|
|
@@ -3232,7 +3235,6 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3232
3235
|
iconSizes,
|
|
3233
3236
|
events,
|
|
3234
3237
|
containerClassName,
|
|
3235
|
-
playerName,
|
|
3236
3238
|
...videoProps
|
|
3237
3239
|
}, ref) => {
|
|
3238
3240
|
const videoRef = (0, import_react12.useRef)(null);
|
|
@@ -3268,7 +3270,7 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3268
3270
|
updateMuxData,
|
|
3269
3271
|
handleMuxError,
|
|
3270
3272
|
destroyMux
|
|
3271
|
-
} = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate
|
|
3273
|
+
} = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
|
|
3272
3274
|
const { setupEventListeners, cleanupEventListeners } = useEventHandlers(videoRef, {
|
|
3273
3275
|
onPlay: events?.onPlay,
|
|
3274
3276
|
onPause: events?.onPause,
|
|
@@ -3936,7 +3938,6 @@ var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
|
3936
3938
|
var Video = ({
|
|
3937
3939
|
videoId,
|
|
3938
3940
|
publicKey,
|
|
3939
|
-
mottoToken,
|
|
3940
3941
|
videoData: providedVideoData,
|
|
3941
3942
|
refetchInterval = 0,
|
|
3942
3943
|
playerName,
|
|
@@ -3944,6 +3945,8 @@ var Video = ({
|
|
|
3944
3945
|
events,
|
|
3945
3946
|
children,
|
|
3946
3947
|
className,
|
|
3948
|
+
auth,
|
|
3949
|
+
settings,
|
|
3947
3950
|
queryOptions = {},
|
|
3948
3951
|
...props
|
|
3949
3952
|
}) => {
|
|
@@ -3953,8 +3956,8 @@ var Video = ({
|
|
|
3953
3956
|
error,
|
|
3954
3957
|
refetch
|
|
3955
3958
|
} = (0, import_react_query.useQuery)({
|
|
3956
|
-
queryKey: ["video", videoId, publicKey, mottoToken],
|
|
3957
|
-
queryFn: () => fetchVideoData(videoId, publicKey, mottoToken),
|
|
3959
|
+
queryKey: ["video", videoId, publicKey, auth?.mottoToken],
|
|
3960
|
+
queryFn: () => fetchVideoData(videoId, publicKey, auth?.mottoToken),
|
|
3958
3961
|
enabled: !!videoId && !!publicKey && !providedVideoData,
|
|
3959
3962
|
refetchInterval: refetchInterval > 0 ? refetchInterval : false,
|
|
3960
3963
|
staleTime: queryOptions.staleTime ?? 5 * 60 * 1e3,
|
|
@@ -4004,7 +4007,6 @@ var Video = ({
|
|
|
4004
4007
|
children
|
|
4005
4008
|
] }) });
|
|
4006
4009
|
}
|
|
4007
|
-
console.log("hlsUrl", hlsUrl);
|
|
4008
4010
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: (0, import_tailwind_merge3.twMerge)("md:rounded-2xl overflow-hidden aspect-video", className), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4009
4011
|
Player,
|
|
4010
4012
|
{
|
|
@@ -4119,8 +4121,13 @@ var Event = ({
|
|
|
4119
4121
|
const [loadingPlaylist, setLoadingPlaylist] = (0, import_react15.useState)(true);
|
|
4120
4122
|
const videosDataError = videosData?.some((video) => !!video.error);
|
|
4121
4123
|
(0, import_react15.useEffect)(() => {
|
|
4122
|
-
if (
|
|
4123
|
-
|
|
4124
|
+
if (isEventLoading || videosIsLoading || loadingApisState) {
|
|
4125
|
+
return;
|
|
4126
|
+
}
|
|
4127
|
+
const hasPlayablePlaylist = Boolean(activePlaylist);
|
|
4128
|
+
if (eventError || videosError || videosDataError && !hasPlayablePlaylist) {
|
|
4129
|
+
const firstVideoError = videosData?.find((video) => !!video.error)?.error;
|
|
4130
|
+
const errorObj = eventError || videosError || firstVideoError && new Error(firstVideoError) || new Error("default");
|
|
4124
4131
|
setError(errorObj);
|
|
4125
4132
|
if (events?.onError) {
|
|
4126
4133
|
events.onError(errorObj);
|
|
@@ -4128,7 +4135,17 @@ var Event = ({
|
|
|
4128
4135
|
} else {
|
|
4129
4136
|
setError(null);
|
|
4130
4137
|
}
|
|
4131
|
-
}, [
|
|
4138
|
+
}, [
|
|
4139
|
+
eventError,
|
|
4140
|
+
videosError,
|
|
4141
|
+
videosDataError,
|
|
4142
|
+
videosData,
|
|
4143
|
+
events,
|
|
4144
|
+
activePlaylist,
|
|
4145
|
+
isEventLoading,
|
|
4146
|
+
videosIsLoading,
|
|
4147
|
+
loadingApisState
|
|
4148
|
+
]);
|
|
4132
4149
|
(0, import_react15.useEffect)(() => {
|
|
4133
4150
|
const eventLoadedWithNoVideos = !isEventLoading && eventData && eventData.videoIds && (!eventData.videoIds || eventData?.videoIds?.length === 0) && !loadingApisState;
|
|
4134
4151
|
const allApisLoadedWithPotentialVideos = !isEventLoading && !videosIsLoading && eventData && !loadingApisState;
|