@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.mjs CHANGED
@@ -1295,10 +1295,10 @@ import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
1295
1295
  import shaka from "shaka-player/dist/shaka-player.ui";
1296
1296
 
1297
1297
  // package.json
1298
- var version = "1.0.1-rc.21";
1298
+ var version = "1.0.1-rc.23";
1299
1299
 
1300
1300
  // src/hooks/useMuxAnalytics.ts
1301
- var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate, playerName) => {
1301
+ var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
1302
1302
  const shakaPlayerMuxRef = useRef3(null);
1303
1303
  const initializeMux = useCallback4(() => {
1304
1304
  if (!muxConfig || !playerRef.current) return;
@@ -1313,9 +1313,12 @@ var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate, player
1313
1313
  ...muxConfig.errorTranslator && { errorTranslator: muxConfig.errorTranslator },
1314
1314
  data: {
1315
1315
  env_key: muxConfig.envKey,
1316
- player_name: playerName,
1316
+ player_name: muxConfig?.metadata?.player_name,
1317
1317
  player_version: version,
1318
1318
  player_init_time: playerInitTime,
1319
+ video_title: muxConfig?.metadata?.video_title ?? "",
1320
+ video_id: muxConfig?.metadata?.video_id ?? "",
1321
+ viewer_user_id: muxConfig?.metadata?.viewer_user_id ?? "",
1319
1322
  ...muxConfig.metadata
1320
1323
  }
1321
1324
  };
@@ -3191,7 +3194,6 @@ var Player = forwardRef(
3191
3194
  iconSizes,
3192
3195
  events,
3193
3196
  containerClassName,
3194
- playerName,
3195
3197
  ...videoProps
3196
3198
  }, ref) => {
3197
3199
  const videoRef = useRef8(null);
@@ -3227,7 +3229,7 @@ var Player = forwardRef(
3227
3229
  updateMuxData,
3228
3230
  handleMuxError,
3229
3231
  destroyMux
3230
- } = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate, playerName);
3232
+ } = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
3231
3233
  const { setupEventListeners, cleanupEventListeners } = useEventHandlers(videoRef, {
3232
3234
  onPlay: events?.onPlay,
3233
3235
  onPause: events?.onPause,
@@ -3895,7 +3897,6 @@ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
3895
3897
  var Video = ({
3896
3898
  videoId,
3897
3899
  publicKey,
3898
- mottoToken,
3899
3900
  videoData: providedVideoData,
3900
3901
  refetchInterval = 0,
3901
3902
  playerName,
@@ -3903,6 +3904,8 @@ var Video = ({
3903
3904
  events,
3904
3905
  children,
3905
3906
  className,
3907
+ auth,
3908
+ settings,
3906
3909
  queryOptions = {},
3907
3910
  ...props
3908
3911
  }) => {
@@ -3912,8 +3915,8 @@ var Video = ({
3912
3915
  error,
3913
3916
  refetch
3914
3917
  } = useQuery({
3915
- queryKey: ["video", videoId, publicKey, mottoToken],
3916
- queryFn: () => fetchVideoData(videoId, publicKey, mottoToken),
3918
+ queryKey: ["video", videoId, publicKey, auth?.mottoToken],
3919
+ queryFn: () => fetchVideoData(videoId, publicKey, auth?.mottoToken),
3917
3920
  enabled: !!videoId && !!publicKey && !providedVideoData,
3918
3921
  refetchInterval: refetchInterval > 0 ? refetchInterval : false,
3919
3922
  staleTime: queryOptions.staleTime ?? 5 * 60 * 1e3,
@@ -3963,7 +3966,6 @@ var Video = ({
3963
3966
  children
3964
3967
  ] }) });
3965
3968
  }
3966
- console.log("hlsUrl", hlsUrl);
3967
3969
  return /* @__PURE__ */ jsx9("div", { className: twMerge3("md:rounded-2xl overflow-hidden aspect-video", className), children: /* @__PURE__ */ jsx9("div", { className: "relative w-full h-full", children: /* @__PURE__ */ jsx9(
3968
3970
  Player,
3969
3971
  {
@@ -4078,8 +4080,13 @@ var Event = ({
4078
4080
  const [loadingPlaylist, setLoadingPlaylist] = useState4(true);
4079
4081
  const videosDataError = videosData?.some((video) => !!video.error);
4080
4082
  useEffect8(() => {
4081
- if (eventError || videosError || videosDataError) {
4082
- const errorObj = eventError || videosError || videosData?.find((video) => !!video.error)?.error && new Error(videosData?.find((video) => !!video.error)?.error) || new Error("default");
4083
+ if (isEventLoading || videosIsLoading || loadingApisState) {
4084
+ return;
4085
+ }
4086
+ const hasPlayablePlaylist = Boolean(activePlaylist);
4087
+ if (eventError || videosError || videosDataError && !hasPlayablePlaylist) {
4088
+ const firstVideoError = videosData?.find((video) => !!video.error)?.error;
4089
+ const errorObj = eventError || videosError || firstVideoError && new Error(firstVideoError) || new Error("default");
4083
4090
  setError(errorObj);
4084
4091
  if (events?.onError) {
4085
4092
  events.onError(errorObj);
@@ -4087,7 +4094,17 @@ var Event = ({
4087
4094
  } else {
4088
4095
  setError(null);
4089
4096
  }
4090
- }, [eventError, videosError, videosDataError, videosData, events]);
4097
+ }, [
4098
+ eventError,
4099
+ videosError,
4100
+ videosDataError,
4101
+ videosData,
4102
+ events,
4103
+ activePlaylist,
4104
+ isEventLoading,
4105
+ videosIsLoading,
4106
+ loadingApisState
4107
+ ]);
4091
4108
  useEffect8(() => {
4092
4109
  const eventLoadedWithNoVideos = !isEventLoading && eventData && eventData.videoIds && (!eventData.videoIds || eventData?.videoIds?.length === 0) && !loadingApisState;
4093
4110
  const allApisLoadedWithPotentialVideos = !isEventLoading && !videosIsLoading && eventData && !loadingApisState;