@mottosports/motto-video-player 1.0.1-rc.29 → 1.0.1-rc.31
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 +53 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1168,13 +1168,18 @@ var isPlayReadySupported = () => {
|
|
|
1168
1168
|
return false;
|
|
1169
1169
|
}
|
|
1170
1170
|
const userAgent = navigator.userAgent || "";
|
|
1171
|
-
const isWindows = /Windows/.test(userAgent);
|
|
1172
1171
|
const isXbox = /Xbox/.test(userAgent);
|
|
1173
1172
|
const isEdge = /Edg/.test(userAgent);
|
|
1174
1173
|
const isIE = /Trident|MSIE/.test(userAgent);
|
|
1175
|
-
return
|
|
1174
|
+
return isXbox || isEdge || isIE;
|
|
1176
1175
|
};
|
|
1177
1176
|
|
|
1177
|
+
// src/hooks/useShakePlayer.ts
|
|
1178
|
+
var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
1179
|
+
|
|
1180
|
+
// package.json
|
|
1181
|
+
var version = "1.0.1-rc.31";
|
|
1182
|
+
|
|
1178
1183
|
// src/hooks/useShakePlayer.ts
|
|
1179
1184
|
var useShakePlayer = ({
|
|
1180
1185
|
src,
|
|
@@ -1182,9 +1187,11 @@ var useShakePlayer = ({
|
|
|
1182
1187
|
drmConfig,
|
|
1183
1188
|
onError,
|
|
1184
1189
|
onPlayerReady,
|
|
1185
|
-
|
|
1186
|
-
|
|
1190
|
+
muxConfig,
|
|
1191
|
+
onMuxReady,
|
|
1192
|
+
onMuxDataUpdate
|
|
1187
1193
|
}) => {
|
|
1194
|
+
const playerRef = (0, import_react.useRef)(null);
|
|
1188
1195
|
const initializePlayer = (0, import_react.useCallback)(async (video) => {
|
|
1189
1196
|
try {
|
|
1190
1197
|
import_shaka_player.default.polyfill.installAll();
|
|
@@ -1202,7 +1209,6 @@ var useShakePlayer = ({
|
|
|
1202
1209
|
let cert = null;
|
|
1203
1210
|
if (isDRM) {
|
|
1204
1211
|
const isPlayReady = isPlayReadySupported();
|
|
1205
|
-
const isFairPlay = isAppleDevice();
|
|
1206
1212
|
if (isAppleDevice() && src.drm.fairplay?.certificate_url) {
|
|
1207
1213
|
const req = await fetch(src.drm.fairplay.certificate_url);
|
|
1208
1214
|
cert = await req.arrayBuffer();
|
|
@@ -1254,7 +1260,33 @@ var useShakePlayer = ({
|
|
|
1254
1260
|
console.error("Shaka Player Error:", error);
|
|
1255
1261
|
onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
|
|
1256
1262
|
});
|
|
1257
|
-
|
|
1263
|
+
if (muxConfig) {
|
|
1264
|
+
try {
|
|
1265
|
+
const playerInitTime = import_mux_data_shakaplayer.default.utils.now();
|
|
1266
|
+
const muxOptions = {
|
|
1267
|
+
debug: muxConfig.debug || false,
|
|
1268
|
+
disableCookies: muxConfig.disableCookies || false,
|
|
1269
|
+
respectDoNotTrack: muxConfig.respectDoNotTrack || false,
|
|
1270
|
+
automaticErrorTracking: muxConfig.automaticErrorTracking !== false,
|
|
1271
|
+
...muxConfig.beaconCollectionDomain && { beaconCollectionDomain: muxConfig.beaconCollectionDomain },
|
|
1272
|
+
...muxConfig.errorTranslator && { errorTranslator: muxConfig.errorTranslator },
|
|
1273
|
+
data: {
|
|
1274
|
+
env_key: muxConfig.envKey,
|
|
1275
|
+
player_name: muxConfig?.metadata?.player_name,
|
|
1276
|
+
player_version: version,
|
|
1277
|
+
player_init_time: playerInitTime,
|
|
1278
|
+
video_title: muxConfig?.metadata?.video_title ?? "",
|
|
1279
|
+
video_id: muxConfig?.metadata?.video_id ?? "",
|
|
1280
|
+
viewer_user_id: muxConfig?.metadata?.viewer_user_id ?? "",
|
|
1281
|
+
...muxConfig.metadata
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
(0, import_mux_data_shakaplayer.default)(player, muxOptions, import_shaka_player.default);
|
|
1285
|
+
onMuxReady?.();
|
|
1286
|
+
} catch (error) {
|
|
1287
|
+
console.error("Failed to initialize Mux Analytics:", error);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1258
1290
|
await player.load(manifestUrl);
|
|
1259
1291
|
onPlayerReady?.(player);
|
|
1260
1292
|
return player;
|
|
@@ -1266,7 +1298,7 @@ var useShakePlayer = ({
|
|
|
1266
1298
|
onError?.(error);
|
|
1267
1299
|
throw error;
|
|
1268
1300
|
}
|
|
1269
|
-
}, [shakaConfig, drmConfig, src, onError, onPlayerReady,
|
|
1301
|
+
}, [shakaConfig, drmConfig, src, onError, onPlayerReady, muxConfig, onMuxReady]);
|
|
1270
1302
|
const destroyPlayer = (0, import_react.useCallback)(async () => {
|
|
1271
1303
|
if (playerRef.current) {
|
|
1272
1304
|
try {
|
|
@@ -1279,6 +1311,7 @@ var useShakePlayer = ({
|
|
|
1279
1311
|
}
|
|
1280
1312
|
}, [playerRef]);
|
|
1281
1313
|
return {
|
|
1314
|
+
playerRef,
|
|
1282
1315
|
initializePlayer,
|
|
1283
1316
|
destroyPlayer
|
|
1284
1317
|
};
|
|
@@ -1400,19 +1433,14 @@ var useSkipControls = (videoRef, onSkipBack, onSkipForward) => {
|
|
|
1400
1433
|
|
|
1401
1434
|
// src/hooks/useMuxAnalytics.ts
|
|
1402
1435
|
var import_react4 = require("react");
|
|
1403
|
-
var
|
|
1436
|
+
var import_mux_data_shakaplayer2 = __toESM(require("@mux/mux-data-shakaplayer"));
|
|
1404
1437
|
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
1438
|
var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
|
|
1411
1439
|
const shakaPlayerMuxRef = (0, import_react4.useRef)(null);
|
|
1412
1440
|
const initializeMux = (0, import_react4.useCallback)(() => {
|
|
1413
1441
|
if (!muxConfig || !playerRef.current) return;
|
|
1414
1442
|
try {
|
|
1415
|
-
const playerInitTime =
|
|
1443
|
+
const playerInitTime = import_mux_data_shakaplayer2.default.utils.now();
|
|
1416
1444
|
const muxOptions = {
|
|
1417
1445
|
debug: muxConfig.debug || false,
|
|
1418
1446
|
disableCookies: muxConfig.disableCookies || false,
|
|
@@ -1431,7 +1459,7 @@ var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
|
|
|
1431
1459
|
...muxConfig.metadata
|
|
1432
1460
|
}
|
|
1433
1461
|
};
|
|
1434
|
-
shakaPlayerMuxRef.current = (0,
|
|
1462
|
+
shakaPlayerMuxRef.current = (0, import_mux_data_shakaplayer2.default)(playerRef.current, muxOptions, import_shaka_player2.default);
|
|
1435
1463
|
onMuxReady?.();
|
|
1436
1464
|
} catch (error) {
|
|
1437
1465
|
console.error("Failed to initialize Mux Analytics:", error);
|
|
@@ -3309,22 +3337,22 @@ var Player = (0, import_react12.forwardRef)(
|
|
|
3309
3337
|
const containerRef = (0, import_react12.useRef)(null);
|
|
3310
3338
|
const adContainerRef = (0, import_react12.useRef)(null);
|
|
3311
3339
|
(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({
|
|
3340
|
+
const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
|
|
3320
3341
|
src,
|
|
3321
3342
|
shakaConfig,
|
|
3322
3343
|
drmConfig,
|
|
3323
3344
|
onError: events?.onError,
|
|
3324
3345
|
onPlayerReady: events?.onPlayerReady,
|
|
3325
|
-
|
|
3326
|
-
|
|
3346
|
+
muxConfig,
|
|
3347
|
+
onMuxReady: events?.onMuxReady,
|
|
3348
|
+
onMuxDataUpdate: events?.onMuxDataUpdate
|
|
3327
3349
|
});
|
|
3350
|
+
const {
|
|
3351
|
+
initializeMux,
|
|
3352
|
+
updateMuxData,
|
|
3353
|
+
handleMuxError,
|
|
3354
|
+
destroyMux
|
|
3355
|
+
} = useMuxAnalytics(playerRef, muxConfig, events?.onMuxReady, events?.onMuxDataUpdate);
|
|
3328
3356
|
const {
|
|
3329
3357
|
getAvailableQualities,
|
|
3330
3358
|
setQuality,
|