stormcloud-video-player 0.2.6 → 0.2.7

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 CHANGED
@@ -258,7 +258,7 @@ function createImaController(video, options) {
258
258
  );
259
259
  emit("ad_error");
260
260
  if (!options?.continueLiveStreamDuringAds) {
261
- video.play().catch(() => {
261
+ video.play()?.catch(() => {
262
262
  });
263
263
  }
264
264
  }
@@ -293,7 +293,7 @@ function createImaController(video, options) {
293
293
  if (adContainerEl)
294
294
  adContainerEl.style.pointerEvents = "none";
295
295
  if (!options?.continueLiveStreamDuringAds) {
296
- video.play().catch(() => {
296
+ video.play()?.catch(() => {
297
297
  });
298
298
  console.log("[IMA] Video resumed (VOD mode)");
299
299
  } else {
@@ -406,7 +406,7 @@ function createImaController(video, options) {
406
406
  console.error("[IMA] Error starting ad playback:", error);
407
407
  adPlaying = false;
408
408
  if (!options?.continueLiveStreamDuringAds) {
409
- video.play().catch(() => {
409
+ video.play()?.catch(() => {
410
410
  });
411
411
  }
412
412
  return Promise.reject(error);
@@ -639,13 +639,32 @@ function getClientInfo() {
639
639
  }
640
640
  async function getBrowserID(clientInfo) {
641
641
  const fingerprintString = JSON.stringify(clientInfo);
642
- const hashBuffer = await crypto.subtle.digest(
643
- "SHA-256",
644
- new TextEncoder().encode(fingerprintString)
645
- );
646
- const hashArray = Array.from(new Uint8Array(hashBuffer));
647
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
648
- return hashHex;
642
+ if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
643
+ try {
644
+ const hashBuffer = await crypto.subtle.digest(
645
+ "SHA-256",
646
+ new TextEncoder().encode(fingerprintString)
647
+ );
648
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
649
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
650
+ return hashHex;
651
+ } catch (error) {
652
+ console.warn(
653
+ "[StormcloudVideoPlayer] crypto.subtle.digest failed, using fallback hash:",
654
+ error
655
+ );
656
+ }
657
+ }
658
+ let hash = 0;
659
+ for (let i = 0; i < fingerprintString.length; i++) {
660
+ const char = fingerprintString.charCodeAt(i);
661
+ hash = (hash << 5) - hash + char;
662
+ hash = hash & hash;
663
+ }
664
+ const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
665
+ const timestamp = Date.now().toString(16).padStart(12, "0");
666
+ const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
667
+ return (fallbackHash + timestamp + random).padEnd(64, "0");
649
668
  }
650
669
  async function sendInitialTracking(licenseKey) {
651
670
  try {
@@ -763,7 +782,7 @@ var StormcloudVideoPlayer = class {
763
782
  });
764
783
  this.ima.initialize();
765
784
  if (this.config.autoplay) {
766
- await this.video.play().catch(() => {
785
+ await this.video.play()?.catch(() => {
767
786
  });
768
787
  }
769
788
  return;
@@ -797,7 +816,7 @@ var StormcloudVideoPlayer = class {
797
816
  });
798
817
  this.ima.initialize();
799
818
  if (this.config.autoplay) {
800
- await this.video.play().catch(() => {
819
+ await this.video.play()?.catch(() => {
801
820
  });
802
821
  }
803
822
  });
@@ -1610,7 +1629,7 @@ var StormcloudVideoPlayer = class {
1610
1629
  this.currentAdIndex = 0;
1611
1630
  this.totalAdsInBreak = 0;
1612
1631
  if (this.video.paused) {
1613
- this.video.play().catch(() => {
1632
+ this.video.play()?.catch(() => {
1614
1633
  if (this.config.debugAdTiming) {
1615
1634
  console.error(
1616
1635
  "[StormcloudVideoPlayer] Failed to resume video after ad failure"