@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.mjs CHANGED
@@ -1155,13 +1155,35 @@ var useShakePlayer = ({
1155
1155
  if (shakaConfig) {
1156
1156
  player.configure(shakaConfig);
1157
1157
  }
1158
+ player?.addEventListener("error", (event) => {
1159
+ const error = event.detail;
1160
+ if (error?.code === 7e3) {
1161
+ return;
1162
+ }
1163
+ console.error("Shaka Player Error:", error);
1164
+ onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1165
+ });
1166
+ return player;
1167
+ } catch (error) {
1168
+ if (error?.code === 7e3) {
1169
+ return;
1170
+ }
1171
+ console.error("Error initializing Shaka Player:", error);
1172
+ onError?.(error);
1173
+ throw error;
1174
+ }
1175
+ }, [shakaConfig, drmConfig, src, onError, onPlayerReady]);
1176
+ const loadSource = useCallback(async () => {
1177
+ const player = playerRef.current;
1178
+ if (!player) return;
1179
+ try {
1158
1180
  let manifestUrl = src.url;
1159
1181
  const isDRM = Boolean(src.drm);
1160
1182
  let cert = null;
1161
1183
  if (isDRM) {
1162
1184
  const isPlayReady = isPlayReadySupported();
1163
1185
  const isFairPlay = isAppleDevice();
1164
- if (isAppleDevice() && src.drm.fairplay?.certificate_url) {
1186
+ if (isFairPlay && src.drm.fairplay?.certificate_url) {
1165
1187
  const req = await fetch(src.drm.fairplay.certificate_url);
1166
1188
  cert = await req.arrayBuffer();
1167
1189
  manifestUrl = src.drm.fairplay.playlist_url;
@@ -1204,26 +1226,17 @@ var useShakePlayer = ({
1204
1226
  });
1205
1227
  }
1206
1228
  }
1207
- player?.addEventListener("error", (event) => {
1208
- const error = event.detail;
1209
- if (error?.code === 7e3) {
1210
- return;
1211
- }
1212
- console.error("Shaka Player Error:", error);
1213
- onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1214
- });
1215
1229
  await player.load(manifestUrl);
1216
1230
  onPlayerReady?.(player);
1217
- return player;
1218
1231
  } catch (error) {
1219
1232
  if (error?.code === 7e3) {
1220
1233
  return;
1221
1234
  }
1222
- console.error("Error initializing Shaka Player:", error);
1235
+ console.error("Error loading source:", error);
1223
1236
  onError?.(error);
1224
1237
  throw error;
1225
1238
  }
1226
- }, [shakaConfig, drmConfig, src, onError, onPlayerReady]);
1239
+ }, [src, onError]);
1227
1240
  const destroyPlayer = useCallback(async () => {
1228
1241
  if (playerRef.current) {
1229
1242
  try {
@@ -1238,6 +1251,7 @@ var useShakePlayer = ({
1238
1251
  return {
1239
1252
  playerRef,
1240
1253
  initializePlayer,
1254
+ loadSource,
1241
1255
  destroyPlayer
1242
1256
  };
1243
1257
  };
@@ -1362,7 +1376,7 @@ import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
1362
1376
  import shaka2 from "shaka-player/dist/shaka-player.ui";
1363
1377
 
1364
1378
  // package.json
1365
- var version = "1.0.1-rc.26";
1379
+ var version = "1.0.1-rc.28";
1366
1380
 
1367
1381
  // src/hooks/useMuxAnalytics.ts
1368
1382
  var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
@@ -3267,7 +3281,7 @@ var Player = forwardRef(
3267
3281
  const containerRef = useRef8(null);
3268
3282
  const adContainerRef = useRef8(null);
3269
3283
  useImperativeHandle(ref, () => videoRef.current, []);
3270
- const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
3284
+ const { playerRef, initializePlayer, loadSource, destroyPlayer } = useShakePlayer({
3271
3285
  src,
3272
3286
  shakaConfig,
3273
3287
  drmConfig,
@@ -3375,11 +3389,12 @@ var Player = forwardRef(
3375
3389
  const initialize = async () => {
3376
3390
  try {
3377
3391
  await initializePlayer(video);
3392
+ initializeMux();
3393
+ await loadSource();
3378
3394
  setupEventListeners();
3379
3395
  const cleanupQuality = setupQualityTracking();
3380
3396
  configureQuality();
3381
3397
  await initializeUI();
3382
- initializeMux();
3383
3398
  initializeAds();
3384
3399
  initializeChromecast();
3385
3400
  } catch (error) {