@mottosports/motto-video-player 1.0.1-rc.29 → 1.0.1-rc.30
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 +52 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1175,6 +1175,12 @@ var isPlayReadySupported = () => {
|
|
|
1175
1175
|
return isWindows || isXbox || isEdge || isIE;
|
|
1176
1176
|
};
|
|
1177
1177
|
|
|
1178
|
+
// src/hooks/useShakePlayer.ts
|
|
1179
|
+
var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
1180
|
+
|
|
1181
|
+
// package.json
|
|
1182
|
+
var version = "1.0.1-rc.30";
|
|
1183
|
+
|
|
1178
1184
|
// src/hooks/useShakePlayer.ts
|
|
1179
1185
|
var useShakePlayer = ({
|
|
1180
1186
|
src,
|
|
@@ -1182,9 +1188,11 @@ var useShakePlayer = ({
|
|
|
1182
1188
|
drmConfig,
|
|
1183
1189
|
onError,
|
|
1184
1190
|
onPlayerReady,
|
|
1185
|
-
|
|
1186
|
-
|
|
1191
|
+
muxConfig,
|
|
1192
|
+
onMuxReady,
|
|
1193
|
+
onMuxDataUpdate
|
|
1187
1194
|
}) => {
|
|
1195
|
+
const playerRef = (0, import_react.useRef)(null);
|
|
1188
1196
|
const initializePlayer = (0, import_react.useCallback)(async (video) => {
|
|
1189
1197
|
try {
|
|
1190
1198
|
import_shaka_player.default.polyfill.installAll();
|
|
@@ -1254,7 +1262,33 @@ var useShakePlayer = ({
|
|
|
1254
1262
|
console.error("Shaka Player Error:", error);
|
|
1255
1263
|
onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
|
|
1256
1264
|
});
|
|
1257
|
-
|
|
1265
|
+
if (muxConfig) {
|
|
1266
|
+
try {
|
|
1267
|
+
const playerInitTime = import_mux_data_shakaplayer.default.utils.now();
|
|
1268
|
+
const muxOptions = {
|
|
1269
|
+
debug: muxConfig.debug || false,
|
|
1270
|
+
disableCookies: muxConfig.disableCookies || false,
|
|
1271
|
+
respectDoNotTrack: muxConfig.respectDoNotTrack || false,
|
|
1272
|
+
automaticErrorTracking: muxConfig.automaticErrorTracking !== false,
|
|
1273
|
+
...muxConfig.beaconCollectionDomain && { beaconCollectionDomain: muxConfig.beaconCollectionDomain },
|
|
1274
|
+
...muxConfig.errorTranslator && { errorTranslator: muxConfig.errorTranslator },
|
|
1275
|
+
data: {
|
|
1276
|
+
env_key: muxConfig.envKey,
|
|
1277
|
+
player_name: muxConfig?.metadata?.player_name,
|
|
1278
|
+
player_version: version,
|
|
1279
|
+
player_init_time: playerInitTime,
|
|
1280
|
+
video_title: muxConfig?.metadata?.video_title ?? "",
|
|
1281
|
+
video_id: muxConfig?.metadata?.video_id ?? "",
|
|
1282
|
+
viewer_user_id: muxConfig?.metadata?.viewer_user_id ?? "",
|
|
1283
|
+
...muxConfig.metadata
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
(0, import_mux_data_shakaplayer.default)(player, muxOptions, import_shaka_player.default);
|
|
1287
|
+
onMuxReady?.();
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
console.error("Failed to initialize Mux Analytics:", error);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1258
1292
|
await player.load(manifestUrl);
|
|
1259
1293
|
onPlayerReady?.(player);
|
|
1260
1294
|
return player;
|
|
@@ -1266,7 +1300,7 @@ var useShakePlayer = ({
|
|
|
1266
1300
|
onError?.(error);
|
|
1267
1301
|
throw error;
|
|
1268
1302
|
}
|
|
1269
|
-
}, [shakaConfig, drmConfig, src, onError, onPlayerReady,
|
|
1303
|
+
}, [shakaConfig, drmConfig, src, onError, onPlayerReady, muxConfig, onMuxReady]);
|
|
1270
1304
|
const destroyPlayer = (0, import_react.useCallback)(async () => {
|
|
1271
1305
|
if (playerRef.current) {
|
|
1272
1306
|
try {
|
|
@@ -1279,6 +1313,7 @@ var useShakePlayer = ({
|
|
|
1279
1313
|
}
|
|
1280
1314
|
}, [playerRef]);
|
|
1281
1315
|
return {
|
|
1316
|
+
playerRef,
|
|
1282
1317
|
initializePlayer,
|
|
1283
1318
|
destroyPlayer
|
|
1284
1319
|
};
|
|
@@ -1400,19 +1435,14 @@ var useSkipControls = (videoRef, onSkipBack, onSkipForward) => {
|
|
|
1400
1435
|
|
|
1401
1436
|
// src/hooks/useMuxAnalytics.ts
|
|
1402
1437
|
var import_react4 = require("react");
|
|
1403
|
-
var
|
|
1438
|
+
var import_mux_data_shakaplayer2 = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
1404
1439
|
var import_shaka_player2 = __toESM(require("shaka-player/dist/shaka-player.ui"));
|
|
1405
|
-
|
|
1406
|
-
// package.json
|
|
1407
|
-
var version = "1.0.1-rc.29";
|
|
1408
|
-
|
|
1409
|
-
// src/hooks/useMuxAnalytics.ts
|
|
1410
1440
|
var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
|
|
1411
1441
|
const shakaPlayerMuxRef = (0, import_react4.useRef)(null);
|
|
1412
1442
|
const initializeMux = (0, import_react4.useCallback)(() => {
|
|
1413
1443
|
if (!muxConfig || !playerRef.current) return;
|
|
1414
1444
|
try {
|
|
1415
|
-
const playerInitTime =
|
|
1445
|
+
const playerInitTime = import_mux_data_shakaplayer2.default.utils.now();
|
|
1416
1446
|
const muxOptions = {
|
|
1417
1447
|
debug: muxConfig.debug || false,
|
|
1418
1448
|
disableCookies: muxConfig.disableCookies || false,
|
|
@@ -1431,7 +1461,7 @@ var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
|
|
|
1431
1461
|
...muxConfig.metadata
|
|
1432
1462
|
}
|
|
1433
1463
|
};
|
|
1434
|
-
shakaPlayerMuxRef.current = (0,
|
|
1464
|
+
shakaPlayerMuxRef.current = (0, import_mux_data_shakaplayer2.default)(playerRef.current, muxOptions, import_shaka_player2.default);
|
|
1435
1465
|
onMuxReady?.();
|
|
1436
1466
|
} catch (error) {
|
|
1437
1467
|
console.error("Failed to initialize Mux Analytics:", error);
|
|
@@ -3309,22 +3339,22 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3309
3339
|
const containerRef = (0, import_react12.useRef)(null);
|
|
3310
3340
|
const adContainerRef = (0, import_react12.useRef)(null);
|
|
3311
3341
|
(0, import_react12.useImperativeHandle)(ref, () => videoRef.current, []);
|
|
3312
|
-
const playerRef = (
|
|
3313
|
-
const {
|
|
3314
|
-
initializeMux,
|
|
3315
|
-
updateMuxData,
|
|
3316
|
-
handleMuxError,
|
|
3317
|
-
destroyMux
|
|
3318
|
-
} = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
|
|
3319
|
-
const { initializePlayer, destroyPlayer } = useShakePlayer({
|
|
3342
|
+
const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
|
|
3320
3343
|
src,
|
|
3321
3344
|
shakaConfig,
|
|
3322
3345
|
drmConfig,
|
|
3323
3346
|
onError: events?.onError,
|
|
3324
3347
|
onPlayerReady: events?.onPlayerReady,
|
|
3325
|
-
|
|
3326
|
-
|
|
3348
|
+
muxConfig,
|
|
3349
|
+
onMuxReady: events?.onMuxReady,
|
|
3350
|
+
onMuxDataUpdate: events?.onMuxDataUpdate
|
|
3327
3351
|
});
|
|
3352
|
+
const {
|
|
3353
|
+
initializeMux,
|
|
3354
|
+
updateMuxData,
|
|
3355
|
+
handleMuxError,
|
|
3356
|
+
destroyMux
|
|
3357
|
+
} = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
|
|
3328
3358
|
const {
|
|
3329
3359
|
getAvailableQualities,
|
|
3330
3360
|
setQuality,
|