@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.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +73 -439
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -440
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -415,9 +415,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
|
|
|
415
415
|
.grid {
|
|
416
416
|
display: grid;
|
|
417
417
|
}
|
|
418
|
-
.hidden {
|
|
419
|
-
display: none;
|
|
420
|
-
}
|
|
421
418
|
.aspect-video {
|
|
422
419
|
aspect-ratio: var(--aspect-video);
|
|
423
420
|
}
|
|
@@ -1181,7 +1178,7 @@ var isPlayReadySupported = () => {
|
|
|
1181
1178
|
var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
1182
1179
|
|
|
1183
1180
|
// package.json
|
|
1184
|
-
var version = "1.0.1-rc.
|
|
1181
|
+
var version = "1.0.1-rc.36";
|
|
1185
1182
|
|
|
1186
1183
|
// src/hooks/useShakePlayer.ts
|
|
1187
1184
|
var useShakePlayer = ({
|
|
@@ -1195,62 +1192,38 @@ var useShakePlayer = ({
|
|
|
1195
1192
|
onMuxDataUpdate
|
|
1196
1193
|
}) => {
|
|
1197
1194
|
const playerRef = (0, import_react.useRef)(null);
|
|
1198
|
-
const isDestroyingRef = (0, import_react.useRef)(false);
|
|
1199
1195
|
const initializePlayer = (0, import_react.useCallback)(async (video) => {
|
|
1200
|
-
console.log("\u{1F3AC} PLAYER-INIT: Starting player initialization...");
|
|
1201
|
-
const startTime = performance.now();
|
|
1202
1196
|
try {
|
|
1203
|
-
console.log("\u{1F3AC} PLAYER-INIT: Installing polyfills...");
|
|
1204
1197
|
import_shaka_player.default.polyfill.installAll();
|
|
1205
|
-
console.log("\u{1F3AC} PLAYER-INIT: Polyfills installed successfully");
|
|
1206
|
-
console.log("\u{1F3AC} PLAYER-INIT: Checking browser support...");
|
|
1207
1198
|
if (!import_shaka_player.default.Player.isBrowserSupported()) {
|
|
1208
|
-
console.error("\u{1F3AC} PLAYER-INIT: Browser not supported by Shaka Player");
|
|
1209
1199
|
throw new Error("Browser not supported by Shaka Player");
|
|
1210
1200
|
}
|
|
1211
|
-
console.log("\u{1F3AC} PLAYER-INIT: Browser support confirmed");
|
|
1212
|
-
console.log("\u{1F3AC} PLAYER-INIT: Creating player instance...");
|
|
1213
1201
|
const player = new import_shaka_player.default.Player();
|
|
1214
1202
|
playerRef.current = player;
|
|
1215
|
-
console.log("\u{1F3AC} PLAYER-INIT: Player instance created successfully");
|
|
1216
|
-
console.log("\u{1F3AC} PLAYER-INIT: Attaching player to video element...");
|
|
1217
1203
|
await player.attach(video);
|
|
1218
|
-
console.log("\u{1F3AC} PLAYER-INIT: Player attached to video element successfully");
|
|
1219
|
-
console.log("\u{1F3AC} PLAYER-INIT: Configuring player...");
|
|
1220
1204
|
if (shakaConfig) {
|
|
1221
|
-
console.log("\u{1F3AC} PLAYER-INIT: Applying custom shaka config:", shakaConfig);
|
|
1222
1205
|
player.configure(shakaConfig);
|
|
1223
|
-
console.log("\u{1F3AC} PLAYER-INIT: Custom shaka config applied");
|
|
1224
|
-
} else {
|
|
1225
|
-
console.log("\u{1F3AC} PLAYER-INIT: No custom shaka config provided");
|
|
1226
1206
|
}
|
|
1227
1207
|
let manifestUrl = src.url;
|
|
1228
1208
|
const isDRM = Boolean(src.drm);
|
|
1229
1209
|
let cert = null;
|
|
1230
1210
|
if (isDRM) {
|
|
1231
|
-
console.log("\u{1F3AC} PLAYER-INIT: DRM detected, setting up DRM configuration...");
|
|
1232
1211
|
const isPlayReady = isPlayReadySupported();
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
console.log("\u{1F3AC} PLAYER-INIT: Setting up FairPlay DRM...");
|
|
1236
|
-
const req = await fetch(src.drm.fairplay.certificate_url);
|
|
1212
|
+
if (isAppleDevice() && src.drm.fairplay?.certificateUrl) {
|
|
1213
|
+
const req = await fetch(src.drm.fairplay.certificateUrl);
|
|
1237
1214
|
cert = await req.arrayBuffer();
|
|
1238
|
-
manifestUrl = src.drm.fairplay.
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
console.log("\u{1F3AC} PLAYER-INIT: Setting up PlayReady DRM...");
|
|
1242
|
-
manifestUrl = src.drm.playready.playlist_url;
|
|
1215
|
+
manifestUrl = src.drm.fairplay.playlistUrl;
|
|
1216
|
+
} else if (isPlayReady && src.drm.playready?.licenseUrl) {
|
|
1217
|
+
manifestUrl = src.drm.playready.playlistUrl;
|
|
1243
1218
|
} else {
|
|
1244
|
-
|
|
1245
|
-
manifestUrl = src.drm?.widevine?.playlist_url || "";
|
|
1219
|
+
manifestUrl = src.drm?.widevine?.playlistUrl || "";
|
|
1246
1220
|
}
|
|
1247
|
-
|
|
1248
|
-
const drmConfig2 = {
|
|
1221
|
+
player.configure({
|
|
1249
1222
|
drm: {
|
|
1250
1223
|
servers: {
|
|
1251
|
-
"com.widevine.alpha": src.drm.widevine?.
|
|
1252
|
-
"com.microsoft.playready": src.drm.playready?.
|
|
1253
|
-
"com.apple.fps": src.drm.fairplay?.
|
|
1224
|
+
"com.widevine.alpha": src.drm.widevine?.licenseUrl,
|
|
1225
|
+
"com.microsoft.playready": src.drm.playready?.licenseUrl,
|
|
1226
|
+
"com.apple.fps": src.drm.fairplay?.licenseUrl
|
|
1254
1227
|
},
|
|
1255
1228
|
...cert && {
|
|
1256
1229
|
advanced: {
|
|
@@ -1260,52 +1233,34 @@ var useShakePlayer = ({
|
|
|
1260
1233
|
}
|
|
1261
1234
|
}
|
|
1262
1235
|
}
|
|
1263
|
-
};
|
|
1264
|
-
console.log("\u{1F3AC} PLAYER-INIT: DRM config:", drmConfig2);
|
|
1265
|
-
player.configure(drmConfig2);
|
|
1266
|
-
console.log("\u{1F3AC} PLAYER-INIT: DRM configuration applied");
|
|
1267
|
-
console.log("\u{1F3AC} PLAYER-INIT: Setting up DRM network filters...");
|
|
1236
|
+
});
|
|
1268
1237
|
const netEngine = player.getNetworkingEngine();
|
|
1269
1238
|
if (netEngine) {
|
|
1270
|
-
console.log("\u{1F3AC} PLAYER-INIT: Registering DRM request filter...");
|
|
1271
1239
|
netEngine.registerRequestFilter((type, request) => {
|
|
1272
1240
|
if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
|
|
1273
|
-
|
|
1274
|
-
request.headers["x-dt-custom-data"] = src.drm.token;
|
|
1241
|
+
request.headers["x-dt-auth-token"] = src.drm.token;
|
|
1275
1242
|
}
|
|
1276
1243
|
});
|
|
1277
|
-
console.log("\u{1F3AC} PLAYER-INIT: Registering DRM response filter...");
|
|
1278
1244
|
netEngine.registerResponseFilter((type, response) => {
|
|
1279
1245
|
if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
|
|
1280
1246
|
const ks = player.keySystem && player.keySystem();
|
|
1281
1247
|
if (ks === "com.apple.fps") {
|
|
1282
|
-
console.log("\u{1F3AC} PLAYER-INIT: Processing FairPlay license response");
|
|
1283
1248
|
const responseText = import_shaka_player.default.util.StringUtils.fromUTF8(response.data);
|
|
1284
1249
|
response.data = import_shaka_player.default.util.Uint8ArrayUtils.fromBase64(responseText).buffer;
|
|
1285
1250
|
}
|
|
1286
1251
|
}
|
|
1287
1252
|
});
|
|
1288
|
-
console.log("\u{1F3AC} PLAYER-INIT: DRM network filters registered");
|
|
1289
|
-
} else {
|
|
1290
|
-
console.warn("\u{1F3AC} PLAYER-INIT: No networking engine available for DRM filters");
|
|
1291
1253
|
}
|
|
1292
|
-
} else {
|
|
1293
|
-
console.log("\u{1F3AC} PLAYER-INIT: No DRM configuration needed");
|
|
1294
1254
|
}
|
|
1295
|
-
console.log("\u{1F3AC} PLAYER-INIT: Setting up error handling...");
|
|
1296
1255
|
player?.addEventListener("error", (event) => {
|
|
1297
1256
|
const error = event.detail;
|
|
1298
1257
|
if (error?.code === 7e3) {
|
|
1299
|
-
console.log("\u{1F3AC} PLAYER-INIT: Ignoring benign LOAD_INTERRUPTED error (7000)");
|
|
1300
1258
|
return;
|
|
1301
1259
|
}
|
|
1302
|
-
console.error("
|
|
1260
|
+
console.error("Shaka Player Error:", error);
|
|
1303
1261
|
onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
|
|
1304
1262
|
});
|
|
1305
|
-
console.log("\u{1F3AC} PLAYER-INIT: Error handling configured");
|
|
1306
|
-
console.log("\u{1F3AC} PLAYER-INIT: Checking Mux configuration...");
|
|
1307
1263
|
if (muxConfig) {
|
|
1308
|
-
console.log("\u{1F3AC} PLAYER-INIT: Initializing Mux Analytics...");
|
|
1309
1264
|
try {
|
|
1310
1265
|
const playerInitTime = import_mux_data_shakaplayer.default.utils.now();
|
|
1311
1266
|
const muxOptions = {
|
|
@@ -1326,54 +1281,33 @@ var useShakePlayer = ({
|
|
|
1326
1281
|
...muxConfig.metadata
|
|
1327
1282
|
}
|
|
1328
1283
|
};
|
|
1329
|
-
console.log("\u{1F3AC} PLAYER-INIT: Mux options:", muxOptions);
|
|
1330
1284
|
(0, import_mux_data_shakaplayer.default)(player, muxOptions, import_shaka_player.default);
|
|
1331
|
-
console.log("\u{1F3AC} PLAYER-INIT: Mux Analytics initialized successfully");
|
|
1332
1285
|
onMuxReady?.();
|
|
1333
1286
|
} catch (error) {
|
|
1334
|
-
console.error("
|
|
1287
|
+
console.error("Failed to initialize Mux Analytics:", error);
|
|
1335
1288
|
}
|
|
1336
|
-
} else {
|
|
1337
|
-
console.log("\u{1F3AC} PLAYER-INIT: No Mux configuration provided");
|
|
1338
1289
|
}
|
|
1339
|
-
console.log("\u{1F3AC} PLAYER-INIT: Loading manifest:", manifestUrl);
|
|
1340
|
-
console.log("\u{1F3AC} PLAYER-INIT: CRITICAL - Using manifestUrl instead of hardcoded URL");
|
|
1341
1290
|
await player.load(manifestUrl);
|
|
1342
|
-
console.log("\u{1F3AC} PLAYER-INIT: Manifest loaded successfully");
|
|
1343
|
-
const endTime = performance.now();
|
|
1344
|
-
console.log(`\u{1F3AC} PLAYER-INIT: Player initialization completed in ${(endTime - startTime).toFixed(2)}ms`);
|
|
1345
1291
|
onPlayerReady?.(player);
|
|
1346
1292
|
return player;
|
|
1347
1293
|
} catch (error) {
|
|
1348
1294
|
if (error?.code === 7e3) {
|
|
1349
|
-
console.log("\u{1F3AC} PLAYER-INIT: Caught benign LOAD_INTERRUPTED error during initialization");
|
|
1350
1295
|
return;
|
|
1351
1296
|
}
|
|
1352
|
-
|
|
1353
|
-
console.error(`\u{1F3AC} PLAYER-INIT: Error during initialization after ${(endTime - startTime).toFixed(2)}ms:`, error);
|
|
1297
|
+
console.error("Error initializing Shaka Player:", error);
|
|
1354
1298
|
onError?.(error);
|
|
1355
1299
|
throw error;
|
|
1356
1300
|
}
|
|
1357
1301
|
}, [shakaConfig, drmConfig, src, onError, onPlayerReady, muxConfig, onMuxReady]);
|
|
1358
1302
|
const destroyPlayer = (0, import_react.useCallback)(async () => {
|
|
1359
|
-
if (playerRef.current
|
|
1360
|
-
isDestroyingRef.current = true;
|
|
1361
|
-
console.log("\u{1F3AC} PLAYER-DESTROY: Setting destroy flag to prevent race conditions");
|
|
1303
|
+
if (playerRef.current) {
|
|
1362
1304
|
try {
|
|
1363
|
-
console.log("\u{1F3AC} PLAYER-DESTROY: Destroying player instance...");
|
|
1364
1305
|
await playerRef.current.destroy();
|
|
1365
|
-
console.log("\u{1F3AC} PLAYER-DESTROY: Player instance destroyed successfully");
|
|
1366
1306
|
} catch (error) {
|
|
1367
|
-
console.warn("
|
|
1307
|
+
console.warn("Error destroying Shaka Player:", error);
|
|
1368
1308
|
} finally {
|
|
1369
1309
|
playerRef.current = null;
|
|
1370
|
-
isDestroyingRef.current = false;
|
|
1371
|
-
console.log("\u{1F3AC} PLAYER-DESTROY: Player reference cleared and destroy flag reset");
|
|
1372
1310
|
}
|
|
1373
|
-
} else if (isDestroyingRef.current) {
|
|
1374
|
-
console.log("\u{1F3AC} PLAYER-DESTROY: Destroy already in progress, skipping...");
|
|
1375
|
-
} else {
|
|
1376
|
-
console.log("\u{1F3AC} PLAYER-DESTROY: No player instance to destroy");
|
|
1377
1311
|
}
|
|
1378
1312
|
}, [playerRef]);
|
|
1379
1313
|
return {
|
|
@@ -1791,198 +1725,20 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
|
|
|
1791
1725
|
const uiRef = (0, import_react6.useRef)(null);
|
|
1792
1726
|
const registeredElements = (0, import_react6.useRef)(/* @__PURE__ */ new Set());
|
|
1793
1727
|
const initializeUI = (0, import_react6.useCallback)(async () => {
|
|
1794
|
-
|
|
1795
|
-
const startTime = performance.now();
|
|
1796
|
-
if (!controls) {
|
|
1797
|
-
console.log("\u{1F3AE} UI-INIT: Controls disabled, skipping UI initialization");
|
|
1798
|
-
return null;
|
|
1799
|
-
}
|
|
1800
|
-
if (!containerRef.current) {
|
|
1801
|
-
console.warn("\u{1F3AE} UI-INIT: Container ref not available, skipping UI initialization");
|
|
1802
|
-
return null;
|
|
1803
|
-
}
|
|
1804
|
-
if (!playerRef.current) {
|
|
1805
|
-
console.warn("\u{1F3AE} UI-INIT: Player ref not available, skipping UI initialization");
|
|
1806
|
-
console.warn("\u{1F3AE} UI-INIT: This might be due to a race condition - player destroyed before UI init");
|
|
1807
|
-
console.log("\u{1F3AE} UI-INIT: Attempting to wait for player reference...");
|
|
1808
|
-
let waitAttempts = 0;
|
|
1809
|
-
const maxWaitAttempts = 10;
|
|
1810
|
-
while (!playerRef.current && waitAttempts < maxWaitAttempts) {
|
|
1811
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1812
|
-
waitAttempts++;
|
|
1813
|
-
console.log(`\u{1F3AE} UI-INIT: Waiting for player ref... attempt ${waitAttempts}`);
|
|
1814
|
-
}
|
|
1815
|
-
if (!playerRef.current) {
|
|
1816
|
-
console.error("\u{1F3AE} UI-INIT: Player ref still not available after waiting, aborting UI initialization");
|
|
1817
|
-
return null;
|
|
1818
|
-
} else {
|
|
1819
|
-
console.log(`\u{1F3AE} UI-INIT: Player ref became available after ${waitAttempts * 100}ms`);
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
const player = playerRef.current;
|
|
1823
|
-
console.log("\u{1F3AE} UI-INIT: RACE CHECK - Player state analysis:");
|
|
1824
|
-
console.log("\u{1F3AE} UI-INIT: - Player exists:", !!player);
|
|
1825
|
-
if (!player) {
|
|
1826
|
-
console.error("\u{1F3AE} UI-INIT: CRITICAL - Player reference is null during UI initialization!");
|
|
1827
|
-
console.error("\u{1F3AE} UI-INIT: This indicates a race condition between player destruction and UI initialization");
|
|
1828
|
-
return null;
|
|
1829
|
-
}
|
|
1830
|
-
console.log("\u{1F3AE} UI-INIT: - Player isDestroyed:", player.isDestroyed && player.isDestroyed());
|
|
1831
|
-
console.log("\u{1F3AE} UI-INIT: - Player getNetworkingEngine:", !!player.getNetworkingEngine());
|
|
1832
|
-
console.log("\u{1F3AE} UI-INIT: - Player getConfiguration:", !!player.getConfiguration);
|
|
1833
|
-
try {
|
|
1834
|
-
const config = player.getConfiguration();
|
|
1835
|
-
console.log("\u{1F3AE} UI-INIT: - Player configuration available:", !!config);
|
|
1836
|
-
if (player.isDestroyed && player.isDestroyed()) {
|
|
1837
|
-
console.error("\u{1F3AE} UI-INIT: CRITICAL - Player is destroyed, aborting UI initialization");
|
|
1838
|
-
return null;
|
|
1839
|
-
}
|
|
1840
|
-
} catch (error) {
|
|
1841
|
-
console.warn("\u{1F3AE} UI-INIT: - WARNING: Could not get player configuration:", error);
|
|
1842
|
-
console.warn("\u{1F3AE} UI-INIT: - This may indicate the player is in an invalid state");
|
|
1843
|
-
return null;
|
|
1844
|
-
}
|
|
1845
|
-
if (!videoRef.current) {
|
|
1846
|
-
console.warn("\u{1F3AE} UI-INIT: Video ref not available, skipping UI initialization");
|
|
1728
|
+
if (!controls || !containerRef.current || !playerRef.current || !videoRef.current) {
|
|
1847
1729
|
return null;
|
|
1848
1730
|
}
|
|
1849
|
-
console.log("\u{1F3AE} UI-INIT: All prerequisites met, proceeding with initialization");
|
|
1850
|
-
const chromecastAPICheck = {
|
|
1851
|
-
chromeExists: !!window.chrome,
|
|
1852
|
-
castExists: !!window.chrome?.cast,
|
|
1853
|
-
isAvailable: !!window.chrome?.cast?.isAvailable,
|
|
1854
|
-
sessionExists: !!window.chrome?.cast?.Session,
|
|
1855
|
-
receiverExists: !!window.chrome?.cast?.ReceiverAvailability
|
|
1856
|
-
};
|
|
1857
|
-
console.log("\u{1F3AE} UI-INIT: CRITICAL - Chromecast API state before UI init:", chromecastAPICheck);
|
|
1858
|
-
if (chromecastConfig) {
|
|
1859
|
-
try {
|
|
1860
|
-
console.log("\u{1F3AE} CAST-DIAG: Secure context:", window.isSecureContext, "Protocol:", window.location.protocol);
|
|
1861
|
-
console.log("\u{1F3AE} CAST-DIAG: UserAgent:", navigator.userAgent);
|
|
1862
|
-
console.log("\u{1F3AE} CAST-DIAG: In iframe:", window.top !== window.self);
|
|
1863
|
-
const existingCastScript = document.querySelector('script#gcast_sender, script[src*="cast_sender.js"]');
|
|
1864
|
-
if (existingCastScript) {
|
|
1865
|
-
console.log("\u{1F3AE} CAST-DIAG: Found existing cast sender script:", {
|
|
1866
|
-
id: existingCastScript.id,
|
|
1867
|
-
src: existingCastScript.src,
|
|
1868
|
-
async: existingCastScript.async,
|
|
1869
|
-
defer: existingCastScript.defer,
|
|
1870
|
-
dataset: existingCastScript.dataset
|
|
1871
|
-
});
|
|
1872
|
-
} else {
|
|
1873
|
-
console.log("\u{1F3AE} CAST-DIAG: No cast sender script present yet");
|
|
1874
|
-
}
|
|
1875
|
-
} catch (e) {
|
|
1876
|
-
console.warn("\u{1F3AE} CAST-DIAG: Environment diagnostics failed", e);
|
|
1877
|
-
}
|
|
1878
|
-
const hasCastFramework = !!window.chrome?.cast?.framework?.CastContext;
|
|
1879
|
-
if (!hasCastFramework) {
|
|
1880
|
-
console.warn("\u{1F3AE} UI-INIT: Cast Framework not loaded. Attempting to load sender library...");
|
|
1881
|
-
const loadCastFramework = () => new Promise((resolve) => {
|
|
1882
|
-
if (window.chrome?.cast?.framework?.CastContext) {
|
|
1883
|
-
return resolve();
|
|
1884
|
-
}
|
|
1885
|
-
if (!document.getElementById("gcast_sender")) {
|
|
1886
|
-
const script = document.createElement("script");
|
|
1887
|
-
script.id = "gcast_sender";
|
|
1888
|
-
script.src = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
|
|
1889
|
-
script.async = true;
|
|
1890
|
-
script.defer = true;
|
|
1891
|
-
script.addEventListener("load", () => {
|
|
1892
|
-
console.log("\u{1F3AE} CAST-LOAD: cast_sender.js loaded");
|
|
1893
|
-
});
|
|
1894
|
-
script.addEventListener("error", (err) => {
|
|
1895
|
-
console.error("\u{1F3AE} CAST-LOAD: cast_sender.js failed to load", err);
|
|
1896
|
-
});
|
|
1897
|
-
document.head.appendChild(script);
|
|
1898
|
-
console.log("\u{1F3AE} CAST-LOAD: Injected cast sender script tag");
|
|
1899
|
-
}
|
|
1900
|
-
const previousCallback = window.__onGCastApiAvailable;
|
|
1901
|
-
window.__onGCastApiAvailable = (isAvailable) => {
|
|
1902
|
-
console.log("\u{1F3AE} UI-INIT: __onGCastApiAvailable called. Available:", isAvailable);
|
|
1903
|
-
try {
|
|
1904
|
-
console.log("\u{1F3AE} CAST-CB: chrome.cast exists:", !!window.chrome?.cast);
|
|
1905
|
-
console.log("\u{1F3AE} CAST-CB: chrome.cast.isAvailable:", !!window.chrome?.cast?.isAvailable);
|
|
1906
|
-
console.log("\u{1F3AE} CAST-CB: chrome.cast.framework exists:", !!window.chrome?.cast?.framework);
|
|
1907
|
-
console.log("\u{1F3AE} CAST-CB: CastContext exists:", !!window.chrome?.cast?.framework?.CastContext);
|
|
1908
|
-
} catch (e) {
|
|
1909
|
-
console.warn("\u{1F3AE} CAST-CB: Diagnostics failed", e);
|
|
1910
|
-
}
|
|
1911
|
-
if (typeof previousCallback === "function") {
|
|
1912
|
-
try {
|
|
1913
|
-
previousCallback(isAvailable);
|
|
1914
|
-
} catch {
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
resolve();
|
|
1918
|
-
};
|
|
1919
|
-
let attempts = 0;
|
|
1920
|
-
const maxAttempts = 50;
|
|
1921
|
-
const poll = setInterval(() => {
|
|
1922
|
-
attempts++;
|
|
1923
|
-
const hasCast = !!window.chrome?.cast;
|
|
1924
|
-
const hasFramework = !!window.chrome?.cast?.framework;
|
|
1925
|
-
const hasContext = !!window.chrome?.cast?.framework?.CastContext;
|
|
1926
|
-
if (attempts % 10 === 0) {
|
|
1927
|
-
console.log(`\u{1F3AE} CAST-POLL: attempt=${attempts} cast=${hasCast} framework=${hasFramework} context=${hasContext}`);
|
|
1928
|
-
}
|
|
1929
|
-
if (hasContext || attempts >= maxAttempts) {
|
|
1930
|
-
clearInterval(poll);
|
|
1931
|
-
resolve();
|
|
1932
|
-
}
|
|
1933
|
-
}, 100);
|
|
1934
|
-
});
|
|
1935
|
-
await loadCastFramework();
|
|
1936
|
-
console.log("\u{1F3AE} UI-INIT: Cast Framework load attempt complete. Framework present:", !!window.chrome?.cast?.framework?.CastContext);
|
|
1937
|
-
if (!window.chrome?.cast?.framework?.CastContext) {
|
|
1938
|
-
console.warn("\u{1F3AE} UI-INIT: CastContext still missing after load. Potential causes:");
|
|
1939
|
-
console.warn("\u{1F3AE} UI-INIT: - Script blocked by CSP/adblock");
|
|
1940
|
-
console.warn("\u{1F3AE} UI-INIT: - Non-secure origin (requires https/localhost)");
|
|
1941
|
-
console.warn("\u{1F3AE} UI-INIT: - Non-Chrome browser or incognito restrictions");
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
if (chromecastConfig && !chromecastAPICheck.castExists) {
|
|
1946
|
-
console.warn("\u{1F3AE} UI-INIT: WARNING - Chromecast config provided but Cast API not available!");
|
|
1947
|
-
console.warn("\u{1F3AE} UI-INIT: This could cause race condition issues");
|
|
1948
|
-
console.log("\u{1F3AE} UI-INIT: Waiting for Cast API to be available...");
|
|
1949
|
-
let waitAttempts = 0;
|
|
1950
|
-
const maxWaitAttempts = 50;
|
|
1951
|
-
while (!window.chrome?.cast?.isAvailable && waitAttempts < maxWaitAttempts) {
|
|
1952
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1953
|
-
waitAttempts++;
|
|
1954
|
-
if (waitAttempts % 10 === 0) {
|
|
1955
|
-
console.log(`\u{1F3AE} UI-INIT: Still waiting for Cast API... (${waitAttempts * 100}ms)`);
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
if (window.chrome?.cast?.isAvailable) {
|
|
1959
|
-
console.log(`\u{1F3AE} UI-INIT: Cast API became available after ${waitAttempts * 100}ms`);
|
|
1960
|
-
} else {
|
|
1961
|
-
console.warn(`\u{1F3AE} UI-INIT: Cast API not available after ${waitAttempts * 100}ms, proceeding anyway`);
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
console.log("\u{1F3AE} UI-INIT: Registering custom UI elements...");
|
|
1965
1731
|
if (!registeredElements.current.has("skip_back_button")) {
|
|
1966
|
-
console.log("\u{1F3AE} UI-INIT: Registering skip_back_button element");
|
|
1967
1732
|
import_shaka_player3.ui.Controls.registerElement("skip_back_button", new SkipBackButtonFactory(onSkipBack, iconSizes?.skipButtons));
|
|
1968
1733
|
registeredElements.current.add("skip_back_button");
|
|
1969
|
-
} else {
|
|
1970
|
-
console.log("\u{1F3AE} UI-INIT: skip_back_button already registered");
|
|
1971
1734
|
}
|
|
1972
1735
|
if (!registeredElements.current.has("skip_forward_button")) {
|
|
1973
|
-
console.log("\u{1F3AE} UI-INIT: Registering skip_forward_button element");
|
|
1974
1736
|
import_shaka_player3.ui.Controls.registerElement("skip_forward_button", new SkipForwardButtonFactory(onSkipForward, iconSizes?.skipButtons));
|
|
1975
1737
|
registeredElements.current.add("skip_forward_button");
|
|
1976
|
-
} else {
|
|
1977
|
-
console.log("\u{1F3AE} UI-INIT: skip_forward_button already registered");
|
|
1978
1738
|
}
|
|
1979
|
-
console.log("\u{1F3AE} UI-INIT: Creating Shaka UI Overlay...");
|
|
1980
1739
|
const ui = new import_shaka_player3.ui.Overlay(playerRef.current, containerRef.current, videoRef.current);
|
|
1981
1740
|
uiRef.current = ui;
|
|
1982
|
-
console.log("\u{1F3AE} UI-INIT: Shaka UI Overlay created successfully");
|
|
1983
1741
|
const isMobile = window.innerWidth <= 767;
|
|
1984
|
-
console.log("\u{1F3AE} UI-INIT: Device detection - Mobile:", isMobile, "Width:", window.innerWidth);
|
|
1985
|
-
console.log("\u{1F3AE} UI-INIT: Building control panel elements...");
|
|
1986
1742
|
const controlPanelElements = [
|
|
1987
1743
|
...isMobile ? [] : ["skip_back_button"],
|
|
1988
1744
|
...isMobile ? [] : ["play_pause"],
|
|
@@ -1997,11 +1753,6 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
|
|
|
1997
1753
|
// Always show cast button
|
|
1998
1754
|
"overflow_menu"
|
|
1999
1755
|
];
|
|
2000
|
-
console.log("\u{1F3AE} UI-INIT: Control panel elements:", controlPanelElements);
|
|
2001
|
-
console.log("\u{1F3AE} UI-INIT: Configuring Chromecast settings...");
|
|
2002
|
-
const castReceiverAppId = chromecastConfig?.receiverApplicationId || "CC1AD845";
|
|
2003
|
-
console.log("\u{1F3AE} UI-INIT: Cast receiver app ID:", castReceiverAppId);
|
|
2004
|
-
console.log("\u{1F3AE} UI-INIT: Chromecast config provided:", !!chromecastConfig, chromecastConfig);
|
|
2005
1756
|
const uiConfig = {
|
|
2006
1757
|
seekBarColors: {
|
|
2007
1758
|
base: seekbarColors?.base || "rgba(255, 255, 255, 0.3)",
|
|
@@ -2014,7 +1765,8 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
|
|
|
2014
1765
|
controlPanelElements,
|
|
2015
1766
|
addBigPlayButton: isMobile,
|
|
2016
1767
|
// Always configure chromecast with defaults or provided config
|
|
2017
|
-
castReceiverAppId,
|
|
1768
|
+
castReceiverAppId: chromecastConfig?.receiverApplicationId || "CC1AD845",
|
|
1769
|
+
// Default Media Receiver
|
|
2018
1770
|
castAndroidReceiverCompatible: true,
|
|
2019
1771
|
// Enable Android TV compatibility
|
|
2020
1772
|
overflowMenuButtons: [
|
|
@@ -2023,66 +1775,11 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
|
|
|
2023
1775
|
"playback_rate"
|
|
2024
1776
|
]
|
|
2025
1777
|
};
|
|
2026
|
-
|
|
2027
|
-
console.log("\u{1F3AE} UI-INIT: Applying UI configuration...");
|
|
2028
|
-
console.log("\u{1F3AE} UI-INIT: RACE CHECK - Pre-configure state:");
|
|
2029
|
-
console.log("\u{1F3AE} UI-INIT: - UI exists:", !!ui);
|
|
2030
|
-
console.log("\u{1F3AE} UI-INIT: - Cast receiver ID:", uiConfig.castReceiverAppId);
|
|
2031
|
-
console.log("\u{1F3AE} UI-INIT: - Cast compatibility:", uiConfig.castAndroidReceiverCompatible);
|
|
2032
|
-
const configureStartTime = performance.now();
|
|
2033
|
-
try {
|
|
2034
|
-
ui.configure(uiConfig);
|
|
2035
|
-
const configureEndTime = performance.now();
|
|
2036
|
-
console.log(`\u{1F3AE} UI-INIT: UI configuration applied successfully in ${(configureEndTime - configureStartTime).toFixed(2)}ms`);
|
|
2037
|
-
setTimeout(() => {
|
|
2038
|
-
const castButton = containerRef.current?.querySelector(".shaka-cast-button");
|
|
2039
|
-
const castAvailable = !!window.chrome?.cast?.isAvailable;
|
|
2040
|
-
console.log("\u{1F3AE} UI-INIT: POST-CONFIGURE CAST CHECK:");
|
|
2041
|
-
console.log("\u{1F3AE} UI-INIT: - Cast button found:", !!castButton);
|
|
2042
|
-
console.log("\u{1F3AE} UI-INIT: - Chrome cast API available:", castAvailable);
|
|
2043
|
-
console.log("\u{1F3AE} UI-INIT: - Cast button visible:", castButton ? !castButton.hasAttribute("hidden") : false);
|
|
2044
|
-
if (castButton) {
|
|
2045
|
-
castButton.addEventListener("click", async () => {
|
|
2046
|
-
console.log("\u{1F3AE} CAST-CLICK: Cast button clicked!");
|
|
2047
|
-
console.log("\u{1F3AE} CAST-CLICK: Player state:", {
|
|
2048
|
-
exists: !!playerRef.current,
|
|
2049
|
-
isDestroyed: playerRef.current?.isDestroyed?.(),
|
|
2050
|
-
videoLoaded: !!videoRef.current?.src,
|
|
2051
|
-
videoCurrentTime: videoRef.current?.currentTime,
|
|
2052
|
-
videoDuration: videoRef.current?.duration
|
|
2053
|
-
});
|
|
2054
|
-
const cast = window.chrome?.cast;
|
|
2055
|
-
const framework = cast?.framework;
|
|
2056
|
-
if (framework?.CastContext) {
|
|
2057
|
-
const castContext = framework.CastContext.getInstance();
|
|
2058
|
-
try {
|
|
2059
|
-
castContext.setOptions?.({
|
|
2060
|
-
receiverApplicationId: chromecastConfig?.receiverApplicationId || "CC1AD845",
|
|
2061
|
-
autoJoinPolicy: cast?.AutoJoinPolicy?.TAB_AND_ORIGIN_SCOPED || "origin_scoped"
|
|
2062
|
-
});
|
|
2063
|
-
console.log("\u{1F3AE} CAST-CLICK: CastContext options set");
|
|
2064
|
-
} catch (e) {
|
|
2065
|
-
console.warn("\u{1F3AE} CAST-CLICK: Failed to set CastContext options", e);
|
|
2066
|
-
}
|
|
2067
|
-
console.log("\u{1F3AE} CAST-CLICK: Cast state:", castContext.getCastState?.());
|
|
2068
|
-
} else {
|
|
2069
|
-
console.warn("\u{1F3AE} CAST-CLICK: Cast framework not available on click");
|
|
2070
|
-
}
|
|
2071
|
-
});
|
|
2072
|
-
}
|
|
2073
|
-
}, 50);
|
|
2074
|
-
} catch (error) {
|
|
2075
|
-
const configureEndTime = performance.now();
|
|
2076
|
-
console.error(`\u{1F3AE} UI-INIT: ERROR during UI configuration after ${(configureEndTime - configureStartTime).toFixed(2)}ms:`, error);
|
|
2077
|
-
throw error;
|
|
2078
|
-
}
|
|
2079
|
-
console.log("\u{1F3AE} UI-INIT: Setting up mobile-specific customizations...");
|
|
1778
|
+
ui.configure(uiConfig);
|
|
2080
1779
|
if (isMobile) {
|
|
2081
|
-
console.log("\u{1F3AE} UI-INIT: Setting up big play button customization for mobile");
|
|
2082
1780
|
const customizeBigPlayButton = () => {
|
|
2083
1781
|
const bigPlayButton = containerRef.current?.querySelector(".shaka-big-play-button");
|
|
2084
1782
|
if (bigPlayButton && !bigPlayButton.hasAttribute("data-customized")) {
|
|
2085
|
-
console.log("\u{1F3AE} UI-INIT: Customizing big play button");
|
|
2086
1783
|
const buttonSize = iconSizes?.bigPlayButton || 40;
|
|
2087
1784
|
bigPlayButton.innerHTML = renderIcon(BigPlayIcon, { size: buttonSize });
|
|
2088
1785
|
bigPlayButton.setAttribute("data-customized", "true");
|
|
@@ -2090,10 +1787,8 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
|
|
|
2090
1787
|
buttonElement.style.display = "flex";
|
|
2091
1788
|
buttonElement.style.alignItems = "center";
|
|
2092
1789
|
buttonElement.style.justifyContent = "center";
|
|
2093
|
-
console.log("\u{1F3AE} UI-INIT: Big play button customized successfully");
|
|
2094
1790
|
}
|
|
2095
1791
|
};
|
|
2096
|
-
console.log("\u{1F3AE} UI-INIT: Scheduling big play button customization");
|
|
2097
1792
|
setTimeout(customizeBigPlayButton, 100);
|
|
2098
1793
|
const observer = new MutationObserver(() => {
|
|
2099
1794
|
customizeBigPlayButton();
|
|
@@ -2104,29 +1799,18 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
|
|
|
2104
1799
|
subtree: true,
|
|
2105
1800
|
attributes: false
|
|
2106
1801
|
});
|
|
2107
|
-
console.log("\u{1F3AE} UI-INIT: Mutation observer set up for big play button");
|
|
2108
1802
|
}
|
|
2109
|
-
} else {
|
|
2110
|
-
console.log("\u{1F3AE} UI-INIT: Desktop mode - skipping big play button customization");
|
|
2111
1803
|
}
|
|
2112
|
-
console.log("\u{1F3AE} UI-INIT: Seekbar styling handled by CSS");
|
|
2113
|
-
const endTime = performance.now();
|
|
2114
|
-
console.log(`\u{1F3AE} UI-INIT: UI initialization completed successfully in ${(endTime - startTime).toFixed(2)}ms`);
|
|
2115
1804
|
return ui;
|
|
2116
1805
|
}, [controls, containerRef, playerRef, videoRef, chromecastConfig, seekbarColors, onSkipBack, onSkipForward, iconSizes]);
|
|
2117
1806
|
const destroyUI = (0, import_react6.useCallback)(() => {
|
|
2118
1807
|
if (uiRef.current) {
|
|
2119
1808
|
try {
|
|
2120
|
-
console.log("\u{1F3AE} UI-DESTROY: Destroying Shaka UI...");
|
|
2121
1809
|
uiRef.current.destroy();
|
|
2122
|
-
console.log("\u{1F3AE} UI-DESTROY: Shaka UI destroyed successfully");
|
|
2123
1810
|
} catch (error) {
|
|
2124
|
-
console.error("
|
|
1811
|
+
console.error("Error destroying UI:", error);
|
|
2125
1812
|
}
|
|
2126
1813
|
uiRef.current = null;
|
|
2127
|
-
console.log("\u{1F3AE} UI-DESTROY: UI reference cleared");
|
|
2128
|
-
} else {
|
|
2129
|
-
console.log("\u{1F3AE} UI-DESTROY: No UI instance to destroy");
|
|
2130
1814
|
}
|
|
2131
1815
|
}, []);
|
|
2132
1816
|
return {
|
|
@@ -2893,9 +2577,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
|
|
|
2893
2577
|
.grid {
|
|
2894
2578
|
display: grid;
|
|
2895
2579
|
}
|
|
2896
|
-
.hidden {
|
|
2897
|
-
display: none;
|
|
2898
|
-
}
|
|
2899
2580
|
.aspect-video {
|
|
2900
2581
|
aspect-ratio: var(--aspect-video);
|
|
2901
2582
|
}
|
|
@@ -3653,18 +3334,14 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3653
3334
|
const videoRef = (0, import_react12.useRef)(null);
|
|
3654
3335
|
const containerRef = (0, import_react12.useRef)(null);
|
|
3655
3336
|
const adContainerRef = (0, import_react12.useRef)(null);
|
|
3656
|
-
const isInitializingRef = (0, import_react12.useRef)(false);
|
|
3657
|
-
const stableShakaConfig = (0, import_react12.useMemo)(() => shakaConfig, [shakaConfig]);
|
|
3658
|
-
const stableDrmConfig = (0, import_react12.useMemo)(() => drmConfig, [drmConfig]);
|
|
3659
|
-
const stableMuxConfig = (0, import_react12.useMemo)(() => muxConfig, [muxConfig]);
|
|
3660
3337
|
(0, import_react12.useImperativeHandle)(ref, () => videoRef.current, []);
|
|
3661
3338
|
const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
|
|
3662
3339
|
src,
|
|
3663
|
-
shakaConfig
|
|
3664
|
-
drmConfig
|
|
3340
|
+
shakaConfig,
|
|
3341
|
+
drmConfig,
|
|
3665
3342
|
onError: events?.onError,
|
|
3666
3343
|
onPlayerReady: events?.onPlayerReady,
|
|
3667
|
-
muxConfig
|
|
3344
|
+
muxConfig,
|
|
3668
3345
|
onMuxReady: events?.onMuxReady,
|
|
3669
3346
|
onMuxDataUpdate: events?.onMuxDataUpdate
|
|
3670
3347
|
});
|
|
@@ -3698,7 +3375,7 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3698
3375
|
onLoadStart: events?.onLoadStart,
|
|
3699
3376
|
onCanPlay: events?.onCanPlay
|
|
3700
3377
|
});
|
|
3701
|
-
const { uiRef, initializeUI } = useShakaUI(
|
|
3378
|
+
const { uiRef, initializeUI, destroyUI } = useShakaUI(
|
|
3702
3379
|
playerRef,
|
|
3703
3380
|
containerRef,
|
|
3704
3381
|
videoRef,
|
|
@@ -3751,105 +3428,57 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3751
3428
|
}
|
|
3752
3429
|
}
|
|
3753
3430
|
};
|
|
3431
|
+
const initializeChromecast = () => {
|
|
3432
|
+
try {
|
|
3433
|
+
if (typeof window !== "undefined" && window.chrome?.cast) {
|
|
3434
|
+
const castContext = window.chrome.cast.CastContext.getInstance();
|
|
3435
|
+
if (castContext) {
|
|
3436
|
+
castContext.setOptions({
|
|
3437
|
+
receiverApplicationId: chromecastConfig?.receiverApplicationId || "CC1AD845"
|
|
3438
|
+
// Default Media Receiver
|
|
3439
|
+
});
|
|
3440
|
+
castContext.addEventListener("caststatechanged", (event) => {
|
|
3441
|
+
const isCasting = event.castState === "CONNECTED";
|
|
3442
|
+
events?.onCastStateChange?.(isCasting);
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
} else {
|
|
3446
|
+
if (events?.onCastStateChange) {
|
|
3447
|
+
setTimeout(() => events.onCastStateChange(false), 100);
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
} catch (error) {
|
|
3451
|
+
console.warn("Chromecast initialization failed:", error);
|
|
3452
|
+
if (events?.onCastStateChange) {
|
|
3453
|
+
setTimeout(() => events.onCastStateChange(false), 100);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
};
|
|
3754
3457
|
(0, import_react12.useEffect)(() => {
|
|
3755
|
-
console.log("SOURCE IS", src);
|
|
3756
|
-
console.log("\u{1F680} MAIN-INIT: Starting main player initialization sequence...");
|
|
3757
|
-
const initStartTime = performance.now();
|
|
3758
3458
|
const video = videoRef.current;
|
|
3759
|
-
if (!video)
|
|
3760
|
-
console.warn("\u{1F680} MAIN-INIT: Video element not available, skipping initialization");
|
|
3761
|
-
return;
|
|
3762
|
-
}
|
|
3763
|
-
console.log("\u{1F680} MAIN-INIT: Video element available, proceeding with initialization");
|
|
3459
|
+
if (!video) return;
|
|
3764
3460
|
const initialize = async () => {
|
|
3765
|
-
if (isInitializingRef.current) {
|
|
3766
|
-
console.log("\u{1F680} MAIN-INIT: Initialization already in progress, skipping...");
|
|
3767
|
-
return;
|
|
3768
|
-
}
|
|
3769
|
-
if (playerRef.current && !playerRef.current.isDestroyed?.()) {
|
|
3770
|
-
console.log("\u{1F680} MAIN-INIT: Player already exists and is not destroyed, loading new source instead of re-initialization");
|
|
3771
|
-
try {
|
|
3772
|
-
const manifestUrl = src.url;
|
|
3773
|
-
console.log("\u{1F680} MAIN-INIT: Loading new manifest:", manifestUrl);
|
|
3774
|
-
await playerRef.current.load(manifestUrl);
|
|
3775
|
-
console.log("\u{1F680} MAIN-INIT: New manifest loaded successfully without re-initialization");
|
|
3776
|
-
isInitializingRef.current = false;
|
|
3777
|
-
return;
|
|
3778
|
-
} catch (error) {
|
|
3779
|
-
if (error && typeof error === "object" && "code" in error && error.code === 7e3) {
|
|
3780
|
-
console.log("\u{1F680} MAIN-INIT: Benign LOAD_INTERRUPTED (7000) while loading new source. Skipping re-init.");
|
|
3781
|
-
isInitializingRef.current = false;
|
|
3782
|
-
return;
|
|
3783
|
-
}
|
|
3784
|
-
console.error("\u{1F680} MAIN-INIT: Failed to load new source, proceeding with full re-initialization:", error);
|
|
3785
|
-
}
|
|
3786
|
-
}
|
|
3787
|
-
isInitializingRef.current = true;
|
|
3788
|
-
console.log("\u{1F680} MAIN-INIT: Setting initialization flag to prevent race conditions");
|
|
3789
3461
|
try {
|
|
3790
|
-
console.log("\u{1F680} MAIN-INIT: === STEP 1: Initialize Player ===");
|
|
3791
|
-
const playerInitStart = performance.now();
|
|
3792
3462
|
await initializePlayer(video);
|
|
3793
|
-
const playerInitEnd = performance.now();
|
|
3794
|
-
console.log(`\u{1F680} MAIN-INIT: Player initialization completed in ${(playerInitEnd - playerInitStart).toFixed(2)}ms`);
|
|
3795
|
-
console.log("\u{1F680} MAIN-INIT: === STEP 2: Setup Event Listeners ===");
|
|
3796
|
-
const eventListenersStart = performance.now();
|
|
3797
3463
|
setupEventListeners();
|
|
3798
|
-
const eventListenersEnd = performance.now();
|
|
3799
|
-
console.log(`\u{1F680} MAIN-INIT: Event listeners setup completed in ${(eventListenersEnd - eventListenersStart).toFixed(2)}ms`);
|
|
3800
|
-
console.log("\u{1F680} MAIN-INIT: === STEP 3: Setup Quality Tracking ===");
|
|
3801
|
-
const qualityStart = performance.now();
|
|
3802
3464
|
const cleanupQuality = setupQualityTracking();
|
|
3803
3465
|
configureQuality();
|
|
3804
|
-
const qualityEnd = performance.now();
|
|
3805
|
-
console.log(`\u{1F680} MAIN-INIT: Quality setup completed in ${(qualityEnd - qualityStart).toFixed(2)}ms`);
|
|
3806
|
-
console.log("\u{1F680} MAIN-INIT: === STEP 4: Initialize UI (Including Chromecast) ===");
|
|
3807
|
-
const timeSincePlayerInit = performance.now() - playerInitEnd;
|
|
3808
|
-
console.log(`\u{1F680} MAIN-INIT: RACE CHECK - Time gap between player and UI init: ${timeSincePlayerInit.toFixed(2)}ms`);
|
|
3809
|
-
const uiInitStart = performance.now();
|
|
3810
3466
|
await initializeUI();
|
|
3811
|
-
const uiInitEnd = performance.now();
|
|
3812
|
-
console.log(`\u{1F680} MAIN-INIT: UI initialization completed in ${(uiInitEnd - uiInitStart).toFixed(2)}ms`);
|
|
3813
|
-
console.log("\u{1F680} MAIN-INIT: === STEP 5: Initialize Ads ===");
|
|
3814
|
-
const adsInitStart = performance.now();
|
|
3815
3467
|
initializeAds();
|
|
3816
|
-
|
|
3817
|
-
console.log(`\u{1F680} MAIN-INIT: Ads initialization completed in ${(adsInitEnd - adsInitStart).toFixed(2)}ms`);
|
|
3818
|
-
const totalInitTime = performance.now() - initStartTime;
|
|
3819
|
-
console.log(`\u{1F680} MAIN-INIT: === INITIALIZATION COMPLETE ===`);
|
|
3820
|
-
console.log(`\u{1F680} MAIN-INIT: Total initialization time: ${totalInitTime.toFixed(2)}ms`);
|
|
3468
|
+
initializeChromecast();
|
|
3821
3469
|
} catch (error) {
|
|
3822
|
-
|
|
3823
|
-
console.error(`\u{1F680} MAIN-INIT: Error during player initialization after ${errorTime.toFixed(2)}ms:`, error);
|
|
3470
|
+
console.error("Error during player initialization:", error);
|
|
3824
3471
|
handleMuxError(error);
|
|
3825
|
-
} finally {
|
|
3826
|
-
isInitializingRef.current = false;
|
|
3827
|
-
console.log("\u{1F680} MAIN-INIT: Clearing initialization flag");
|
|
3828
3472
|
}
|
|
3829
3473
|
};
|
|
3830
3474
|
initialize();
|
|
3831
3475
|
return () => {
|
|
3832
|
-
console.log("\u{1F680} MAIN-CLEANUP: Starting cleanup sequence...");
|
|
3833
|
-
const cleanupStart = performance.now();
|
|
3834
|
-
if (!playerRef.current && !isInitializingRef.current) {
|
|
3835
|
-
console.log("\u{1F680} MAIN-CLEANUP: No player to cleanup and no initialization in progress, skipping cleanup");
|
|
3836
|
-
return;
|
|
3837
|
-
}
|
|
3838
|
-
if (playerRef.current && !playerRef.current.isDestroyed?.()) {
|
|
3839
|
-
console.log("\u{1F680} MAIN-CLEANUP: Player exists and is not destroyed - this might be a source change");
|
|
3840
|
-
console.log("\u{1F680} MAIN-CLEANUP: Checking if this is a real unmount or just a re-render...");
|
|
3841
|
-
}
|
|
3842
|
-
isInitializingRef.current = false;
|
|
3843
|
-
console.log("\u{1F680} MAIN-CLEANUP: Reset initialization flag");
|
|
3844
|
-
console.log("\u{1F680} MAIN-CLEANUP: Cleaning up event listeners...");
|
|
3845
3476
|
cleanupEventListeners();
|
|
3846
|
-
|
|
3847
|
-
console.log("\u{1F680} MAIN-CLEANUP: Destroying Mux...");
|
|
3477
|
+
destroyUI();
|
|
3848
3478
|
destroyMux();
|
|
3849
|
-
|
|
3850
|
-
console.log(`\u{1F680} MAIN-CLEANUP: Cleanup completed in ${(cleanupEnd - cleanupStart).toFixed(2)}ms`);
|
|
3479
|
+
destroyPlayer();
|
|
3851
3480
|
};
|
|
3852
|
-
}, [src
|
|
3481
|
+
}, [src]);
|
|
3853
3482
|
(0, import_react12.useEffect)(() => {
|
|
3854
3483
|
const video = videoRef.current;
|
|
3855
3484
|
if (!video) return;
|
|
@@ -4449,7 +4078,8 @@ var Video = ({
|
|
|
4449
4078
|
const video = providedVideoData || data;
|
|
4450
4079
|
const { t } = useMessages_default(locale);
|
|
4451
4080
|
const activePlaylist = findHLSPlaylist(video);
|
|
4452
|
-
const
|
|
4081
|
+
const activePlaylistUrl = activePlaylist?.url ?? activePlaylist?.drm?.widevine?.playlistUrl ?? activePlaylist?.drm?.playready?.playlistUrl ?? activePlaylist?.drm?.fairplay?.playlistUrl;
|
|
4082
|
+
const activePlaylistHasUrl = !!activePlaylistUrl;
|
|
4453
4083
|
(0, import_react14.useEffect)(() => {
|
|
4454
4084
|
if (events?.onVideoData && video) {
|
|
4455
4085
|
events.onVideoData(video);
|
|
@@ -4458,7 +4088,7 @@ var Video = ({
|
|
|
4458
4088
|
if (isLoading || !providedVideoData && !video) {
|
|
4459
4089
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: (0, import_tailwind_merge3.twMerge)("md:rounded-2xl overflow-hidden aspect-video", className), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative w-full h-full bg-[#151515]", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Loading, {}) }) });
|
|
4460
4090
|
}
|
|
4461
|
-
if (!isLoading && video && !
|
|
4091
|
+
if (!isLoading && video && !activePlaylistHasUrl && events?.onEmptyPlaylists) {
|
|
4462
4092
|
events.onEmptyPlaylists();
|
|
4463
4093
|
}
|
|
4464
4094
|
if (error || video?.error) {
|
|
@@ -4480,7 +4110,7 @@ var Video = ({
|
|
|
4480
4110
|
children
|
|
4481
4111
|
] }) });
|
|
4482
4112
|
}
|
|
4483
|
-
if (!
|
|
4113
|
+
if (!activePlaylist || !activePlaylistHasUrl) {
|
|
4484
4114
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: (0, import_tailwind_merge3.twMerge)("md:rounded-2xl overflow-hidden aspect-video", className), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "relative w-full h-full bg-[#151515]", children: [
|
|
4485
4115
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Title, { title: video?.name || "" }),
|
|
4486
4116
|
children
|
|
@@ -4560,9 +4190,11 @@ var Event = ({
|
|
|
4560
4190
|
if (videosWithPlaylists.length > 0) {
|
|
4561
4191
|
let hlsPlaylistFound = false;
|
|
4562
4192
|
for (const video of videosWithPlaylists) {
|
|
4563
|
-
const
|
|
4564
|
-
|
|
4565
|
-
|
|
4193
|
+
const activePlaylist2 = findHLSPlaylist(video);
|
|
4194
|
+
const activePlaylistUrl = activePlaylist2?.url ?? activePlaylist2?.drm?.widevine?.playlistUrl ?? activePlaylist2?.drm?.playready?.playlistUrl ?? activePlaylist2?.drm?.fairplay?.playlistUrl;
|
|
4195
|
+
const activePlaylistHasUrl = !!activePlaylistUrl;
|
|
4196
|
+
if (activePlaylist2 && activePlaylistHasUrl) {
|
|
4197
|
+
setActivePlaylist(activePlaylist2);
|
|
4566
4198
|
setActiveVideoId(video.id);
|
|
4567
4199
|
hlsPlaylistFound = true;
|
|
4568
4200
|
break;
|
|
@@ -4902,9 +4534,11 @@ var CreativeWork = ({
|
|
|
4902
4534
|
if (videosWithPlaylists.length > 0) {
|
|
4903
4535
|
let hlsPlaylistFound = false;
|
|
4904
4536
|
for (const video of videosWithPlaylists) {
|
|
4905
|
-
const
|
|
4906
|
-
|
|
4907
|
-
|
|
4537
|
+
const activePlaylist2 = findHLSPlaylist(video);
|
|
4538
|
+
const activePlaylistUrl = activePlaylist2?.url ?? activePlaylist2?.drm?.widevine?.playlistUrl ?? activePlaylist2?.drm?.playready?.playlistUrl ?? activePlaylist2?.drm?.fairplay?.playlistUrl;
|
|
4539
|
+
const activePlaylistHasUrl = !!activePlaylistUrl;
|
|
4540
|
+
if (activePlaylist2 && activePlaylistHasUrl) {
|
|
4541
|
+
setActivePlaylist(activePlaylist2);
|
|
4908
4542
|
setActiveVideoId(video.id);
|
|
4909
4543
|
hlsPlaylistFound = true;
|
|
4910
4544
|
break;
|