stormcloud-video-player 0.1.0 → 0.1.2
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/lib/index.cjs +66 -35
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -5
- package/lib/index.d.ts +0 -5
- package/lib/index.js +66 -35
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/player/StormcloudVideoPlayer.ts +1 -2
package/lib/index.cjs
CHANGED
|
@@ -495,7 +495,6 @@ function getClientInfo() {
|
|
|
495
495
|
}
|
|
496
496
|
isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || window.screen?.orientation?.angle !== void 0;
|
|
497
497
|
return {
|
|
498
|
-
// Identity
|
|
499
498
|
brand,
|
|
500
499
|
os,
|
|
501
500
|
model: model || ua.substring(0, 50) + "...",
|
|
@@ -504,14 +503,12 @@ function getClientInfo() {
|
|
|
504
503
|
isAndroid,
|
|
505
504
|
isWebView,
|
|
506
505
|
isWebApp,
|
|
507
|
-
// Environment
|
|
508
506
|
domain: window.location.hostname,
|
|
509
507
|
origin: window.location.origin,
|
|
510
508
|
path: window.location.pathname,
|
|
511
509
|
userAgent: ua,
|
|
512
510
|
vendor,
|
|
513
511
|
platform,
|
|
514
|
-
// Hardware
|
|
515
512
|
screen: screenInfo,
|
|
516
513
|
hardwareConcurrency,
|
|
517
514
|
deviceMemory: memory,
|
|
@@ -520,7 +517,6 @@ function getClientInfo() {
|
|
|
520
517
|
languages: navigator.languages?.join(",") || "",
|
|
521
518
|
cookieEnabled: navigator.cookieEnabled,
|
|
522
519
|
doNotTrack: navigator.doNotTrack || "",
|
|
523
|
-
// Context
|
|
524
520
|
referrer: document.referrer,
|
|
525
521
|
visibilityState: document.visibilityState
|
|
526
522
|
};
|
|
@@ -544,7 +540,7 @@ async function sendInitialTracking() {
|
|
|
544
540
|
...clientInfo
|
|
545
541
|
};
|
|
546
542
|
const response = await fetch(
|
|
547
|
-
"https://
|
|
543
|
+
"https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track",
|
|
548
544
|
{
|
|
549
545
|
method: "POST",
|
|
550
546
|
headers: { "Content-Type": "application/json" },
|
|
@@ -555,9 +551,15 @@ async function sendInitialTracking() {
|
|
|
555
551
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
556
552
|
}
|
|
557
553
|
const data = await response.json();
|
|
558
|
-
console.log(
|
|
554
|
+
console.log(
|
|
555
|
+
"[StormcloudVideoPlayer] Initial tracking data sent successfully:",
|
|
556
|
+
data
|
|
557
|
+
);
|
|
559
558
|
} catch (error) {
|
|
560
|
-
console.error(
|
|
559
|
+
console.error(
|
|
560
|
+
"[StormcloudVideoPlayer] Error sending initial tracking data:",
|
|
561
|
+
error
|
|
562
|
+
);
|
|
561
563
|
}
|
|
562
564
|
}
|
|
563
565
|
async function sendHeartbeat() {
|
|
@@ -569,7 +571,7 @@ async function sendHeartbeat() {
|
|
|
569
571
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
570
572
|
};
|
|
571
573
|
const response = await fetch(
|
|
572
|
-
"https://
|
|
574
|
+
"https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat",
|
|
573
575
|
{
|
|
574
576
|
method: "POST",
|
|
575
577
|
headers: { "Content-Type": "application/json" },
|
|
@@ -610,7 +612,10 @@ var StormcloudVideoPlayer = class {
|
|
|
610
612
|
await this.fetchAdConfiguration();
|
|
611
613
|
} catch (error) {
|
|
612
614
|
if (this.config.debugAdTiming) {
|
|
613
|
-
console.warn(
|
|
615
|
+
console.warn(
|
|
616
|
+
"[StormcloudVideoPlayer] Failed to fetch ad configuration:",
|
|
617
|
+
error
|
|
618
|
+
);
|
|
614
619
|
}
|
|
615
620
|
}
|
|
616
621
|
this.initializeTracking();
|
|
@@ -767,7 +772,9 @@ var StormcloudVideoPlayer = class {
|
|
|
767
772
|
});
|
|
768
773
|
this.ima.on("content_resume", () => {
|
|
769
774
|
if (this.config.debugAdTiming) {
|
|
770
|
-
console.log(
|
|
775
|
+
console.log(
|
|
776
|
+
"[StormcloudVideoPlayer] IMA content_resume event received"
|
|
777
|
+
);
|
|
771
778
|
}
|
|
772
779
|
this.clearAdFailsafeTimer();
|
|
773
780
|
});
|
|
@@ -914,7 +921,9 @@ var StormcloudVideoPlayer = class {
|
|
|
914
921
|
}
|
|
915
922
|
if (isManifestMarker && forceImmediate) {
|
|
916
923
|
if (this.config.debugAdTiming) {
|
|
917
|
-
console.log(
|
|
924
|
+
console.log(
|
|
925
|
+
"[StormcloudVideoPlayer] Starting ad immediately (manifest-based)"
|
|
926
|
+
);
|
|
918
927
|
}
|
|
919
928
|
this.clearAdStartTimer();
|
|
920
929
|
this.handleAdStart(marker);
|
|
@@ -926,17 +935,22 @@ var StormcloudVideoPlayer = class {
|
|
|
926
935
|
marker.ptsSeconds * 1e3 - estCurrentPtsMs
|
|
927
936
|
);
|
|
928
937
|
if (this.config.debugAdTiming) {
|
|
929
|
-
console.log(
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
938
|
+
console.log(
|
|
939
|
+
"[StormcloudVideoPlayer] PTS-based timing calculation:",
|
|
940
|
+
{
|
|
941
|
+
nowMs,
|
|
942
|
+
estCurrentPtsMs,
|
|
943
|
+
markerPtsMs: marker.ptsSeconds * 1e3,
|
|
944
|
+
deltaMs,
|
|
945
|
+
tolerance: tol
|
|
946
|
+
}
|
|
947
|
+
);
|
|
936
948
|
}
|
|
937
949
|
if (deltaMs > tol) {
|
|
938
950
|
if (this.config.debugAdTiming) {
|
|
939
|
-
console.log(
|
|
951
|
+
console.log(
|
|
952
|
+
`[StormcloudVideoPlayer] Scheduling ad start in ${deltaMs}ms`
|
|
953
|
+
);
|
|
940
954
|
}
|
|
941
955
|
this.scheduleAdStartIn(deltaMs);
|
|
942
956
|
} else {
|
|
@@ -950,7 +964,9 @@ var StormcloudVideoPlayer = class {
|
|
|
950
964
|
}
|
|
951
965
|
} else {
|
|
952
966
|
if (this.config.debugAdTiming) {
|
|
953
|
-
console.log(
|
|
967
|
+
console.log(
|
|
968
|
+
"[StormcloudVideoPlayer] Starting ad immediately (fallback)"
|
|
969
|
+
);
|
|
954
970
|
}
|
|
955
971
|
this.clearAdStartTimer();
|
|
956
972
|
this.handleAdStart(marker);
|
|
@@ -1170,7 +1186,10 @@ var StormcloudVideoPlayer = class {
|
|
|
1170
1186
|
initializeTracking() {
|
|
1171
1187
|
sendInitialTracking().catch((error) => {
|
|
1172
1188
|
if (this.config.debugAdTiming) {
|
|
1173
|
-
console.warn(
|
|
1189
|
+
console.warn(
|
|
1190
|
+
"[StormcloudVideoPlayer] Failed to send initial tracking:",
|
|
1191
|
+
error
|
|
1192
|
+
);
|
|
1174
1193
|
}
|
|
1175
1194
|
});
|
|
1176
1195
|
this.heartbeatInterval = window.setInterval(() => {
|
|
@@ -1183,15 +1202,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1183
1202
|
this.lastHeartbeatTime = now;
|
|
1184
1203
|
sendHeartbeat().catch((error) => {
|
|
1185
1204
|
if (this.config.debugAdTiming) {
|
|
1186
|
-
console.warn(
|
|
1205
|
+
console.warn(
|
|
1206
|
+
"[StormcloudVideoPlayer] Failed to send heartbeat:",
|
|
1207
|
+
error
|
|
1208
|
+
);
|
|
1187
1209
|
}
|
|
1188
1210
|
});
|
|
1189
1211
|
}
|
|
1190
1212
|
}
|
|
1191
1213
|
async fetchAdConfiguration() {
|
|
1192
|
-
const apiUrl = "https://
|
|
1214
|
+
const apiUrl = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
|
|
1193
1215
|
if (this.config.debugAdTiming) {
|
|
1194
|
-
console.log(
|
|
1216
|
+
console.log(
|
|
1217
|
+
"[StormcloudVideoPlayer] Fetching ad configuration from:",
|
|
1218
|
+
apiUrl
|
|
1219
|
+
);
|
|
1195
1220
|
}
|
|
1196
1221
|
const response = await fetch(apiUrl);
|
|
1197
1222
|
if (!response.ok) {
|
|
@@ -1202,7 +1227,10 @@ var StormcloudVideoPlayer = class {
|
|
|
1202
1227
|
if (imaPayload) {
|
|
1203
1228
|
this.apiVastTagUrl = decodeURIComponent(imaPayload);
|
|
1204
1229
|
if (this.config.debugAdTiming) {
|
|
1205
|
-
console.log(
|
|
1230
|
+
console.log(
|
|
1231
|
+
"[StormcloudVideoPlayer] Extracted VAST tag URL:",
|
|
1232
|
+
this.apiVastTagUrl
|
|
1233
|
+
);
|
|
1206
1234
|
}
|
|
1207
1235
|
}
|
|
1208
1236
|
this.vastConfig = data.response?.options?.vast;
|
|
@@ -1213,11 +1241,9 @@ var StormcloudVideoPlayer = class {
|
|
|
1213
1241
|
});
|
|
1214
1242
|
}
|
|
1215
1243
|
}
|
|
1216
|
-
// Public helpers to manage schedule and external ingestion
|
|
1217
1244
|
setAdSchedule(schedule) {
|
|
1218
1245
|
this.adSchedule = schedule;
|
|
1219
1246
|
}
|
|
1220
|
-
// Public methods to get ad status
|
|
1221
1247
|
getCurrentAdIndex() {
|
|
1222
1248
|
return this.currentAdIndex;
|
|
1223
1249
|
}
|
|
@@ -1290,7 +1316,10 @@ var StormcloudVideoPlayer = class {
|
|
|
1290
1316
|
this.currentAdIndex = 0;
|
|
1291
1317
|
this.totalAdsInBreak = tags.length;
|
|
1292
1318
|
if (this.config.debugAdTiming) {
|
|
1293
|
-
console.log(
|
|
1319
|
+
console.log(
|
|
1320
|
+
"[StormcloudVideoPlayer] Using scheduled VAST tag:",
|
|
1321
|
+
vastTagUrl
|
|
1322
|
+
);
|
|
1294
1323
|
}
|
|
1295
1324
|
} else {
|
|
1296
1325
|
if (this.config.debugAdTiming) {
|
|
@@ -1421,7 +1450,9 @@ var StormcloudVideoPlayer = class {
|
|
|
1421
1450
|
}
|
|
1422
1451
|
handleAdFailure() {
|
|
1423
1452
|
if (this.config.debugAdTiming) {
|
|
1424
|
-
console.log(
|
|
1453
|
+
console.log(
|
|
1454
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1455
|
+
);
|
|
1425
1456
|
}
|
|
1426
1457
|
this.inAdBreak = false;
|
|
1427
1458
|
this.expectedAdBreakDurationMs = void 0;
|
|
@@ -1436,7 +1467,9 @@ var StormcloudVideoPlayer = class {
|
|
|
1436
1467
|
if (this.video.paused) {
|
|
1437
1468
|
this.video.play().catch(() => {
|
|
1438
1469
|
if (this.config.debugAdTiming) {
|
|
1439
|
-
console.error(
|
|
1470
|
+
console.error(
|
|
1471
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1472
|
+
);
|
|
1440
1473
|
}
|
|
1441
1474
|
});
|
|
1442
1475
|
}
|
|
@@ -1445,7 +1478,9 @@ var StormcloudVideoPlayer = class {
|
|
|
1445
1478
|
this.clearAdFailsafeTimer();
|
|
1446
1479
|
const failsafeMs = this.config.adFailsafeTimeoutMs ?? 1e4;
|
|
1447
1480
|
if (this.config.debugAdTiming) {
|
|
1448
|
-
console.log(
|
|
1481
|
+
console.log(
|
|
1482
|
+
`[StormcloudVideoPlayer] Starting failsafe timer (${failsafeMs}ms)`
|
|
1483
|
+
);
|
|
1449
1484
|
}
|
|
1450
1485
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1451
1486
|
if (this.video.paused) {
|
|
@@ -1505,7 +1540,6 @@ var import_react = __toESM(require("react"), 1);
|
|
|
1505
1540
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1506
1541
|
var StormcloudVideoPlayerComponent = (props) => {
|
|
1507
1542
|
const {
|
|
1508
|
-
// Player config props
|
|
1509
1543
|
src,
|
|
1510
1544
|
autoplay,
|
|
1511
1545
|
muted,
|
|
@@ -1519,18 +1553,15 @@ var StormcloudVideoPlayerComponent = (props) => {
|
|
|
1519
1553
|
onVolumeToggle,
|
|
1520
1554
|
onFullscreenToggle,
|
|
1521
1555
|
onControlClick,
|
|
1522
|
-
// UI / DOM props
|
|
1523
1556
|
onReady,
|
|
1524
1557
|
wrapperClassName,
|
|
1525
1558
|
wrapperStyle,
|
|
1526
|
-
// Video element props (filtered)
|
|
1527
1559
|
className,
|
|
1528
1560
|
style,
|
|
1529
1561
|
controls,
|
|
1530
1562
|
playsInline,
|
|
1531
1563
|
preload,
|
|
1532
1564
|
poster,
|
|
1533
|
-
// Intentionally exclude src/autoplay/muted from spread to avoid conflicts
|
|
1534
1565
|
children,
|
|
1535
1566
|
...restVideoAttrs
|
|
1536
1567
|
} = props;
|