stormcloud-video-player 0.2.6 → 0.2.8

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.
@@ -272,7 +272,7 @@ function createImaController(video, options) {
272
272
  );
273
273
  emit("ad_error");
274
274
  if (!options?.continueLiveStreamDuringAds) {
275
- video.play().catch(() => {
275
+ video.play()?.catch(() => {
276
276
  });
277
277
  }
278
278
  }
@@ -307,7 +307,7 @@ function createImaController(video, options) {
307
307
  if (adContainerEl)
308
308
  adContainerEl.style.pointerEvents = "none";
309
309
  if (!options?.continueLiveStreamDuringAds) {
310
- video.play().catch(() => {
310
+ video.play()?.catch(() => {
311
311
  });
312
312
  console.log("[IMA] Video resumed (VOD mode)");
313
313
  } else {
@@ -420,7 +420,7 @@ function createImaController(video, options) {
420
420
  console.error("[IMA] Error starting ad playback:", error);
421
421
  adPlaying = false;
422
422
  if (!options?.continueLiveStreamDuringAds) {
423
- video.play().catch(() => {
423
+ video.play()?.catch(() => {
424
424
  });
425
425
  }
426
426
  return Promise.reject(error);
@@ -653,13 +653,32 @@ function getClientInfo() {
653
653
  }
654
654
  async function getBrowserID(clientInfo) {
655
655
  const fingerprintString = JSON.stringify(clientInfo);
656
- const hashBuffer = await crypto.subtle.digest(
657
- "SHA-256",
658
- new TextEncoder().encode(fingerprintString)
659
- );
660
- const hashArray = Array.from(new Uint8Array(hashBuffer));
661
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
662
- return hashHex;
656
+ if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
657
+ try {
658
+ await crypto.subtle.digest("SHA-256", new Uint8Array([1, 2, 3]));
659
+ const hashBuffer = await crypto.subtle.digest(
660
+ "SHA-256",
661
+ new TextEncoder().encode(fingerprintString)
662
+ );
663
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
664
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
665
+ return hashHex;
666
+ } catch (error) {
667
+ console.warn(
668
+ "[StormcloudVideoPlayer] crypto.subtle.digest not supported, using fallback hash"
669
+ );
670
+ }
671
+ }
672
+ let hash = 0;
673
+ for (let i = 0; i < fingerprintString.length; i++) {
674
+ const char = fingerprintString.charCodeAt(i);
675
+ hash = (hash << 5) - hash + char;
676
+ hash = hash & hash;
677
+ }
678
+ const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
679
+ const timestamp = Date.now().toString(16).padStart(12, "0");
680
+ const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
681
+ return (fallbackHash + timestamp + random).padEnd(64, "0");
663
682
  }
664
683
  async function sendInitialTracking(licenseKey) {
665
684
  try {
@@ -777,7 +796,7 @@ var StormcloudVideoPlayer = class {
777
796
  });
778
797
  this.ima.initialize();
779
798
  if (this.config.autoplay) {
780
- await this.video.play().catch(() => {
799
+ await this.video.play()?.catch(() => {
781
800
  });
782
801
  }
783
802
  return;
@@ -811,7 +830,7 @@ var StormcloudVideoPlayer = class {
811
830
  });
812
831
  this.ima.initialize();
813
832
  if (this.config.autoplay) {
814
- await this.video.play().catch(() => {
833
+ await this.video.play()?.catch(() => {
815
834
  });
816
835
  }
817
836
  });
@@ -1624,7 +1643,7 @@ var StormcloudVideoPlayer = class {
1624
1643
  this.currentAdIndex = 0;
1625
1644
  this.totalAdsInBreak = 0;
1626
1645
  if (this.video.paused) {
1627
- this.video.play().catch(() => {
1646
+ this.video.play()?.catch(() => {
1628
1647
  if (this.config.debugAdTiming) {
1629
1648
  console.error(
1630
1649
  "[StormcloudVideoPlayer] Failed to resume video after ad failure"