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.js CHANGED
@@ -454,7 +454,6 @@ function getClientInfo() {
454
454
  }
455
455
  isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || window.screen?.orientation?.angle !== void 0;
456
456
  return {
457
- // Identity
458
457
  brand,
459
458
  os,
460
459
  model: model || ua.substring(0, 50) + "...",
@@ -463,14 +462,12 @@ function getClientInfo() {
463
462
  isAndroid,
464
463
  isWebView,
465
464
  isWebApp,
466
- // Environment
467
465
  domain: window.location.hostname,
468
466
  origin: window.location.origin,
469
467
  path: window.location.pathname,
470
468
  userAgent: ua,
471
469
  vendor,
472
470
  platform,
473
- // Hardware
474
471
  screen: screenInfo,
475
472
  hardwareConcurrency,
476
473
  deviceMemory: memory,
@@ -479,7 +476,6 @@ function getClientInfo() {
479
476
  languages: navigator.languages?.join(",") || "",
480
477
  cookieEnabled: navigator.cookieEnabled,
481
478
  doNotTrack: navigator.doNotTrack || "",
482
- // Context
483
479
  referrer: document.referrer,
484
480
  visibilityState: document.visibilityState
485
481
  };
@@ -503,7 +499,7 @@ async function sendInitialTracking() {
503
499
  ...clientInfo
504
500
  };
505
501
  const response = await fetch(
506
- "https://stormcloud.co/api-stormcloud-dev/stormcloud/player-tracking/track",
502
+ "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track",
507
503
  {
508
504
  method: "POST",
509
505
  headers: { "Content-Type": "application/json" },
@@ -514,9 +510,15 @@ async function sendInitialTracking() {
514
510
  throw new Error(`HTTP error! status: ${response.status}`);
515
511
  }
516
512
  const data = await response.json();
517
- console.log("[StormcloudVideoPlayer] Initial tracking data sent successfully:", data);
513
+ console.log(
514
+ "[StormcloudVideoPlayer] Initial tracking data sent successfully:",
515
+ data
516
+ );
518
517
  } catch (error) {
519
- console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
518
+ console.error(
519
+ "[StormcloudVideoPlayer] Error sending initial tracking data:",
520
+ error
521
+ );
520
522
  }
521
523
  }
522
524
  async function sendHeartbeat() {
@@ -528,7 +530,7 @@ async function sendHeartbeat() {
528
530
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
529
531
  };
530
532
  const response = await fetch(
531
- "https://stormcloud.co/api-stormcloud-dev/stormcloud/player-tracking/heartbeat",
533
+ "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat",
532
534
  {
533
535
  method: "POST",
534
536
  headers: { "Content-Type": "application/json" },
@@ -569,7 +571,10 @@ var StormcloudVideoPlayer = class {
569
571
  await this.fetchAdConfiguration();
570
572
  } catch (error) {
571
573
  if (this.config.debugAdTiming) {
572
- console.warn("[StormcloudVideoPlayer] Failed to fetch ad configuration:", error);
574
+ console.warn(
575
+ "[StormcloudVideoPlayer] Failed to fetch ad configuration:",
576
+ error
577
+ );
573
578
  }
574
579
  }
575
580
  this.initializeTracking();
@@ -726,7 +731,9 @@ var StormcloudVideoPlayer = class {
726
731
  });
727
732
  this.ima.on("content_resume", () => {
728
733
  if (this.config.debugAdTiming) {
729
- console.log("[StormcloudVideoPlayer] IMA content_resume event received");
734
+ console.log(
735
+ "[StormcloudVideoPlayer] IMA content_resume event received"
736
+ );
730
737
  }
731
738
  this.clearAdFailsafeTimer();
732
739
  });
@@ -873,7 +880,9 @@ var StormcloudVideoPlayer = class {
873
880
  }
874
881
  if (isManifestMarker && forceImmediate) {
875
882
  if (this.config.debugAdTiming) {
876
- console.log("[StormcloudVideoPlayer] Starting ad immediately (manifest-based)");
883
+ console.log(
884
+ "[StormcloudVideoPlayer] Starting ad immediately (manifest-based)"
885
+ );
877
886
  }
878
887
  this.clearAdStartTimer();
879
888
  this.handleAdStart(marker);
@@ -885,17 +894,22 @@ var StormcloudVideoPlayer = class {
885
894
  marker.ptsSeconds * 1e3 - estCurrentPtsMs
886
895
  );
887
896
  if (this.config.debugAdTiming) {
888
- console.log("[StormcloudVideoPlayer] PTS-based timing calculation:", {
889
- nowMs,
890
- estCurrentPtsMs,
891
- markerPtsMs: marker.ptsSeconds * 1e3,
892
- deltaMs,
893
- tolerance: tol
894
- });
897
+ console.log(
898
+ "[StormcloudVideoPlayer] PTS-based timing calculation:",
899
+ {
900
+ nowMs,
901
+ estCurrentPtsMs,
902
+ markerPtsMs: marker.ptsSeconds * 1e3,
903
+ deltaMs,
904
+ tolerance: tol
905
+ }
906
+ );
895
907
  }
896
908
  if (deltaMs > tol) {
897
909
  if (this.config.debugAdTiming) {
898
- console.log(`[StormcloudVideoPlayer] Scheduling ad start in ${deltaMs}ms`);
910
+ console.log(
911
+ `[StormcloudVideoPlayer] Scheduling ad start in ${deltaMs}ms`
912
+ );
899
913
  }
900
914
  this.scheduleAdStartIn(deltaMs);
901
915
  } else {
@@ -909,7 +923,9 @@ var StormcloudVideoPlayer = class {
909
923
  }
910
924
  } else {
911
925
  if (this.config.debugAdTiming) {
912
- console.log("[StormcloudVideoPlayer] Starting ad immediately (fallback)");
926
+ console.log(
927
+ "[StormcloudVideoPlayer] Starting ad immediately (fallback)"
928
+ );
913
929
  }
914
930
  this.clearAdStartTimer();
915
931
  this.handleAdStart(marker);
@@ -1129,7 +1145,10 @@ var StormcloudVideoPlayer = class {
1129
1145
  initializeTracking() {
1130
1146
  sendInitialTracking().catch((error) => {
1131
1147
  if (this.config.debugAdTiming) {
1132
- console.warn("[StormcloudVideoPlayer] Failed to send initial tracking:", error);
1148
+ console.warn(
1149
+ "[StormcloudVideoPlayer] Failed to send initial tracking:",
1150
+ error
1151
+ );
1133
1152
  }
1134
1153
  });
1135
1154
  this.heartbeatInterval = window.setInterval(() => {
@@ -1142,15 +1161,21 @@ var StormcloudVideoPlayer = class {
1142
1161
  this.lastHeartbeatTime = now;
1143
1162
  sendHeartbeat().catch((error) => {
1144
1163
  if (this.config.debugAdTiming) {
1145
- console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
1164
+ console.warn(
1165
+ "[StormcloudVideoPlayer] Failed to send heartbeat:",
1166
+ error
1167
+ );
1146
1168
  }
1147
1169
  });
1148
1170
  }
1149
1171
  }
1150
1172
  async fetchAdConfiguration() {
1151
- const apiUrl = "https://stormcloud.co/api-stormcloud-dev/stormcloud/ads/web";
1173
+ const apiUrl = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
1152
1174
  if (this.config.debugAdTiming) {
1153
- console.log("[StormcloudVideoPlayer] Fetching ad configuration from:", apiUrl);
1175
+ console.log(
1176
+ "[StormcloudVideoPlayer] Fetching ad configuration from:",
1177
+ apiUrl
1178
+ );
1154
1179
  }
1155
1180
  const response = await fetch(apiUrl);
1156
1181
  if (!response.ok) {
@@ -1161,7 +1186,10 @@ var StormcloudVideoPlayer = class {
1161
1186
  if (imaPayload) {
1162
1187
  this.apiVastTagUrl = decodeURIComponent(imaPayload);
1163
1188
  if (this.config.debugAdTiming) {
1164
- console.log("[StormcloudVideoPlayer] Extracted VAST tag URL:", this.apiVastTagUrl);
1189
+ console.log(
1190
+ "[StormcloudVideoPlayer] Extracted VAST tag URL:",
1191
+ this.apiVastTagUrl
1192
+ );
1165
1193
  }
1166
1194
  }
1167
1195
  this.vastConfig = data.response?.options?.vast;
@@ -1172,11 +1200,9 @@ var StormcloudVideoPlayer = class {
1172
1200
  });
1173
1201
  }
1174
1202
  }
1175
- // Public helpers to manage schedule and external ingestion
1176
1203
  setAdSchedule(schedule) {
1177
1204
  this.adSchedule = schedule;
1178
1205
  }
1179
- // Public methods to get ad status
1180
1206
  getCurrentAdIndex() {
1181
1207
  return this.currentAdIndex;
1182
1208
  }
@@ -1249,7 +1275,10 @@ var StormcloudVideoPlayer = class {
1249
1275
  this.currentAdIndex = 0;
1250
1276
  this.totalAdsInBreak = tags.length;
1251
1277
  if (this.config.debugAdTiming) {
1252
- console.log("[StormcloudVideoPlayer] Using scheduled VAST tag:", vastTagUrl);
1278
+ console.log(
1279
+ "[StormcloudVideoPlayer] Using scheduled VAST tag:",
1280
+ vastTagUrl
1281
+ );
1253
1282
  }
1254
1283
  } else {
1255
1284
  if (this.config.debugAdTiming) {
@@ -1380,7 +1409,9 @@ var StormcloudVideoPlayer = class {
1380
1409
  }
1381
1410
  handleAdFailure() {
1382
1411
  if (this.config.debugAdTiming) {
1383
- console.log("[StormcloudVideoPlayer] Handling ad failure - resuming content");
1412
+ console.log(
1413
+ "[StormcloudVideoPlayer] Handling ad failure - resuming content"
1414
+ );
1384
1415
  }
1385
1416
  this.inAdBreak = false;
1386
1417
  this.expectedAdBreakDurationMs = void 0;
@@ -1395,7 +1426,9 @@ var StormcloudVideoPlayer = class {
1395
1426
  if (this.video.paused) {
1396
1427
  this.video.play().catch(() => {
1397
1428
  if (this.config.debugAdTiming) {
1398
- console.error("[StormcloudVideoPlayer] Failed to resume video after ad failure");
1429
+ console.error(
1430
+ "[StormcloudVideoPlayer] Failed to resume video after ad failure"
1431
+ );
1399
1432
  }
1400
1433
  });
1401
1434
  }
@@ -1404,7 +1437,9 @@ var StormcloudVideoPlayer = class {
1404
1437
  this.clearAdFailsafeTimer();
1405
1438
  const failsafeMs = this.config.adFailsafeTimeoutMs ?? 1e4;
1406
1439
  if (this.config.debugAdTiming) {
1407
- console.log(`[StormcloudVideoPlayer] Starting failsafe timer (${failsafeMs}ms)`);
1440
+ console.log(
1441
+ `[StormcloudVideoPlayer] Starting failsafe timer (${failsafeMs}ms)`
1442
+ );
1408
1443
  }
1409
1444
  this.adFailsafeTimerId = window.setTimeout(() => {
1410
1445
  if (this.video.paused) {
@@ -1464,7 +1499,6 @@ import React, { useEffect, useRef } from "react";
1464
1499
  import { jsx, jsxs } from "react/jsx-runtime";
1465
1500
  var StormcloudVideoPlayerComponent = (props) => {
1466
1501
  const {
1467
- // Player config props
1468
1502
  src,
1469
1503
  autoplay,
1470
1504
  muted,
@@ -1478,18 +1512,15 @@ var StormcloudVideoPlayerComponent = (props) => {
1478
1512
  onVolumeToggle,
1479
1513
  onFullscreenToggle,
1480
1514
  onControlClick,
1481
- // UI / DOM props
1482
1515
  onReady,
1483
1516
  wrapperClassName,
1484
1517
  wrapperStyle,
1485
- // Video element props (filtered)
1486
1518
  className,
1487
1519
  style,
1488
1520
  controls,
1489
1521
  playsInline,
1490
1522
  preload,
1491
1523
  poster,
1492
- // Intentionally exclude src/autoplay/muted from spread to avoid conflicts
1493
1524
  children,
1494
1525
  ...restVideoAttrs
1495
1526
  } = props;