@mottosports/motto-video-player 1.0.1-rc.26 → 1.0.1-rc.28

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 CHANGED
@@ -1196,13 +1196,35 @@ var useShakePlayer = ({
1196
1196
  if (shakaConfig) {
1197
1197
  player.configure(shakaConfig);
1198
1198
  }
1199
+ player?.addEventListener("error", (event) => {
1200
+ const error = event.detail;
1201
+ if (error?.code === 7e3) {
1202
+ return;
1203
+ }
1204
+ console.error("Shaka Player Error:", error);
1205
+ onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1206
+ });
1207
+ return player;
1208
+ } catch (error) {
1209
+ if (error?.code === 7e3) {
1210
+ return;
1211
+ }
1212
+ console.error("Error initializing Shaka Player:", error);
1213
+ onError?.(error);
1214
+ throw error;
1215
+ }
1216
+ }, [shakaConfig, drmConfig, src, onError, onPlayerReady]);
1217
+ const loadSource = (0, import_react.useCallback)(async () => {
1218
+ const player = playerRef.current;
1219
+ if (!player) return;
1220
+ try {
1199
1221
  let manifestUrl = src.url;
1200
1222
  const isDRM = Boolean(src.drm);
1201
1223
  let cert = null;
1202
1224
  if (isDRM) {
1203
1225
  const isPlayReady = isPlayReadySupported();
1204
1226
  const isFairPlay = isAppleDevice();
1205
- if (isAppleDevice() && src.drm.fairplay?.certificate_url) {
1227
+ if (isFairPlay && src.drm.fairplay?.certificate_url) {
1206
1228
  const req = await fetch(src.drm.fairplay.certificate_url);
1207
1229
  cert = await req.arrayBuffer();
1208
1230
  manifestUrl = src.drm.fairplay.playlist_url;
@@ -1245,26 +1267,17 @@ var useShakePlayer = ({
1245
1267
  });
1246
1268
  }
1247
1269
  }
1248
- player?.addEventListener("error", (event) => {
1249
- const error = event.detail;
1250
- if (error?.code === 7e3) {
1251
- return;
1252
- }
1253
- console.error("Shaka Player Error:", error);
1254
- onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1255
- });
1256
1270
  await player.load(manifestUrl);
1257
1271
  onPlayerReady?.(player);
1258
- return player;
1259
1272
  } catch (error) {
1260
1273
  if (error?.code === 7e3) {
1261
1274
  return;
1262
1275
  }
1263
- console.error("Error initializing Shaka Player:", error);
1276
+ console.error("Error loading source:", error);
1264
1277
  onError?.(error);
1265
1278
  throw error;
1266
1279
  }
1267
- }, [shakaConfig, drmConfig, src, onError, onPlayerReady]);
1280
+ }, [src, onError]);
1268
1281
  const destroyPlayer = (0, import_react.useCallback)(async () => {
1269
1282
  if (playerRef.current) {
1270
1283
  try {
@@ -1279,6 +1292,7 @@ var useShakePlayer = ({
1279
1292
  return {
1280
1293
  playerRef,
1281
1294
  initializePlayer,
1295
+ loadSource,
1282
1296
  destroyPlayer
1283
1297
  };
1284
1298
  };
@@ -1403,7 +1417,7 @@ var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
1403
1417
  var import_shaka_player2 = __toESM(require("shaka-player/dist/shaka-player.ui"));
1404
1418
 
1405
1419
  // package.json
1406
- var version = "1.0.1-rc.26";
1420
+ var version = "1.0.1-rc.28";
1407
1421
 
1408
1422
  // src/hooks/useMuxAnalytics.ts
1409
1423
  var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
@@ -3308,7 +3322,7 @@ var Player = (0, import_react12.forwardRef)(
3308
3322
  const containerRef = (0, import_react12.useRef)(null);
3309
3323
  const adContainerRef = (0, import_react12.useRef)(null);
3310
3324
  (0, import_react12.useImperativeHandle)(ref, () => videoRef.current, []);
3311
- const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
3325
+ const { playerRef, initializePlayer, loadSource, destroyPlayer } = useShakePlayer({
3312
3326
  src,
3313
3327
  shakaConfig,
3314
3328
  drmConfig,
@@ -3416,11 +3430,12 @@ var Player = (0, import_react12.forwardRef)(
3416
3430
  const initialize = async () => {
3417
3431
  try {
3418
3432
  await initializePlayer(video);
3433
+ initializeMux();
3434
+ await loadSource();
3419
3435
  setupEventListeners();
3420
3436
  const cleanupQuality = setupQualityTracking();
3421
3437
  configureQuality();
3422
3438
  await initializeUI();
3423
- initializeMux();
3424
3439
  initializeAds();
3425
3440
  initializeChromecast();
3426
3441
  } catch (error) {