stormcloud-video-player 0.2.5 → 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/README.md +15 -16
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +84 -375
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -30
- package/lib/index.d.ts +0 -30
- package/lib/index.js +84 -375
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +32 -24
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +0 -1
- package/lib/players/HlsPlayer.cjs +32 -24
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +32 -24
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +3 -3
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +32 -24
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/tracking.cjs +26 -7
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +1 -1
- package/lib/types-DOcCdwQI.d.cts +0 -78
|
@@ -233,7 +233,7 @@ function createImaController(video, options) {
|
|
|
233
233
|
);
|
|
234
234
|
emit("ad_error");
|
|
235
235
|
if (!options?.continueLiveStreamDuringAds) {
|
|
236
|
-
video.play()
|
|
236
|
+
video.play()?.catch(() => {
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
@@ -268,7 +268,7 @@ function createImaController(video, options) {
|
|
|
268
268
|
if (adContainerEl)
|
|
269
269
|
adContainerEl.style.pointerEvents = "none";
|
|
270
270
|
if (!options?.continueLiveStreamDuringAds) {
|
|
271
|
-
video.play()
|
|
271
|
+
video.play()?.catch(() => {
|
|
272
272
|
});
|
|
273
273
|
console.log("[IMA] Video resumed (VOD mode)");
|
|
274
274
|
} else {
|
|
@@ -381,7 +381,7 @@ function createImaController(video, options) {
|
|
|
381
381
|
console.error("[IMA] Error starting ad playback:", error);
|
|
382
382
|
adPlaying = false;
|
|
383
383
|
if (!options?.continueLiveStreamDuringAds) {
|
|
384
|
-
video.play()
|
|
384
|
+
video.play()?.catch(() => {
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
387
|
return Promise.reject(error);
|
|
@@ -614,13 +614,32 @@ function getClientInfo() {
|
|
|
614
614
|
}
|
|
615
615
|
async function getBrowserID(clientInfo) {
|
|
616
616
|
const fingerprintString = JSON.stringify(clientInfo);
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
618
|
+
try {
|
|
619
|
+
const hashBuffer = await crypto.subtle.digest(
|
|
620
|
+
"SHA-256",
|
|
621
|
+
new TextEncoder().encode(fingerprintString)
|
|
622
|
+
);
|
|
623
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
624
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
625
|
+
return hashHex;
|
|
626
|
+
} catch (error) {
|
|
627
|
+
console.warn(
|
|
628
|
+
"[StormcloudVideoPlayer] crypto.subtle.digest failed, using fallback hash:",
|
|
629
|
+
error
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
let hash = 0;
|
|
634
|
+
for (let i = 0; i < fingerprintString.length; i++) {
|
|
635
|
+
const char = fingerprintString.charCodeAt(i);
|
|
636
|
+
hash = (hash << 5) - hash + char;
|
|
637
|
+
hash = hash & hash;
|
|
638
|
+
}
|
|
639
|
+
const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
|
|
640
|
+
const timestamp = Date.now().toString(16).padStart(12, "0");
|
|
641
|
+
const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
|
|
642
|
+
return (fallbackHash + timestamp + random).padEnd(64, "0");
|
|
624
643
|
}
|
|
625
644
|
async function sendInitialTracking(licenseKey) {
|
|
626
645
|
try {
|
|
@@ -738,7 +757,7 @@ var StormcloudVideoPlayer = class {
|
|
|
738
757
|
});
|
|
739
758
|
this.ima.initialize();
|
|
740
759
|
if (this.config.autoplay) {
|
|
741
|
-
await this.video.play()
|
|
760
|
+
await this.video.play()?.catch(() => {
|
|
742
761
|
});
|
|
743
762
|
}
|
|
744
763
|
return;
|
|
@@ -772,7 +791,7 @@ var StormcloudVideoPlayer = class {
|
|
|
772
791
|
});
|
|
773
792
|
this.ima.initialize();
|
|
774
793
|
if (this.config.autoplay) {
|
|
775
|
-
await this.video.play()
|
|
794
|
+
await this.video.play()?.catch(() => {
|
|
776
795
|
});
|
|
777
796
|
}
|
|
778
797
|
});
|
|
@@ -1405,17 +1424,6 @@ var StormcloudVideoPlayer = class {
|
|
|
1405
1424
|
}
|
|
1406
1425
|
return true;
|
|
1407
1426
|
}
|
|
1408
|
-
async loadDefaultVastFromAdstorm(adstormApiUrl, params) {
|
|
1409
|
-
const usp = new URLSearchParams(params || {});
|
|
1410
|
-
const url = `${adstormApiUrl}?${usp.toString()}`;
|
|
1411
|
-
const res = await fetch(url);
|
|
1412
|
-
if (!res.ok) throw new Error(`Failed to fetch adstorm ads: ${res.status}`);
|
|
1413
|
-
const data = await res.json();
|
|
1414
|
-
const tag = data?.adTagUrl || data?.vastTagUrl || data?.tagUrl;
|
|
1415
|
-
if (typeof tag === "string" && tag.length > 0) {
|
|
1416
|
-
this.apiVastTagUrl = tag;
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
1427
|
async handleAdStart(_marker) {
|
|
1420
1428
|
const scheduled = this.findCurrentOrNextBreak(
|
|
1421
1429
|
this.video.currentTime * 1e3
|
|
@@ -1596,7 +1604,7 @@ var StormcloudVideoPlayer = class {
|
|
|
1596
1604
|
this.currentAdIndex = 0;
|
|
1597
1605
|
this.totalAdsInBreak = 0;
|
|
1598
1606
|
if (this.video.paused) {
|
|
1599
|
-
this.video.play()
|
|
1607
|
+
this.video.play()?.catch(() => {
|
|
1600
1608
|
if (this.config.debugAdTiming) {
|
|
1601
1609
|
console.error(
|
|
1602
1610
|
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|