@mdcrtrs/player 0.3.0 → 0.4.0
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/README.md +6 -0
- package/dist/index.cjs +153 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +153 -41
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -51,11 +51,16 @@ function VideoPlayer() {
|
|
|
51
51
|
|------|------|----------|-------------|
|
|
52
52
|
| `creatorId` | `string` | Yes | Project public ID |
|
|
53
53
|
| `asset` | `PlayerAsset` | Yes | Asset to play (`assetId`, `playbackId`, `title`, optional `duration`) |
|
|
54
|
+
| `env` | `"production" \| "preview"` | No | Platform environment; `"preview"` calls `preview-api` / `preview-playback.mediacreators.io`. Default `"production"` |
|
|
54
55
|
| `auth` | `{ fanToken: string }` | No | Fan authentication for personalized features |
|
|
55
56
|
| `theme` | `{ primaryColor: string }` | No | Brand color (CSS color value) |
|
|
57
|
+
| `branding` | `PlayerBrandingConfig` | No | Custom branding logo (URL, link, title, white filter) |
|
|
58
|
+
| `config` | `PlayerConfig` | No | Player customization: controls visibility, accent color, languages |
|
|
56
59
|
| `playerTheme` | `string` | No | Player chrome theme name |
|
|
57
60
|
| `poster` | `string` | No | Poster image URL |
|
|
58
61
|
| `autoResume` | `boolean` | No | Resume from last watched position (requires `auth`) |
|
|
62
|
+
| `getSession` | `() => Promise<SessionToken>` | No | Host-minted session callback; skips internal session fetch |
|
|
63
|
+
| `onAccessDenied` | `(state: PlayerAccessState) => void` | No | Called on 403 from playback service (`"access_denied"` or `"not_available"`) |
|
|
59
64
|
| `className` | `string` | No | CSS class for the player container |
|
|
60
65
|
|
|
61
66
|
### Events
|
|
@@ -71,6 +76,7 @@ function VideoPlayer() {
|
|
|
71
76
|
| `onComplete` | `() => void` | Playback completed |
|
|
72
77
|
| `onResume` | `(position: number) => void` | Resumed from saved position |
|
|
73
78
|
| `onError` | `(error: { code: string, message: string }) => void` | Playback error |
|
|
79
|
+
| `onAccessDenied` | `(state: PlayerAccessState) => void` | Access denied by playback service |
|
|
74
80
|
|
|
75
81
|
## License
|
|
76
82
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -19,6 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
21
|
}
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
25
|
var __export = (target, all) => {
|
|
23
26
|
for (var name in all)
|
|
24
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -1116,11 +1119,19 @@ if (import_server_safe_globals.globalThis.customElements && !import_server_safe_
|
|
|
1116
1119
|
var import_react = require("react");
|
|
1117
1120
|
|
|
1118
1121
|
// src/types.ts
|
|
1119
|
-
var
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1122
|
+
var PLATFORM_ENDPOINTS = {
|
|
1123
|
+
production: {
|
|
1124
|
+
apiBase: "https://api.mediacreators.io",
|
|
1125
|
+
playbackBase: "https://playback.mediacreators.io"
|
|
1126
|
+
},
|
|
1127
|
+
preview: {
|
|
1128
|
+
apiBase: "https://preview-api.mediacreators.io",
|
|
1129
|
+
playbackBase: "https://preview-playback.mediacreators.io"
|
|
1130
|
+
}
|
|
1123
1131
|
};
|
|
1132
|
+
var PLATFORM = __spreadProps(__spreadValues({}, PLATFORM_ENDPOINTS.production), {
|
|
1133
|
+
dataEnvKey: "fhri2484lqcn6gk89r013ckmb"
|
|
1134
|
+
});
|
|
1124
1135
|
|
|
1125
1136
|
// src/lib/api.ts
|
|
1126
1137
|
var ApiError = class extends Error {
|
|
@@ -1130,6 +1141,22 @@ var ApiError = class extends Error {
|
|
|
1130
1141
|
this.name = "ApiError";
|
|
1131
1142
|
}
|
|
1132
1143
|
};
|
|
1144
|
+
var AccessDeniedError = class extends ApiError {
|
|
1145
|
+
constructor(state) {
|
|
1146
|
+
super(state === "not_available" ? "Content is not available" : "Access denied", 403);
|
|
1147
|
+
this.state = state;
|
|
1148
|
+
this.name = "AccessDeniedError";
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
async function readAccessState(res) {
|
|
1152
|
+
try {
|
|
1153
|
+
const body = await res.json();
|
|
1154
|
+
const code = body == null ? void 0 : body.error;
|
|
1155
|
+
return code === "access_denied" || code === "not_available" ? code : null;
|
|
1156
|
+
} catch (e) {
|
|
1157
|
+
return null;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1133
1160
|
async function fetchWithRetry(url, init, maxRetries = 3) {
|
|
1134
1161
|
let lastError = new Error("Unknown fetch error");
|
|
1135
1162
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
@@ -1148,12 +1175,12 @@ async function fetchWithRetry(url, init, maxRetries = 3) {
|
|
|
1148
1175
|
}
|
|
1149
1176
|
throw lastError;
|
|
1150
1177
|
}
|
|
1151
|
-
async function fetchSessionToken(creatorId, fanToken) {
|
|
1178
|
+
async function fetchSessionToken(creatorId, fanToken, env = "production") {
|
|
1152
1179
|
const headers = {};
|
|
1153
1180
|
if (fanToken) {
|
|
1154
1181
|
headers["X-Fan-Token"] = fanToken;
|
|
1155
1182
|
}
|
|
1156
|
-
const url = `${
|
|
1183
|
+
const url = `${PLATFORM_ENDPOINTS[env].apiBase}/v1/mos/${encodeURIComponent(creatorId)}/playback-session`;
|
|
1157
1184
|
const res = await fetchWithRetry(url, { method: "POST", headers });
|
|
1158
1185
|
if (!res.ok) {
|
|
1159
1186
|
throw new ApiError(`Failed to fetch session token: ${res.status}`, res.status);
|
|
@@ -1161,12 +1188,16 @@ async function fetchSessionToken(creatorId, fanToken) {
|
|
|
1161
1188
|
const json = await res.json();
|
|
1162
1189
|
return { token: json.token, expiresAt: json.expires_at };
|
|
1163
1190
|
}
|
|
1164
|
-
async function fetchPlaybackTokens(creatorId, playbackId, duration, sessionToken) {
|
|
1191
|
+
async function fetchPlaybackTokens(creatorId, playbackId, duration, sessionToken, env = "production") {
|
|
1165
1192
|
const params = new URLSearchParams({ duration: String(duration) });
|
|
1166
|
-
const url = `${
|
|
1193
|
+
const url = `${PLATFORM_ENDPOINTS[env].playbackBase}/v1/${encodeURIComponent(creatorId)}/tokens/${encodeURIComponent(playbackId)}?${params}`;
|
|
1167
1194
|
const res = await fetchWithRetry(url, {
|
|
1168
1195
|
headers: { Authorization: `Bearer ${sessionToken}` }
|
|
1169
1196
|
});
|
|
1197
|
+
if (res.status === 403) {
|
|
1198
|
+
const state = await readAccessState(res);
|
|
1199
|
+
if (state) throw new AccessDeniedError(state);
|
|
1200
|
+
}
|
|
1170
1201
|
if (res.status === 401 || res.status === 403) {
|
|
1171
1202
|
throw new ApiError("Session token invalid or expired", res.status);
|
|
1172
1203
|
}
|
|
@@ -1181,8 +1212,8 @@ async function fetchPlaybackTokens(creatorId, playbackId, duration, sessionToken
|
|
|
1181
1212
|
expiresIn: json.expires_in
|
|
1182
1213
|
};
|
|
1183
1214
|
}
|
|
1184
|
-
async function saveWatchProgress(creatorId, assetId, position, duration, fanToken, completed) {
|
|
1185
|
-
const url = `${
|
|
1215
|
+
async function saveWatchProgress(creatorId, assetId, position, duration, fanToken, completed, env = "production") {
|
|
1216
|
+
const url = `${PLATFORM_ENDPOINTS[env].apiBase}/v1/mos/${encodeURIComponent(creatorId)}/watch-progress/${encodeURIComponent(assetId)}`;
|
|
1186
1217
|
try {
|
|
1187
1218
|
const res = await fetch(url, {
|
|
1188
1219
|
method: "PUT",
|
|
@@ -1199,8 +1230,8 @@ async function saveWatchProgress(creatorId, assetId, position, duration, fanToke
|
|
|
1199
1230
|
return { ok: false, status: 0 };
|
|
1200
1231
|
}
|
|
1201
1232
|
}
|
|
1202
|
-
async function getWatchProgress(creatorId, assetId, fanToken) {
|
|
1203
|
-
const url = `${
|
|
1233
|
+
async function getWatchProgress(creatorId, assetId, fanToken, env = "production") {
|
|
1234
|
+
const url = `${PLATFORM_ENDPOINTS[env].apiBase}/v1/mos/${encodeURIComponent(creatorId)}/watch-progress/${encodeURIComponent(assetId)}`;
|
|
1204
1235
|
try {
|
|
1205
1236
|
const res = await fetch(url, {
|
|
1206
1237
|
headers: { "X-Fan-Token": fanToken }
|
|
@@ -1234,10 +1265,13 @@ function cancelRefresh(timerRef) {
|
|
|
1234
1265
|
timerRef.current = null;
|
|
1235
1266
|
}
|
|
1236
1267
|
}
|
|
1237
|
-
function usePlaybackSession(creatorId, playbackId, duration, fanToken) {
|
|
1268
|
+
function usePlaybackSession(creatorId, playbackId, duration, fanToken, env = "production", getSession) {
|
|
1238
1269
|
const [tokens, setTokens] = (0, import_react.useState)(null);
|
|
1239
1270
|
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
1240
1271
|
const [error, setError] = (0, import_react.useState)(null);
|
|
1272
|
+
const [accessDenied, setAccessDenied] = (0, import_react.useState)(null);
|
|
1273
|
+
const getSessionRef = (0, import_react.useRef)(getSession);
|
|
1274
|
+
getSessionRef.current = getSession;
|
|
1241
1275
|
const sessionTokenRef = (0, import_react.useRef)(null);
|
|
1242
1276
|
const sessionExpiresAtRef = (0, import_react.useRef)(null);
|
|
1243
1277
|
const tokensRef = (0, import_react.useRef)(null);
|
|
@@ -1249,30 +1283,48 @@ function usePlaybackSession(creatorId, playbackId, duration, fanToken) {
|
|
|
1249
1283
|
setTokens(null);
|
|
1250
1284
|
setIsLoading(true);
|
|
1251
1285
|
setError(null);
|
|
1286
|
+
setAccessDenied(null);
|
|
1287
|
+
function mintSession() {
|
|
1288
|
+
const hostSession = getSessionRef.current;
|
|
1289
|
+
return hostSession ? hostSession() : fetchSessionToken(creatorId, fanToken, env);
|
|
1290
|
+
}
|
|
1291
|
+
function deny(err) {
|
|
1292
|
+
if (cancelled) return;
|
|
1293
|
+
cancelRefresh(timerRef);
|
|
1294
|
+
tokensRef.current = null;
|
|
1295
|
+
setTokens(null);
|
|
1296
|
+
setError(null);
|
|
1297
|
+
setAccessDenied(err.state);
|
|
1298
|
+
}
|
|
1252
1299
|
async function refresh() {
|
|
1253
1300
|
if (!sessionTokenRef.current || !sessionExpiresAtRef.current) return;
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1301
|
+
try {
|
|
1302
|
+
const now = Date.now();
|
|
1303
|
+
const sessionExpiry = sessionExpiresAtRef.current.getTime();
|
|
1304
|
+
let sessionToken = sessionTokenRef.current;
|
|
1305
|
+
if (sessionExpiry - now < 6e4) {
|
|
1306
|
+
const newSession = await mintSession();
|
|
1307
|
+
sessionToken = newSession.token;
|
|
1308
|
+
sessionTokenRef.current = newSession.token;
|
|
1309
|
+
sessionExpiresAtRef.current = new Date(newSession.expiresAt);
|
|
1310
|
+
}
|
|
1311
|
+
const nextTokens = await fetchPlaybackTokens(creatorId, playbackId, duration, sessionToken, env);
|
|
1312
|
+
if (cancelled) return;
|
|
1313
|
+
tokensRef.current = nextTokens;
|
|
1314
|
+
setTokens(nextTokens);
|
|
1315
|
+
scheduleRefresh(nextTokens.expiresIn, refresh, timerRef);
|
|
1316
|
+
} catch (err) {
|
|
1317
|
+
if (!(err instanceof AccessDeniedError)) throw err;
|
|
1318
|
+
deny(err);
|
|
1262
1319
|
}
|
|
1263
|
-
const nextTokens = await fetchPlaybackTokens(creatorId, playbackId, duration, sessionToken);
|
|
1264
|
-
if (cancelled) return;
|
|
1265
|
-
tokensRef.current = nextTokens;
|
|
1266
|
-
setTokens(nextTokens);
|
|
1267
|
-
scheduleRefresh(nextTokens.expiresIn, refresh, timerRef);
|
|
1268
1320
|
}
|
|
1269
1321
|
async function initialize() {
|
|
1270
1322
|
try {
|
|
1271
|
-
const session = await
|
|
1323
|
+
const session = await mintSession();
|
|
1272
1324
|
if (cancelled) return;
|
|
1273
1325
|
sessionTokenRef.current = session.token;
|
|
1274
1326
|
sessionExpiresAtRef.current = new Date(session.expiresAt);
|
|
1275
|
-
const initialTokens = await fetchPlaybackTokens(creatorId, playbackId, duration, session.token);
|
|
1327
|
+
const initialTokens = await fetchPlaybackTokens(creatorId, playbackId, duration, session.token, env);
|
|
1276
1328
|
if (cancelled) return;
|
|
1277
1329
|
tokensRef.current = initialTokens;
|
|
1278
1330
|
setTokens(initialTokens);
|
|
@@ -1295,7 +1347,9 @@ function usePlaybackSession(creatorId, playbackId, duration, fanToken) {
|
|
|
1295
1347
|
};
|
|
1296
1348
|
document.addEventListener("visibilitychange", visibilityHandlerRef.current);
|
|
1297
1349
|
} catch (err) {
|
|
1298
|
-
if (
|
|
1350
|
+
if (err instanceof AccessDeniedError) {
|
|
1351
|
+
deny(err);
|
|
1352
|
+
} else if (!cancelled) {
|
|
1299
1353
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
1300
1354
|
setTokens(null);
|
|
1301
1355
|
}
|
|
@@ -1314,8 +1368,8 @@ function usePlaybackSession(creatorId, playbackId, duration, fanToken) {
|
|
|
1314
1368
|
sessionTokenRef.current = null;
|
|
1315
1369
|
sessionExpiresAtRef.current = null;
|
|
1316
1370
|
};
|
|
1317
|
-
}, [creatorId, playbackId, duration, fanToken]);
|
|
1318
|
-
return { tokens, isLoading, error };
|
|
1371
|
+
}, [creatorId, playbackId, duration, fanToken, env]);
|
|
1372
|
+
return { tokens, isLoading, error, accessDenied };
|
|
1319
1373
|
}
|
|
1320
1374
|
|
|
1321
1375
|
// src/hooks/use-player-events.ts
|
|
@@ -1408,7 +1462,7 @@ function useVolume() {
|
|
|
1408
1462
|
// src/hooks/use-watch-progress.ts
|
|
1409
1463
|
var import_react4 = require("react");
|
|
1410
1464
|
var SAVE_DEBOUNCE_MS = 1e4;
|
|
1411
|
-
function useWatchProgress(creatorId, assetId, fanToken, autoResume, onResume) {
|
|
1465
|
+
function useWatchProgress(creatorId, assetId, fanToken, autoResume, onResume, env = "production") {
|
|
1412
1466
|
const [resumePosition, setResumePosition] = (0, import_react4.useState)(null);
|
|
1413
1467
|
const [authExpired, setAuthExpired] = (0, import_react4.useState)(false);
|
|
1414
1468
|
const debounceTimer = (0, import_react4.useRef)(null);
|
|
@@ -1421,7 +1475,7 @@ function useWatchProgress(creatorId, assetId, fanToken, autoResume, onResume) {
|
|
|
1421
1475
|
setResumePosition(null);
|
|
1422
1476
|
if (!fanToken || !autoResume) return;
|
|
1423
1477
|
let cancelled = false;
|
|
1424
|
-
void getWatchProgress(creatorId, assetId, fanToken).then((record) => {
|
|
1478
|
+
void getWatchProgress(creatorId, assetId, fanToken, env).then((record) => {
|
|
1425
1479
|
var _a2;
|
|
1426
1480
|
if (cancelled || !record || record.completed) return;
|
|
1427
1481
|
if (record.position > 5) {
|
|
@@ -1436,14 +1490,14 @@ function useWatchProgress(creatorId, assetId, fanToken, autoResume, onResume) {
|
|
|
1436
1490
|
debounceTimer.current = null;
|
|
1437
1491
|
}
|
|
1438
1492
|
};
|
|
1439
|
-
}, [creatorId, assetId, fanToken, autoResume]);
|
|
1493
|
+
}, [creatorId, assetId, fanToken, autoResume, env]);
|
|
1440
1494
|
const saveProgress = (0, import_react4.useCallback)(
|
|
1441
1495
|
(position, duration) => {
|
|
1442
1496
|
if (!fanToken || stoppedRef.current) return;
|
|
1443
1497
|
if (debounceTimer.current !== null) clearTimeout(debounceTimer.current);
|
|
1444
1498
|
debounceTimer.current = setTimeout(() => {
|
|
1445
1499
|
const completed = duration > 0 && position / duration >= 0.95;
|
|
1446
|
-
void saveWatchProgress(creatorId, assetId, position, duration, fanToken, completed).then((result) => {
|
|
1500
|
+
void saveWatchProgress(creatorId, assetId, position, duration, fanToken, completed, env).then((result) => {
|
|
1447
1501
|
if (!result.ok && result.status === 401) {
|
|
1448
1502
|
stoppedRef.current = true;
|
|
1449
1503
|
setAuthExpired(true);
|
|
@@ -1451,11 +1505,49 @@ function useWatchProgress(creatorId, assetId, fanToken, autoResume, onResume) {
|
|
|
1451
1505
|
});
|
|
1452
1506
|
}, SAVE_DEBOUNCE_MS);
|
|
1453
1507
|
},
|
|
1454
|
-
[creatorId, assetId, fanToken]
|
|
1508
|
+
[creatorId, assetId, fanToken, env]
|
|
1455
1509
|
);
|
|
1456
1510
|
return { resumePosition, saveProgress, authExpired };
|
|
1457
1511
|
}
|
|
1458
1512
|
|
|
1513
|
+
// src/components/access-lock.tsx
|
|
1514
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1515
|
+
var LABELS = {
|
|
1516
|
+
access_denied: "Locked",
|
|
1517
|
+
not_available: "Not available"
|
|
1518
|
+
};
|
|
1519
|
+
var AccessLock = ({ state, poster, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1520
|
+
"div",
|
|
1521
|
+
{
|
|
1522
|
+
className,
|
|
1523
|
+
role: "img",
|
|
1524
|
+
"aria-label": LABELS[state],
|
|
1525
|
+
"data-mc-player-state": state,
|
|
1526
|
+
style: {
|
|
1527
|
+
position: "relative",
|
|
1528
|
+
display: "flex",
|
|
1529
|
+
alignItems: "center",
|
|
1530
|
+
justifyContent: "center",
|
|
1531
|
+
width: "100%",
|
|
1532
|
+
aspectRatio: "16 / 9",
|
|
1533
|
+
overflow: "hidden",
|
|
1534
|
+
background: "#111"
|
|
1535
|
+
},
|
|
1536
|
+
children: [
|
|
1537
|
+
poster ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1538
|
+
"img",
|
|
1539
|
+
{
|
|
1540
|
+
src: poster,
|
|
1541
|
+
alt: "",
|
|
1542
|
+
"aria-hidden": "true",
|
|
1543
|
+
style: { position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover", opacity: 0.3 }
|
|
1544
|
+
}
|
|
1545
|
+
) : null,
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", width: "48", height: "48", fill: "#fff", "aria-hidden": "true", style: { position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" }) })
|
|
1547
|
+
]
|
|
1548
|
+
}
|
|
1549
|
+
);
|
|
1550
|
+
|
|
1459
1551
|
// src/components/player-branding.tsx
|
|
1460
1552
|
function applyBranding(player, videoId, creatorId, config) {
|
|
1461
1553
|
var _a2, _b2, _c, _d;
|
|
@@ -1636,7 +1728,7 @@ function deriveTheme(primaryColor) {
|
|
|
1636
1728
|
}
|
|
1637
1729
|
|
|
1638
1730
|
// src/components/player.tsx
|
|
1639
|
-
var
|
|
1731
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1640
1732
|
function decodeJwtSub(token) {
|
|
1641
1733
|
try {
|
|
1642
1734
|
const payloadPart = token.split(".")[1];
|
|
@@ -1652,6 +1744,7 @@ function decodeJwtSub(token) {
|
|
|
1652
1744
|
var MediaCreatorsPlayer = (0, import_react5.memo)(function MediaCreatorsPlayer2({
|
|
1653
1745
|
creatorId,
|
|
1654
1746
|
asset,
|
|
1747
|
+
env = "production",
|
|
1655
1748
|
auth,
|
|
1656
1749
|
theme,
|
|
1657
1750
|
branding,
|
|
@@ -1660,6 +1753,8 @@ var MediaCreatorsPlayer = (0, import_react5.memo)(function MediaCreatorsPlayer2(
|
|
|
1660
1753
|
metadata,
|
|
1661
1754
|
autoResume,
|
|
1662
1755
|
className,
|
|
1756
|
+
getSession,
|
|
1757
|
+
onAccessDenied,
|
|
1663
1758
|
onTimeUpdate,
|
|
1664
1759
|
onQuartile,
|
|
1665
1760
|
onPause,
|
|
@@ -1672,7 +1767,14 @@ var MediaCreatorsPlayer = (0, import_react5.memo)(function MediaCreatorsPlayer2(
|
|
|
1672
1767
|
}) {
|
|
1673
1768
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1674
1769
|
const durationHint = (_a2 = asset.duration) != null ? _a2 : 3600;
|
|
1675
|
-
const { tokens, isLoading, error } = usePlaybackSession(
|
|
1770
|
+
const { tokens, isLoading, error, accessDenied } = usePlaybackSession(
|
|
1771
|
+
creatorId,
|
|
1772
|
+
asset.playbackId,
|
|
1773
|
+
durationHint,
|
|
1774
|
+
auth == null ? void 0 : auth.fanToken,
|
|
1775
|
+
env,
|
|
1776
|
+
getSession
|
|
1777
|
+
);
|
|
1676
1778
|
const accentSource = (_c = (_b2 = config == null ? void 0 : config.accentColor) != null ? _b2 : theme == null ? void 0 : theme.primaryColor) != null ? _c : "#4ae9ab";
|
|
1677
1779
|
const colors = (0, import_react5.useMemo)(() => deriveTheme(accentSource), [accentSource]);
|
|
1678
1780
|
const { initialVolume, handleVolumeChange } = useVolume();
|
|
@@ -1708,7 +1810,8 @@ var MediaCreatorsPlayer = (0, import_react5.memo)(function MediaCreatorsPlayer2(
|
|
|
1708
1810
|
asset.assetId,
|
|
1709
1811
|
auth == null ? void 0 : auth.fanToken,
|
|
1710
1812
|
autoResume,
|
|
1711
|
-
onResume
|
|
1813
|
+
onResume,
|
|
1814
|
+
env
|
|
1712
1815
|
);
|
|
1713
1816
|
(0, import_react5.useEffect)(() => {
|
|
1714
1817
|
import("media-chrome/dist/utils/i18n.js").then(({ setLanguage }) => {
|
|
@@ -1721,6 +1824,12 @@ var MediaCreatorsPlayer = (0, import_react5.memo)(function MediaCreatorsPlayer2(
|
|
|
1721
1824
|
onError == null ? void 0 : onError({ code: "SESSION_ERROR", message: error.message });
|
|
1722
1825
|
}
|
|
1723
1826
|
}, [error, onError]);
|
|
1827
|
+
const onAccessDeniedRef = (0, import_react5.useRef)(onAccessDenied);
|
|
1828
|
+
onAccessDeniedRef.current = onAccessDenied;
|
|
1829
|
+
(0, import_react5.useEffect)(() => {
|
|
1830
|
+
var _a3;
|
|
1831
|
+
if (accessDenied) (_a3 = onAccessDeniedRef.current) == null ? void 0 : _a3.call(onAccessDeniedRef, accessDenied);
|
|
1832
|
+
}, [accessDenied]);
|
|
1724
1833
|
(0, import_react5.useEffect)(() => {
|
|
1725
1834
|
seekDoneRef.current = false;
|
|
1726
1835
|
}, [asset.assetId]);
|
|
@@ -1757,10 +1866,13 @@ var MediaCreatorsPlayer = (0, import_react5.memo)(function MediaCreatorsPlayer2(
|
|
|
1757
1866
|
[initialVolume]
|
|
1758
1867
|
);
|
|
1759
1868
|
const viewerUserId = (_g = (_f = (_e = metadata == null ? void 0 : metadata.viewerUserId) != null ? _e : (auth == null ? void 0 : auth.fanToken) ? decodeJwtSub(auth.fanToken) : null) != null ? _f : getSessionId()) != null ? _g : void 0;
|
|
1869
|
+
if (accessDenied) {
|
|
1870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AccessLock, { state: accessDenied, poster, className });
|
|
1871
|
+
}
|
|
1760
1872
|
if (isLoading || !tokens) {
|
|
1761
|
-
return /* @__PURE__ */ (0,
|
|
1873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, style: { width: "100%", aspectRatio: "16 / 9", background: "#111" } });
|
|
1762
1874
|
}
|
|
1763
|
-
return /* @__PURE__ */ (0,
|
|
1875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1764
1876
|
import_mux_player_react.default,
|
|
1765
1877
|
{
|
|
1766
1878
|
ref: handlePlayerRef,
|