@mottosports/motto-video-player 1.0.1-rc.29 → 1.0.1-rc.31

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
@@ -1107,7 +1107,7 @@ import { forwardRef, useEffect as useEffect5, useRef as useRef8, useImperativeHa
1107
1107
  import shaka3 from "shaka-player/dist/shaka-player.ui";
1108
1108
 
1109
1109
  // src/hooks/useShakePlayer.ts
1110
- import { useCallback } from "react";
1110
+ import { useRef, useCallback } from "react";
1111
1111
  import shaka from "shaka-player/dist/shaka-player.ui";
1112
1112
 
1113
1113
  // src/utils/devices.ts
@@ -1127,13 +1127,18 @@ var isPlayReadySupported = () => {
1127
1127
  return false;
1128
1128
  }
1129
1129
  const userAgent = navigator.userAgent || "";
1130
- const isWindows = /Windows/.test(userAgent);
1131
1130
  const isXbox = /Xbox/.test(userAgent);
1132
1131
  const isEdge = /Edg/.test(userAgent);
1133
1132
  const isIE = /Trident|MSIE/.test(userAgent);
1134
- return isWindows || isXbox || isEdge || isIE;
1133
+ return isXbox || isEdge || isIE;
1135
1134
  };
1136
1135
 
1136
+ // src/hooks/useShakePlayer.ts
1137
+ import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
1138
+
1139
+ // package.json
1140
+ var version = "1.0.1-rc.31";
1141
+
1137
1142
  // src/hooks/useShakePlayer.ts
1138
1143
  var useShakePlayer = ({
1139
1144
  src,
@@ -1141,9 +1146,11 @@ var useShakePlayer = ({
1141
1146
  drmConfig,
1142
1147
  onError,
1143
1148
  onPlayerReady,
1144
- onBeforeLoad,
1145
- playerRef
1149
+ muxConfig,
1150
+ onMuxReady,
1151
+ onMuxDataUpdate
1146
1152
  }) => {
1153
+ const playerRef = useRef(null);
1147
1154
  const initializePlayer = useCallback(async (video) => {
1148
1155
  try {
1149
1156
  shaka.polyfill.installAll();
@@ -1161,7 +1168,6 @@ var useShakePlayer = ({
1161
1168
  let cert = null;
1162
1169
  if (isDRM) {
1163
1170
  const isPlayReady = isPlayReadySupported();
1164
- const isFairPlay = isAppleDevice();
1165
1171
  if (isAppleDevice() && src.drm.fairplay?.certificate_url) {
1166
1172
  const req = await fetch(src.drm.fairplay.certificate_url);
1167
1173
  cert = await req.arrayBuffer();
@@ -1213,7 +1219,33 @@ var useShakePlayer = ({
1213
1219
  console.error("Shaka Player Error:", error);
1214
1220
  onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1215
1221
  });
1216
- onBeforeLoad?.();
1222
+ if (muxConfig) {
1223
+ try {
1224
+ const playerInitTime = initShakaPlayerMux.utils.now();
1225
+ const muxOptions = {
1226
+ debug: muxConfig.debug || false,
1227
+ disableCookies: muxConfig.disableCookies || false,
1228
+ respectDoNotTrack: muxConfig.respectDoNotTrack || false,
1229
+ automaticErrorTracking: muxConfig.automaticErrorTracking !== false,
1230
+ ...muxConfig.beaconCollectionDomain && { beaconCollectionDomain: muxConfig.beaconCollectionDomain },
1231
+ ...muxConfig.errorTranslator && { errorTranslator: muxConfig.errorTranslator },
1232
+ data: {
1233
+ env_key: muxConfig.envKey,
1234
+ player_name: muxConfig?.metadata?.player_name,
1235
+ player_version: version,
1236
+ player_init_time: playerInitTime,
1237
+ video_title: muxConfig?.metadata?.video_title ?? "",
1238
+ video_id: muxConfig?.metadata?.video_id ?? "",
1239
+ viewer_user_id: muxConfig?.metadata?.viewer_user_id ?? "",
1240
+ ...muxConfig.metadata
1241
+ }
1242
+ };
1243
+ initShakaPlayerMux(player, muxOptions, shaka);
1244
+ onMuxReady?.();
1245
+ } catch (error) {
1246
+ console.error("Failed to initialize Mux Analytics:", error);
1247
+ }
1248
+ }
1217
1249
  await player.load(manifestUrl);
1218
1250
  onPlayerReady?.(player);
1219
1251
  return player;
@@ -1225,7 +1257,7 @@ var useShakePlayer = ({
1225
1257
  onError?.(error);
1226
1258
  throw error;
1227
1259
  }
1228
- }, [shakaConfig, drmConfig, src, onError, onPlayerReady, onBeforeLoad, playerRef]);
1260
+ }, [shakaConfig, drmConfig, src, onError, onPlayerReady, muxConfig, onMuxReady]);
1229
1261
  const destroyPlayer = useCallback(async () => {
1230
1262
  if (playerRef.current) {
1231
1263
  try {
@@ -1238,6 +1270,7 @@ var useShakePlayer = ({
1238
1270
  }
1239
1271
  }, [playerRef]);
1240
1272
  return {
1273
+ playerRef,
1241
1274
  initializePlayer,
1242
1275
  destroyPlayer
1243
1276
  };
@@ -1359,19 +1392,14 @@ var useSkipControls = (videoRef, onSkipBack, onSkipForward) => {
1359
1392
 
1360
1393
  // src/hooks/useMuxAnalytics.ts
1361
1394
  import { useCallback as useCallback4, useRef as useRef3 } from "react";
1362
- import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
1395
+ import initShakaPlayerMux2 from "@mux/mux-data-shakaplayer";
1363
1396
  import shaka2 from "shaka-player/dist/shaka-player.ui";
1364
-
1365
- // package.json
1366
- var version = "1.0.1-rc.29";
1367
-
1368
- // src/hooks/useMuxAnalytics.ts
1369
1397
  var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
1370
1398
  const shakaPlayerMuxRef = useRef3(null);
1371
1399
  const initializeMux = useCallback4(() => {
1372
1400
  if (!muxConfig || !playerRef.current) return;
1373
1401
  try {
1374
- const playerInitTime = initShakaPlayerMux.utils.now();
1402
+ const playerInitTime = initShakaPlayerMux2.utils.now();
1375
1403
  const muxOptions = {
1376
1404
  debug: muxConfig.debug || false,
1377
1405
  disableCookies: muxConfig.disableCookies || false,
@@ -1390,7 +1418,7 @@ var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
1390
1418
  ...muxConfig.metadata
1391
1419
  }
1392
1420
  };
1393
- shakaPlayerMuxRef.current = initShakaPlayerMux(playerRef.current, muxOptions, shaka2);
1421
+ shakaPlayerMuxRef.current = initShakaPlayerMux2(playerRef.current, muxOptions, shaka2);
1394
1422
  onMuxReady?.();
1395
1423
  } catch (error) {
1396
1424
  console.error("Failed to initialize Mux Analytics:", error);
@@ -3268,22 +3296,22 @@ var Player = forwardRef(
3268
3296
  const containerRef = useRef8(null);
3269
3297
  const adContainerRef = useRef8(null);
3270
3298
  useImperativeHandle(ref, () => videoRef.current, []);
3271
- const playerRef = useRef8(null);
3272
- const {
3273
- initializeMux,
3274
- updateMuxData,
3275
- handleMuxError,
3276
- destroyMux
3277
- } = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
3278
- const { initializePlayer, destroyPlayer } = useShakePlayer({
3299
+ const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
3279
3300
  src,
3280
3301
  shakaConfig,
3281
3302
  drmConfig,
3282
3303
  onError: events?.onError,
3283
3304
  onPlayerReady: events?.onPlayerReady,
3284
- onBeforeLoad: initializeMux,
3285
- playerRef
3305
+ muxConfig,
3306
+ onMuxReady: events?.onMuxReady,
3307
+ onMuxDataUpdate: events?.onMuxDataUpdate
3286
3308
  });
3309
+ const {
3310
+ initializeMux,
3311
+ updateMuxData,
3312
+ handleMuxError,
3313
+ destroyMux
3314
+ } = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
3287
3315
  const {
3288
3316
  getAvailableQualities,
3289
3317
  setQuality,