@mottosports/motto-video-player 1.0.1-rc.33 → 1.0.1-rc.36

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
@@ -374,9 +374,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
374
374
  .grid {
375
375
  display: grid;
376
376
  }
377
- .hidden {
378
- display: none;
379
- }
380
377
  .aspect-video {
381
378
  aspect-ratio: var(--aspect-video);
382
379
  }
@@ -1106,7 +1103,7 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
1106
1103
  `);
1107
1104
 
1108
1105
  // src/Player.tsx
1109
- import { forwardRef, useEffect as useEffect5, useRef as useRef8, useImperativeHandle, useMemo } from "react";
1106
+ import { forwardRef, useEffect as useEffect5, useRef as useRef8, useImperativeHandle } from "react";
1110
1107
  import shaka3 from "shaka-player/dist/shaka-player.ui";
1111
1108
 
1112
1109
  // src/hooks/useShakePlayer.ts
@@ -1140,7 +1137,7 @@ var isPlayReadySupported = () => {
1140
1137
  import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
1141
1138
 
1142
1139
  // package.json
1143
- var version = "1.0.1-rc.33";
1140
+ var version = "1.0.1-rc.36";
1144
1141
 
1145
1142
  // src/hooks/useShakePlayer.ts
1146
1143
  var useShakePlayer = ({
@@ -1154,62 +1151,38 @@ var useShakePlayer = ({
1154
1151
  onMuxDataUpdate
1155
1152
  }) => {
1156
1153
  const playerRef = useRef(null);
1157
- const isDestroyingRef = useRef(false);
1158
1154
  const initializePlayer = useCallback(async (video) => {
1159
- console.log("\u{1F3AC} PLAYER-INIT: Starting player initialization...");
1160
- const startTime = performance.now();
1161
1155
  try {
1162
- console.log("\u{1F3AC} PLAYER-INIT: Installing polyfills...");
1163
1156
  shaka.polyfill.installAll();
1164
- console.log("\u{1F3AC} PLAYER-INIT: Polyfills installed successfully");
1165
- console.log("\u{1F3AC} PLAYER-INIT: Checking browser support...");
1166
1157
  if (!shaka.Player.isBrowserSupported()) {
1167
- console.error("\u{1F3AC} PLAYER-INIT: Browser not supported by Shaka Player");
1168
1158
  throw new Error("Browser not supported by Shaka Player");
1169
1159
  }
1170
- console.log("\u{1F3AC} PLAYER-INIT: Browser support confirmed");
1171
- console.log("\u{1F3AC} PLAYER-INIT: Creating player instance...");
1172
1160
  const player = new shaka.Player();
1173
1161
  playerRef.current = player;
1174
- console.log("\u{1F3AC} PLAYER-INIT: Player instance created successfully");
1175
- console.log("\u{1F3AC} PLAYER-INIT: Attaching player to video element...");
1176
1162
  await player.attach(video);
1177
- console.log("\u{1F3AC} PLAYER-INIT: Player attached to video element successfully");
1178
- console.log("\u{1F3AC} PLAYER-INIT: Configuring player...");
1179
1163
  if (shakaConfig) {
1180
- console.log("\u{1F3AC} PLAYER-INIT: Applying custom shaka config:", shakaConfig);
1181
1164
  player.configure(shakaConfig);
1182
- console.log("\u{1F3AC} PLAYER-INIT: Custom shaka config applied");
1183
- } else {
1184
- console.log("\u{1F3AC} PLAYER-INIT: No custom shaka config provided");
1185
1165
  }
1186
1166
  let manifestUrl = src.url;
1187
1167
  const isDRM = Boolean(src.drm);
1188
1168
  let cert = null;
1189
1169
  if (isDRM) {
1190
- console.log("\u{1F3AC} PLAYER-INIT: DRM detected, setting up DRM configuration...");
1191
1170
  const isPlayReady = isPlayReadySupported();
1192
- console.log("\u{1F3AC} PLAYER-INIT: Device capabilities - Apple:", isAppleDevice(), "PlayReady:", isPlayReady);
1193
- if (isAppleDevice() && src.drm.fairplay?.certificate_url) {
1194
- console.log("\u{1F3AC} PLAYER-INIT: Setting up FairPlay DRM...");
1195
- const req = await fetch(src.drm.fairplay.certificate_url);
1171
+ if (isAppleDevice() && src.drm.fairplay?.certificateUrl) {
1172
+ const req = await fetch(src.drm.fairplay.certificateUrl);
1196
1173
  cert = await req.arrayBuffer();
1197
- manifestUrl = src.drm.fairplay.playlist_url;
1198
- console.log("\u{1F3AC} PLAYER-INIT: FairPlay certificate loaded");
1199
- } else if (isPlayReady && src.drm.playready?.license_url) {
1200
- console.log("\u{1F3AC} PLAYER-INIT: Setting up PlayReady DRM...");
1201
- manifestUrl = src.drm.playready.playlist_url;
1174
+ manifestUrl = src.drm.fairplay.playlistUrl;
1175
+ } else if (isPlayReady && src.drm.playready?.licenseUrl) {
1176
+ manifestUrl = src.drm.playready.playlistUrl;
1202
1177
  } else {
1203
- console.log("\u{1F3AC} PLAYER-INIT: Setting up Widevine DRM...");
1204
- manifestUrl = src.drm?.widevine?.playlist_url || "";
1178
+ manifestUrl = src.drm?.widevine?.playlistUrl || "";
1205
1179
  }
1206
- console.log("\u{1F3AC} PLAYER-INIT: Configuring DRM servers...");
1207
- const drmConfig2 = {
1180
+ player.configure({
1208
1181
  drm: {
1209
1182
  servers: {
1210
- "com.widevine.alpha": src.drm.widevine?.license_url,
1211
- "com.microsoft.playready": src.drm.playready?.license_url,
1212
- "com.apple.fps": src.drm.fairplay?.license_url
1183
+ "com.widevine.alpha": src.drm.widevine?.licenseUrl,
1184
+ "com.microsoft.playready": src.drm.playready?.licenseUrl,
1185
+ "com.apple.fps": src.drm.fairplay?.licenseUrl
1213
1186
  },
1214
1187
  ...cert && {
1215
1188
  advanced: {
@@ -1219,52 +1192,34 @@ var useShakePlayer = ({
1219
1192
  }
1220
1193
  }
1221
1194
  }
1222
- };
1223
- console.log("\u{1F3AC} PLAYER-INIT: DRM config:", drmConfig2);
1224
- player.configure(drmConfig2);
1225
- console.log("\u{1F3AC} PLAYER-INIT: DRM configuration applied");
1226
- console.log("\u{1F3AC} PLAYER-INIT: Setting up DRM network filters...");
1195
+ });
1227
1196
  const netEngine = player.getNetworkingEngine();
1228
1197
  if (netEngine) {
1229
- console.log("\u{1F3AC} PLAYER-INIT: Registering DRM request filter...");
1230
1198
  netEngine.registerRequestFilter((type, request) => {
1231
1199
  if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
1232
- console.log("\u{1F3AC} PLAYER-INIT: Adding DRM token to license request");
1233
- request.headers["x-dt-custom-data"] = src.drm.token;
1200
+ request.headers["x-dt-auth-token"] = src.drm.token;
1234
1201
  }
1235
1202
  });
1236
- console.log("\u{1F3AC} PLAYER-INIT: Registering DRM response filter...");
1237
1203
  netEngine.registerResponseFilter((type, response) => {
1238
1204
  if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
1239
1205
  const ks = player.keySystem && player.keySystem();
1240
1206
  if (ks === "com.apple.fps") {
1241
- console.log("\u{1F3AC} PLAYER-INIT: Processing FairPlay license response");
1242
1207
  const responseText = shaka.util.StringUtils.fromUTF8(response.data);
1243
1208
  response.data = shaka.util.Uint8ArrayUtils.fromBase64(responseText).buffer;
1244
1209
  }
1245
1210
  }
1246
1211
  });
1247
- console.log("\u{1F3AC} PLAYER-INIT: DRM network filters registered");
1248
- } else {
1249
- console.warn("\u{1F3AC} PLAYER-INIT: No networking engine available for DRM filters");
1250
1212
  }
1251
- } else {
1252
- console.log("\u{1F3AC} PLAYER-INIT: No DRM configuration needed");
1253
1213
  }
1254
- console.log("\u{1F3AC} PLAYER-INIT: Setting up error handling...");
1255
1214
  player?.addEventListener("error", (event) => {
1256
1215
  const error = event.detail;
1257
1216
  if (error?.code === 7e3) {
1258
- console.log("\u{1F3AC} PLAYER-INIT: Ignoring benign LOAD_INTERRUPTED error (7000)");
1259
1217
  return;
1260
1218
  }
1261
- console.error("\u{1F3AC} PLAYER-INIT: Shaka Player Error:", error);
1219
+ console.error("Shaka Player Error:", error);
1262
1220
  onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1263
1221
  });
1264
- console.log("\u{1F3AC} PLAYER-INIT: Error handling configured");
1265
- console.log("\u{1F3AC} PLAYER-INIT: Checking Mux configuration...");
1266
1222
  if (muxConfig) {
1267
- console.log("\u{1F3AC} PLAYER-INIT: Initializing Mux Analytics...");
1268
1223
  try {
1269
1224
  const playerInitTime = initShakaPlayerMux.utils.now();
1270
1225
  const muxOptions = {
@@ -1285,54 +1240,33 @@ var useShakePlayer = ({
1285
1240
  ...muxConfig.metadata
1286
1241
  }
1287
1242
  };
1288
- console.log("\u{1F3AC} PLAYER-INIT: Mux options:", muxOptions);
1289
1243
  initShakaPlayerMux(player, muxOptions, shaka);
1290
- console.log("\u{1F3AC} PLAYER-INIT: Mux Analytics initialized successfully");
1291
1244
  onMuxReady?.();
1292
1245
  } catch (error) {
1293
- console.error("\u{1F3AC} PLAYER-INIT: Failed to initialize Mux Analytics:", error);
1246
+ console.error("Failed to initialize Mux Analytics:", error);
1294
1247
  }
1295
- } else {
1296
- console.log("\u{1F3AC} PLAYER-INIT: No Mux configuration provided");
1297
1248
  }
1298
- console.log("\u{1F3AC} PLAYER-INIT: Loading manifest:", manifestUrl);
1299
- console.log("\u{1F3AC} PLAYER-INIT: CRITICAL - Using manifestUrl instead of hardcoded URL");
1300
1249
  await player.load(manifestUrl);
1301
- console.log("\u{1F3AC} PLAYER-INIT: Manifest loaded successfully");
1302
- const endTime = performance.now();
1303
- console.log(`\u{1F3AC} PLAYER-INIT: Player initialization completed in ${(endTime - startTime).toFixed(2)}ms`);
1304
1250
  onPlayerReady?.(player);
1305
1251
  return player;
1306
1252
  } catch (error) {
1307
1253
  if (error?.code === 7e3) {
1308
- console.log("\u{1F3AC} PLAYER-INIT: Caught benign LOAD_INTERRUPTED error during initialization");
1309
1254
  return;
1310
1255
  }
1311
- const endTime = performance.now();
1312
- console.error(`\u{1F3AC} PLAYER-INIT: Error during initialization after ${(endTime - startTime).toFixed(2)}ms:`, error);
1256
+ console.error("Error initializing Shaka Player:", error);
1313
1257
  onError?.(error);
1314
1258
  throw error;
1315
1259
  }
1316
1260
  }, [shakaConfig, drmConfig, src, onError, onPlayerReady, muxConfig, onMuxReady]);
1317
1261
  const destroyPlayer = useCallback(async () => {
1318
- if (playerRef.current && !isDestroyingRef.current) {
1319
- isDestroyingRef.current = true;
1320
- console.log("\u{1F3AC} PLAYER-DESTROY: Setting destroy flag to prevent race conditions");
1262
+ if (playerRef.current) {
1321
1263
  try {
1322
- console.log("\u{1F3AC} PLAYER-DESTROY: Destroying player instance...");
1323
1264
  await playerRef.current.destroy();
1324
- console.log("\u{1F3AC} PLAYER-DESTROY: Player instance destroyed successfully");
1325
1265
  } catch (error) {
1326
- console.warn("\u{1F3AC} PLAYER-DESTROY: Error destroying Shaka Player:", error);
1266
+ console.warn("Error destroying Shaka Player:", error);
1327
1267
  } finally {
1328
1268
  playerRef.current = null;
1329
- isDestroyingRef.current = false;
1330
- console.log("\u{1F3AC} PLAYER-DESTROY: Player reference cleared and destroy flag reset");
1331
1269
  }
1332
- } else if (isDestroyingRef.current) {
1333
- console.log("\u{1F3AC} PLAYER-DESTROY: Destroy already in progress, skipping...");
1334
- } else {
1335
- console.log("\u{1F3AC} PLAYER-DESTROY: No player instance to destroy");
1336
1270
  }
1337
1271
  }, [playerRef]);
1338
1272
  return {
@@ -1750,198 +1684,20 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
1750
1684
  const uiRef = useRef4(null);
1751
1685
  const registeredElements = useRef4(/* @__PURE__ */ new Set());
1752
1686
  const initializeUI = useCallback5(async () => {
1753
- console.log("\u{1F3AE} UI-INIT: Starting Shaka UI initialization...");
1754
- const startTime = performance.now();
1755
- if (!controls) {
1756
- console.log("\u{1F3AE} UI-INIT: Controls disabled, skipping UI initialization");
1757
- return null;
1758
- }
1759
- if (!containerRef.current) {
1760
- console.warn("\u{1F3AE} UI-INIT: Container ref not available, skipping UI initialization");
1761
- return null;
1762
- }
1763
- if (!playerRef.current) {
1764
- console.warn("\u{1F3AE} UI-INIT: Player ref not available, skipping UI initialization");
1765
- console.warn("\u{1F3AE} UI-INIT: This might be due to a race condition - player destroyed before UI init");
1766
- console.log("\u{1F3AE} UI-INIT: Attempting to wait for player reference...");
1767
- let waitAttempts = 0;
1768
- const maxWaitAttempts = 10;
1769
- while (!playerRef.current && waitAttempts < maxWaitAttempts) {
1770
- await new Promise((resolve) => setTimeout(resolve, 100));
1771
- waitAttempts++;
1772
- console.log(`\u{1F3AE} UI-INIT: Waiting for player ref... attempt ${waitAttempts}`);
1773
- }
1774
- if (!playerRef.current) {
1775
- console.error("\u{1F3AE} UI-INIT: Player ref still not available after waiting, aborting UI initialization");
1776
- return null;
1777
- } else {
1778
- console.log(`\u{1F3AE} UI-INIT: Player ref became available after ${waitAttempts * 100}ms`);
1779
- }
1780
- }
1781
- const player = playerRef.current;
1782
- console.log("\u{1F3AE} UI-INIT: RACE CHECK - Player state analysis:");
1783
- console.log("\u{1F3AE} UI-INIT: - Player exists:", !!player);
1784
- if (!player) {
1785
- console.error("\u{1F3AE} UI-INIT: CRITICAL - Player reference is null during UI initialization!");
1786
- console.error("\u{1F3AE} UI-INIT: This indicates a race condition between player destruction and UI initialization");
1787
- return null;
1788
- }
1789
- console.log("\u{1F3AE} UI-INIT: - Player isDestroyed:", player.isDestroyed && player.isDestroyed());
1790
- console.log("\u{1F3AE} UI-INIT: - Player getNetworkingEngine:", !!player.getNetworkingEngine());
1791
- console.log("\u{1F3AE} UI-INIT: - Player getConfiguration:", !!player.getConfiguration);
1792
- try {
1793
- const config = player.getConfiguration();
1794
- console.log("\u{1F3AE} UI-INIT: - Player configuration available:", !!config);
1795
- if (player.isDestroyed && player.isDestroyed()) {
1796
- console.error("\u{1F3AE} UI-INIT: CRITICAL - Player is destroyed, aborting UI initialization");
1797
- return null;
1798
- }
1799
- } catch (error) {
1800
- console.warn("\u{1F3AE} UI-INIT: - WARNING: Could not get player configuration:", error);
1801
- console.warn("\u{1F3AE} UI-INIT: - This may indicate the player is in an invalid state");
1802
- return null;
1803
- }
1804
- if (!videoRef.current) {
1805
- console.warn("\u{1F3AE} UI-INIT: Video ref not available, skipping UI initialization");
1687
+ if (!controls || !containerRef.current || !playerRef.current || !videoRef.current) {
1806
1688
  return null;
1807
1689
  }
1808
- console.log("\u{1F3AE} UI-INIT: All prerequisites met, proceeding with initialization");
1809
- const chromecastAPICheck = {
1810
- chromeExists: !!window.chrome,
1811
- castExists: !!window.chrome?.cast,
1812
- isAvailable: !!window.chrome?.cast?.isAvailable,
1813
- sessionExists: !!window.chrome?.cast?.Session,
1814
- receiverExists: !!window.chrome?.cast?.ReceiverAvailability
1815
- };
1816
- console.log("\u{1F3AE} UI-INIT: CRITICAL - Chromecast API state before UI init:", chromecastAPICheck);
1817
- if (chromecastConfig) {
1818
- try {
1819
- console.log("\u{1F3AE} CAST-DIAG: Secure context:", window.isSecureContext, "Protocol:", window.location.protocol);
1820
- console.log("\u{1F3AE} CAST-DIAG: UserAgent:", navigator.userAgent);
1821
- console.log("\u{1F3AE} CAST-DIAG: In iframe:", window.top !== window.self);
1822
- const existingCastScript = document.querySelector('script#gcast_sender, script[src*="cast_sender.js"]');
1823
- if (existingCastScript) {
1824
- console.log("\u{1F3AE} CAST-DIAG: Found existing cast sender script:", {
1825
- id: existingCastScript.id,
1826
- src: existingCastScript.src,
1827
- async: existingCastScript.async,
1828
- defer: existingCastScript.defer,
1829
- dataset: existingCastScript.dataset
1830
- });
1831
- } else {
1832
- console.log("\u{1F3AE} CAST-DIAG: No cast sender script present yet");
1833
- }
1834
- } catch (e) {
1835
- console.warn("\u{1F3AE} CAST-DIAG: Environment diagnostics failed", e);
1836
- }
1837
- const hasCastFramework = !!window.chrome?.cast?.framework?.CastContext;
1838
- if (!hasCastFramework) {
1839
- console.warn("\u{1F3AE} UI-INIT: Cast Framework not loaded. Attempting to load sender library...");
1840
- const loadCastFramework = () => new Promise((resolve) => {
1841
- if (window.chrome?.cast?.framework?.CastContext) {
1842
- return resolve();
1843
- }
1844
- if (!document.getElementById("gcast_sender")) {
1845
- const script = document.createElement("script");
1846
- script.id = "gcast_sender";
1847
- script.src = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
1848
- script.async = true;
1849
- script.defer = true;
1850
- script.addEventListener("load", () => {
1851
- console.log("\u{1F3AE} CAST-LOAD: cast_sender.js loaded");
1852
- });
1853
- script.addEventListener("error", (err) => {
1854
- console.error("\u{1F3AE} CAST-LOAD: cast_sender.js failed to load", err);
1855
- });
1856
- document.head.appendChild(script);
1857
- console.log("\u{1F3AE} CAST-LOAD: Injected cast sender script tag");
1858
- }
1859
- const previousCallback = window.__onGCastApiAvailable;
1860
- window.__onGCastApiAvailable = (isAvailable) => {
1861
- console.log("\u{1F3AE} UI-INIT: __onGCastApiAvailable called. Available:", isAvailable);
1862
- try {
1863
- console.log("\u{1F3AE} CAST-CB: chrome.cast exists:", !!window.chrome?.cast);
1864
- console.log("\u{1F3AE} CAST-CB: chrome.cast.isAvailable:", !!window.chrome?.cast?.isAvailable);
1865
- console.log("\u{1F3AE} CAST-CB: chrome.cast.framework exists:", !!window.chrome?.cast?.framework);
1866
- console.log("\u{1F3AE} CAST-CB: CastContext exists:", !!window.chrome?.cast?.framework?.CastContext);
1867
- } catch (e) {
1868
- console.warn("\u{1F3AE} CAST-CB: Diagnostics failed", e);
1869
- }
1870
- if (typeof previousCallback === "function") {
1871
- try {
1872
- previousCallback(isAvailable);
1873
- } catch {
1874
- }
1875
- }
1876
- resolve();
1877
- };
1878
- let attempts = 0;
1879
- const maxAttempts = 50;
1880
- const poll = setInterval(() => {
1881
- attempts++;
1882
- const hasCast = !!window.chrome?.cast;
1883
- const hasFramework = !!window.chrome?.cast?.framework;
1884
- const hasContext = !!window.chrome?.cast?.framework?.CastContext;
1885
- if (attempts % 10 === 0) {
1886
- console.log(`\u{1F3AE} CAST-POLL: attempt=${attempts} cast=${hasCast} framework=${hasFramework} context=${hasContext}`);
1887
- }
1888
- if (hasContext || attempts >= maxAttempts) {
1889
- clearInterval(poll);
1890
- resolve();
1891
- }
1892
- }, 100);
1893
- });
1894
- await loadCastFramework();
1895
- console.log("\u{1F3AE} UI-INIT: Cast Framework load attempt complete. Framework present:", !!window.chrome?.cast?.framework?.CastContext);
1896
- if (!window.chrome?.cast?.framework?.CastContext) {
1897
- console.warn("\u{1F3AE} UI-INIT: CastContext still missing after load. Potential causes:");
1898
- console.warn("\u{1F3AE} UI-INIT: - Script blocked by CSP/adblock");
1899
- console.warn("\u{1F3AE} UI-INIT: - Non-secure origin (requires https/localhost)");
1900
- console.warn("\u{1F3AE} UI-INIT: - Non-Chrome browser or incognito restrictions");
1901
- }
1902
- }
1903
- }
1904
- if (chromecastConfig && !chromecastAPICheck.castExists) {
1905
- console.warn("\u{1F3AE} UI-INIT: WARNING - Chromecast config provided but Cast API not available!");
1906
- console.warn("\u{1F3AE} UI-INIT: This could cause race condition issues");
1907
- console.log("\u{1F3AE} UI-INIT: Waiting for Cast API to be available...");
1908
- let waitAttempts = 0;
1909
- const maxWaitAttempts = 50;
1910
- while (!window.chrome?.cast?.isAvailable && waitAttempts < maxWaitAttempts) {
1911
- await new Promise((resolve) => setTimeout(resolve, 100));
1912
- waitAttempts++;
1913
- if (waitAttempts % 10 === 0) {
1914
- console.log(`\u{1F3AE} UI-INIT: Still waiting for Cast API... (${waitAttempts * 100}ms)`);
1915
- }
1916
- }
1917
- if (window.chrome?.cast?.isAvailable) {
1918
- console.log(`\u{1F3AE} UI-INIT: Cast API became available after ${waitAttempts * 100}ms`);
1919
- } else {
1920
- console.warn(`\u{1F3AE} UI-INIT: Cast API not available after ${waitAttempts * 100}ms, proceeding anyway`);
1921
- }
1922
- }
1923
- console.log("\u{1F3AE} UI-INIT: Registering custom UI elements...");
1924
1690
  if (!registeredElements.current.has("skip_back_button")) {
1925
- console.log("\u{1F3AE} UI-INIT: Registering skip_back_button element");
1926
1691
  ShakaUI.Controls.registerElement("skip_back_button", new SkipBackButtonFactory(onSkipBack, iconSizes?.skipButtons));
1927
1692
  registeredElements.current.add("skip_back_button");
1928
- } else {
1929
- console.log("\u{1F3AE} UI-INIT: skip_back_button already registered");
1930
1693
  }
1931
1694
  if (!registeredElements.current.has("skip_forward_button")) {
1932
- console.log("\u{1F3AE} UI-INIT: Registering skip_forward_button element");
1933
1695
  ShakaUI.Controls.registerElement("skip_forward_button", new SkipForwardButtonFactory(onSkipForward, iconSizes?.skipButtons));
1934
1696
  registeredElements.current.add("skip_forward_button");
1935
- } else {
1936
- console.log("\u{1F3AE} UI-INIT: skip_forward_button already registered");
1937
1697
  }
1938
- console.log("\u{1F3AE} UI-INIT: Creating Shaka UI Overlay...");
1939
1698
  const ui = new ShakaUI.Overlay(playerRef.current, containerRef.current, videoRef.current);
1940
1699
  uiRef.current = ui;
1941
- console.log("\u{1F3AE} UI-INIT: Shaka UI Overlay created successfully");
1942
1700
  const isMobile = window.innerWidth <= 767;
1943
- console.log("\u{1F3AE} UI-INIT: Device detection - Mobile:", isMobile, "Width:", window.innerWidth);
1944
- console.log("\u{1F3AE} UI-INIT: Building control panel elements...");
1945
1701
  const controlPanelElements = [
1946
1702
  ...isMobile ? [] : ["skip_back_button"],
1947
1703
  ...isMobile ? [] : ["play_pause"],
@@ -1956,11 +1712,6 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
1956
1712
  // Always show cast button
1957
1713
  "overflow_menu"
1958
1714
  ];
1959
- console.log("\u{1F3AE} UI-INIT: Control panel elements:", controlPanelElements);
1960
- console.log("\u{1F3AE} UI-INIT: Configuring Chromecast settings...");
1961
- const castReceiverAppId = chromecastConfig?.receiverApplicationId || "CC1AD845";
1962
- console.log("\u{1F3AE} UI-INIT: Cast receiver app ID:", castReceiverAppId);
1963
- console.log("\u{1F3AE} UI-INIT: Chromecast config provided:", !!chromecastConfig, chromecastConfig);
1964
1715
  const uiConfig = {
1965
1716
  seekBarColors: {
1966
1717
  base: seekbarColors?.base || "rgba(255, 255, 255, 0.3)",
@@ -1973,7 +1724,8 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
1973
1724
  controlPanelElements,
1974
1725
  addBigPlayButton: isMobile,
1975
1726
  // Always configure chromecast with defaults or provided config
1976
- castReceiverAppId,
1727
+ castReceiverAppId: chromecastConfig?.receiverApplicationId || "CC1AD845",
1728
+ // Default Media Receiver
1977
1729
  castAndroidReceiverCompatible: true,
1978
1730
  // Enable Android TV compatibility
1979
1731
  overflowMenuButtons: [
@@ -1982,66 +1734,11 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
1982
1734
  "playback_rate"
1983
1735
  ]
1984
1736
  };
1985
- console.log("\u{1F3AE} UI-INIT: Final UI config:", uiConfig);
1986
- console.log("\u{1F3AE} UI-INIT: Applying UI configuration...");
1987
- console.log("\u{1F3AE} UI-INIT: RACE CHECK - Pre-configure state:");
1988
- console.log("\u{1F3AE} UI-INIT: - UI exists:", !!ui);
1989
- console.log("\u{1F3AE} UI-INIT: - Cast receiver ID:", uiConfig.castReceiverAppId);
1990
- console.log("\u{1F3AE} UI-INIT: - Cast compatibility:", uiConfig.castAndroidReceiverCompatible);
1991
- const configureStartTime = performance.now();
1992
- try {
1993
- ui.configure(uiConfig);
1994
- const configureEndTime = performance.now();
1995
- console.log(`\u{1F3AE} UI-INIT: UI configuration applied successfully in ${(configureEndTime - configureStartTime).toFixed(2)}ms`);
1996
- setTimeout(() => {
1997
- const castButton = containerRef.current?.querySelector(".shaka-cast-button");
1998
- const castAvailable = !!window.chrome?.cast?.isAvailable;
1999
- console.log("\u{1F3AE} UI-INIT: POST-CONFIGURE CAST CHECK:");
2000
- console.log("\u{1F3AE} UI-INIT: - Cast button found:", !!castButton);
2001
- console.log("\u{1F3AE} UI-INIT: - Chrome cast API available:", castAvailable);
2002
- console.log("\u{1F3AE} UI-INIT: - Cast button visible:", castButton ? !castButton.hasAttribute("hidden") : false);
2003
- if (castButton) {
2004
- castButton.addEventListener("click", async () => {
2005
- console.log("\u{1F3AE} CAST-CLICK: Cast button clicked!");
2006
- console.log("\u{1F3AE} CAST-CLICK: Player state:", {
2007
- exists: !!playerRef.current,
2008
- isDestroyed: playerRef.current?.isDestroyed?.(),
2009
- videoLoaded: !!videoRef.current?.src,
2010
- videoCurrentTime: videoRef.current?.currentTime,
2011
- videoDuration: videoRef.current?.duration
2012
- });
2013
- const cast = window.chrome?.cast;
2014
- const framework = cast?.framework;
2015
- if (framework?.CastContext) {
2016
- const castContext = framework.CastContext.getInstance();
2017
- try {
2018
- castContext.setOptions?.({
2019
- receiverApplicationId: chromecastConfig?.receiverApplicationId || "CC1AD845",
2020
- autoJoinPolicy: cast?.AutoJoinPolicy?.TAB_AND_ORIGIN_SCOPED || "origin_scoped"
2021
- });
2022
- console.log("\u{1F3AE} CAST-CLICK: CastContext options set");
2023
- } catch (e) {
2024
- console.warn("\u{1F3AE} CAST-CLICK: Failed to set CastContext options", e);
2025
- }
2026
- console.log("\u{1F3AE} CAST-CLICK: Cast state:", castContext.getCastState?.());
2027
- } else {
2028
- console.warn("\u{1F3AE} CAST-CLICK: Cast framework not available on click");
2029
- }
2030
- });
2031
- }
2032
- }, 50);
2033
- } catch (error) {
2034
- const configureEndTime = performance.now();
2035
- console.error(`\u{1F3AE} UI-INIT: ERROR during UI configuration after ${(configureEndTime - configureStartTime).toFixed(2)}ms:`, error);
2036
- throw error;
2037
- }
2038
- console.log("\u{1F3AE} UI-INIT: Setting up mobile-specific customizations...");
1737
+ ui.configure(uiConfig);
2039
1738
  if (isMobile) {
2040
- console.log("\u{1F3AE} UI-INIT: Setting up big play button customization for mobile");
2041
1739
  const customizeBigPlayButton = () => {
2042
1740
  const bigPlayButton = containerRef.current?.querySelector(".shaka-big-play-button");
2043
1741
  if (bigPlayButton && !bigPlayButton.hasAttribute("data-customized")) {
2044
- console.log("\u{1F3AE} UI-INIT: Customizing big play button");
2045
1742
  const buttonSize = iconSizes?.bigPlayButton || 40;
2046
1743
  bigPlayButton.innerHTML = renderIcon(BigPlayIcon, { size: buttonSize });
2047
1744
  bigPlayButton.setAttribute("data-customized", "true");
@@ -2049,10 +1746,8 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
2049
1746
  buttonElement.style.display = "flex";
2050
1747
  buttonElement.style.alignItems = "center";
2051
1748
  buttonElement.style.justifyContent = "center";
2052
- console.log("\u{1F3AE} UI-INIT: Big play button customized successfully");
2053
1749
  }
2054
1750
  };
2055
- console.log("\u{1F3AE} UI-INIT: Scheduling big play button customization");
2056
1751
  setTimeout(customizeBigPlayButton, 100);
2057
1752
  const observer = new MutationObserver(() => {
2058
1753
  customizeBigPlayButton();
@@ -2063,29 +1758,18 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
2063
1758
  subtree: true,
2064
1759
  attributes: false
2065
1760
  });
2066
- console.log("\u{1F3AE} UI-INIT: Mutation observer set up for big play button");
2067
1761
  }
2068
- } else {
2069
- console.log("\u{1F3AE} UI-INIT: Desktop mode - skipping big play button customization");
2070
1762
  }
2071
- console.log("\u{1F3AE} UI-INIT: Seekbar styling handled by CSS");
2072
- const endTime = performance.now();
2073
- console.log(`\u{1F3AE} UI-INIT: UI initialization completed successfully in ${(endTime - startTime).toFixed(2)}ms`);
2074
1763
  return ui;
2075
1764
  }, [controls, containerRef, playerRef, videoRef, chromecastConfig, seekbarColors, onSkipBack, onSkipForward, iconSizes]);
2076
1765
  const destroyUI = useCallback5(() => {
2077
1766
  if (uiRef.current) {
2078
1767
  try {
2079
- console.log("\u{1F3AE} UI-DESTROY: Destroying Shaka UI...");
2080
1768
  uiRef.current.destroy();
2081
- console.log("\u{1F3AE} UI-DESTROY: Shaka UI destroyed successfully");
2082
1769
  } catch (error) {
2083
- console.error("\u{1F3AE} UI-DESTROY: Error destroying UI:", error);
1770
+ console.error("Error destroying UI:", error);
2084
1771
  }
2085
1772
  uiRef.current = null;
2086
- console.log("\u{1F3AE} UI-DESTROY: UI reference cleared");
2087
- } else {
2088
- console.log("\u{1F3AE} UI-DESTROY: No UI instance to destroy");
2089
1773
  }
2090
1774
  }, []);
2091
1775
  return {
@@ -2852,9 +2536,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
2852
2536
  .grid {
2853
2537
  display: grid;
2854
2538
  }
2855
- .hidden {
2856
- display: none;
2857
- }
2858
2539
  .aspect-video {
2859
2540
  aspect-ratio: var(--aspect-video);
2860
2541
  }
@@ -3612,18 +3293,14 @@ var Player = forwardRef(
3612
3293
  const videoRef = useRef8(null);
3613
3294
  const containerRef = useRef8(null);
3614
3295
  const adContainerRef = useRef8(null);
3615
- const isInitializingRef = useRef8(false);
3616
- const stableShakaConfig = useMemo(() => shakaConfig, [shakaConfig]);
3617
- const stableDrmConfig = useMemo(() => drmConfig, [drmConfig]);
3618
- const stableMuxConfig = useMemo(() => muxConfig, [muxConfig]);
3619
3296
  useImperativeHandle(ref, () => videoRef.current, []);
3620
3297
  const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
3621
3298
  src,
3622
- shakaConfig: stableShakaConfig,
3623
- drmConfig: stableDrmConfig,
3299
+ shakaConfig,
3300
+ drmConfig,
3624
3301
  onError: events?.onError,
3625
3302
  onPlayerReady: events?.onPlayerReady,
3626
- muxConfig: stableMuxConfig,
3303
+ muxConfig,
3627
3304
  onMuxReady: events?.onMuxReady,
3628
3305
  onMuxDataUpdate: events?.onMuxDataUpdate
3629
3306
  });
@@ -3657,7 +3334,7 @@ var Player = forwardRef(
3657
3334
  onLoadStart: events?.onLoadStart,
3658
3335
  onCanPlay: events?.onCanPlay
3659
3336
  });
3660
- const { uiRef, initializeUI } = useShakaUI(
3337
+ const { uiRef, initializeUI, destroyUI } = useShakaUI(
3661
3338
  playerRef,
3662
3339
  containerRef,
3663
3340
  videoRef,
@@ -3710,105 +3387,57 @@ var Player = forwardRef(
3710
3387
  }
3711
3388
  }
3712
3389
  };
3390
+ const initializeChromecast = () => {
3391
+ try {
3392
+ if (typeof window !== "undefined" && window.chrome?.cast) {
3393
+ const castContext = window.chrome.cast.CastContext.getInstance();
3394
+ if (castContext) {
3395
+ castContext.setOptions({
3396
+ receiverApplicationId: chromecastConfig?.receiverApplicationId || "CC1AD845"
3397
+ // Default Media Receiver
3398
+ });
3399
+ castContext.addEventListener("caststatechanged", (event) => {
3400
+ const isCasting = event.castState === "CONNECTED";
3401
+ events?.onCastStateChange?.(isCasting);
3402
+ });
3403
+ }
3404
+ } else {
3405
+ if (events?.onCastStateChange) {
3406
+ setTimeout(() => events.onCastStateChange(false), 100);
3407
+ }
3408
+ }
3409
+ } catch (error) {
3410
+ console.warn("Chromecast initialization failed:", error);
3411
+ if (events?.onCastStateChange) {
3412
+ setTimeout(() => events.onCastStateChange(false), 100);
3413
+ }
3414
+ }
3415
+ };
3713
3416
  useEffect5(() => {
3714
- console.log("SOURCE IS", src);
3715
- console.log("\u{1F680} MAIN-INIT: Starting main player initialization sequence...");
3716
- const initStartTime = performance.now();
3717
3417
  const video = videoRef.current;
3718
- if (!video) {
3719
- console.warn("\u{1F680} MAIN-INIT: Video element not available, skipping initialization");
3720
- return;
3721
- }
3722
- console.log("\u{1F680} MAIN-INIT: Video element available, proceeding with initialization");
3418
+ if (!video) return;
3723
3419
  const initialize = async () => {
3724
- if (isInitializingRef.current) {
3725
- console.log("\u{1F680} MAIN-INIT: Initialization already in progress, skipping...");
3726
- return;
3727
- }
3728
- if (playerRef.current && !playerRef.current.isDestroyed?.()) {
3729
- console.log("\u{1F680} MAIN-INIT: Player already exists and is not destroyed, loading new source instead of re-initialization");
3730
- try {
3731
- const manifestUrl = src.url;
3732
- console.log("\u{1F680} MAIN-INIT: Loading new manifest:", manifestUrl);
3733
- await playerRef.current.load(manifestUrl);
3734
- console.log("\u{1F680} MAIN-INIT: New manifest loaded successfully without re-initialization");
3735
- isInitializingRef.current = false;
3736
- return;
3737
- } catch (error) {
3738
- if (error && typeof error === "object" && "code" in error && error.code === 7e3) {
3739
- console.log("\u{1F680} MAIN-INIT: Benign LOAD_INTERRUPTED (7000) while loading new source. Skipping re-init.");
3740
- isInitializingRef.current = false;
3741
- return;
3742
- }
3743
- console.error("\u{1F680} MAIN-INIT: Failed to load new source, proceeding with full re-initialization:", error);
3744
- }
3745
- }
3746
- isInitializingRef.current = true;
3747
- console.log("\u{1F680} MAIN-INIT: Setting initialization flag to prevent race conditions");
3748
3420
  try {
3749
- console.log("\u{1F680} MAIN-INIT: === STEP 1: Initialize Player ===");
3750
- const playerInitStart = performance.now();
3751
3421
  await initializePlayer(video);
3752
- const playerInitEnd = performance.now();
3753
- console.log(`\u{1F680} MAIN-INIT: Player initialization completed in ${(playerInitEnd - playerInitStart).toFixed(2)}ms`);
3754
- console.log("\u{1F680} MAIN-INIT: === STEP 2: Setup Event Listeners ===");
3755
- const eventListenersStart = performance.now();
3756
3422
  setupEventListeners();
3757
- const eventListenersEnd = performance.now();
3758
- console.log(`\u{1F680} MAIN-INIT: Event listeners setup completed in ${(eventListenersEnd - eventListenersStart).toFixed(2)}ms`);
3759
- console.log("\u{1F680} MAIN-INIT: === STEP 3: Setup Quality Tracking ===");
3760
- const qualityStart = performance.now();
3761
3423
  const cleanupQuality = setupQualityTracking();
3762
3424
  configureQuality();
3763
- const qualityEnd = performance.now();
3764
- console.log(`\u{1F680} MAIN-INIT: Quality setup completed in ${(qualityEnd - qualityStart).toFixed(2)}ms`);
3765
- console.log("\u{1F680} MAIN-INIT: === STEP 4: Initialize UI (Including Chromecast) ===");
3766
- const timeSincePlayerInit = performance.now() - playerInitEnd;
3767
- console.log(`\u{1F680} MAIN-INIT: RACE CHECK - Time gap between player and UI init: ${timeSincePlayerInit.toFixed(2)}ms`);
3768
- const uiInitStart = performance.now();
3769
3425
  await initializeUI();
3770
- const uiInitEnd = performance.now();
3771
- console.log(`\u{1F680} MAIN-INIT: UI initialization completed in ${(uiInitEnd - uiInitStart).toFixed(2)}ms`);
3772
- console.log("\u{1F680} MAIN-INIT: === STEP 5: Initialize Ads ===");
3773
- const adsInitStart = performance.now();
3774
3426
  initializeAds();
3775
- const adsInitEnd = performance.now();
3776
- console.log(`\u{1F680} MAIN-INIT: Ads initialization completed in ${(adsInitEnd - adsInitStart).toFixed(2)}ms`);
3777
- const totalInitTime = performance.now() - initStartTime;
3778
- console.log(`\u{1F680} MAIN-INIT: === INITIALIZATION COMPLETE ===`);
3779
- console.log(`\u{1F680} MAIN-INIT: Total initialization time: ${totalInitTime.toFixed(2)}ms`);
3427
+ initializeChromecast();
3780
3428
  } catch (error) {
3781
- const errorTime = performance.now() - initStartTime;
3782
- console.error(`\u{1F680} MAIN-INIT: Error during player initialization after ${errorTime.toFixed(2)}ms:`, error);
3429
+ console.error("Error during player initialization:", error);
3783
3430
  handleMuxError(error);
3784
- } finally {
3785
- isInitializingRef.current = false;
3786
- console.log("\u{1F680} MAIN-INIT: Clearing initialization flag");
3787
3431
  }
3788
3432
  };
3789
3433
  initialize();
3790
3434
  return () => {
3791
- console.log("\u{1F680} MAIN-CLEANUP: Starting cleanup sequence...");
3792
- const cleanupStart = performance.now();
3793
- if (!playerRef.current && !isInitializingRef.current) {
3794
- console.log("\u{1F680} MAIN-CLEANUP: No player to cleanup and no initialization in progress, skipping cleanup");
3795
- return;
3796
- }
3797
- if (playerRef.current && !playerRef.current.isDestroyed?.()) {
3798
- console.log("\u{1F680} MAIN-CLEANUP: Player exists and is not destroyed - this might be a source change");
3799
- console.log("\u{1F680} MAIN-CLEANUP: Checking if this is a real unmount or just a re-render...");
3800
- }
3801
- isInitializingRef.current = false;
3802
- console.log("\u{1F680} MAIN-CLEANUP: Reset initialization flag");
3803
- console.log("\u{1F680} MAIN-CLEANUP: Cleaning up event listeners...");
3804
3435
  cleanupEventListeners();
3805
- console.log("\u{1F680} MAIN-CLEANUP: Destroying UI...");
3806
- console.log("\u{1F680} MAIN-CLEANUP: Destroying Mux...");
3436
+ destroyUI();
3807
3437
  destroyMux();
3808
- const cleanupEnd = performance.now();
3809
- console.log(`\u{1F680} MAIN-CLEANUP: Cleanup completed in ${(cleanupEnd - cleanupStart).toFixed(2)}ms`);
3438
+ destroyPlayer();
3810
3439
  };
3811
- }, [src?.url]);
3440
+ }, [src]);
3812
3441
  useEffect5(() => {
3813
3442
  const video = videoRef.current;
3814
3443
  if (!video) return;
@@ -4408,7 +4037,8 @@ var Video = ({
4408
4037
  const video = providedVideoData || data;
4409
4038
  const { t } = useMessages_default(locale);
4410
4039
  const activePlaylist = findHLSPlaylist(video);
4411
- const hlsUrl = activePlaylist?.url;
4040
+ const activePlaylistUrl = activePlaylist?.url ?? activePlaylist?.drm?.widevine?.playlistUrl ?? activePlaylist?.drm?.playready?.playlistUrl ?? activePlaylist?.drm?.fairplay?.playlistUrl;
4041
+ const activePlaylistHasUrl = !!activePlaylistUrl;
4412
4042
  useEffect7(() => {
4413
4043
  if (events?.onVideoData && video) {
4414
4044
  events.onVideoData(video);
@@ -4417,7 +4047,7 @@ var Video = ({
4417
4047
  if (isLoading || !providedVideoData && !video) {
4418
4048
  return /* @__PURE__ */ jsx9("div", { className: twMerge3("md:rounded-2xl overflow-hidden aspect-video", className), children: /* @__PURE__ */ jsx9("div", { className: "relative w-full h-full bg-[#151515]", children: /* @__PURE__ */ jsx9(Loading, {}) }) });
4419
4049
  }
4420
- if (!isLoading && video && !hlsUrl && events?.onEmptyPlaylists) {
4050
+ if (!isLoading && video && !activePlaylistHasUrl && events?.onEmptyPlaylists) {
4421
4051
  events.onEmptyPlaylists();
4422
4052
  }
4423
4053
  if (error || video?.error) {
@@ -4439,7 +4069,7 @@ var Video = ({
4439
4069
  children
4440
4070
  ] }) });
4441
4071
  }
4442
- if (!hlsUrl) {
4072
+ if (!activePlaylist || !activePlaylistHasUrl) {
4443
4073
  return /* @__PURE__ */ jsx9("div", { className: twMerge3("md:rounded-2xl overflow-hidden aspect-video", className), children: /* @__PURE__ */ jsxs7("div", { className: "relative w-full h-full bg-[#151515]", children: [
4444
4074
  /* @__PURE__ */ jsx9(Title, { title: video?.name || "" }),
4445
4075
  children
@@ -4519,9 +4149,11 @@ var Event = ({
4519
4149
  if (videosWithPlaylists.length > 0) {
4520
4150
  let hlsPlaylistFound = false;
4521
4151
  for (const video of videosWithPlaylists) {
4522
- const hlsPlaylist = findHLSPlaylist(video);
4523
- if (hlsPlaylist?.url) {
4524
- setActivePlaylist(hlsPlaylist);
4152
+ const activePlaylist2 = findHLSPlaylist(video);
4153
+ const activePlaylistUrl = activePlaylist2?.url ?? activePlaylist2?.drm?.widevine?.playlistUrl ?? activePlaylist2?.drm?.playready?.playlistUrl ?? activePlaylist2?.drm?.fairplay?.playlistUrl;
4154
+ const activePlaylistHasUrl = !!activePlaylistUrl;
4155
+ if (activePlaylist2 && activePlaylistHasUrl) {
4156
+ setActivePlaylist(activePlaylist2);
4525
4157
  setActiveVideoId(video.id);
4526
4158
  hlsPlaylistFound = true;
4527
4159
  break;
@@ -4861,9 +4493,11 @@ var CreativeWork = ({
4861
4493
  if (videosWithPlaylists.length > 0) {
4862
4494
  let hlsPlaylistFound = false;
4863
4495
  for (const video of videosWithPlaylists) {
4864
- const hlsPlaylist = findHLSPlaylist(video);
4865
- if (hlsPlaylist?.url) {
4866
- setActivePlaylist(hlsPlaylist);
4496
+ const activePlaylist2 = findHLSPlaylist(video);
4497
+ const activePlaylistUrl = activePlaylist2?.url ?? activePlaylist2?.drm?.widevine?.playlistUrl ?? activePlaylist2?.drm?.playready?.playlistUrl ?? activePlaylist2?.drm?.fairplay?.playlistUrl;
4498
+ const activePlaylistHasUrl = !!activePlaylistUrl;
4499
+ if (activePlaylist2 && activePlaylistHasUrl) {
4500
+ setActivePlaylist(activePlaylist2);
4867
4501
  setActiveVideoId(video.id);
4868
4502
  hlsPlaylistFound = true;
4869
4503
  break;