stormcloud-video-player 0.2.10 → 0.2.12
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/dist/stormcloud-vp.min.js +2 -2
- package/lib/index.cjs +113 -31
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +113 -31
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +89 -27
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +89 -27
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +89 -27
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +25 -8
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +89 -27
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/tracking.cjs +12 -4
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -270,8 +270,11 @@ function createImaController(video, options) {
|
|
|
270
270
|
);
|
|
271
271
|
emit("ad_error");
|
|
272
272
|
if (!options?.continueLiveStreamDuringAds) {
|
|
273
|
-
video.
|
|
274
|
-
|
|
273
|
+
if (video.paused) {
|
|
274
|
+
console.log("[IMA] Resuming paused video after ad error");
|
|
275
|
+
video.play()?.catch(() => {
|
|
276
|
+
});
|
|
277
|
+
}
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
}
|
|
@@ -362,10 +365,17 @@ function createImaController(video, options) {
|
|
|
362
365
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
363
366
|
adPlaying = false;
|
|
364
367
|
video.muted = originalMutedState;
|
|
365
|
-
if (adContainerEl)
|
|
368
|
+
if (adContainerEl) {
|
|
369
|
+
adContainerEl.style.pointerEvents = "none";
|
|
370
|
+
adContainerEl.style.display = "none";
|
|
371
|
+
console.log("[IMA] Ad container hidden after setup error");
|
|
372
|
+
}
|
|
366
373
|
if (!options?.continueLiveStreamDuringAds) {
|
|
367
|
-
video.
|
|
368
|
-
|
|
374
|
+
if (video.paused) {
|
|
375
|
+
console.log("[IMA] Resuming paused video after setup error");
|
|
376
|
+
video.play().catch(() => {
|
|
377
|
+
});
|
|
378
|
+
}
|
|
369
379
|
}
|
|
370
380
|
if (adsLoadedReject) {
|
|
371
381
|
adsLoadedReject(new Error("Failed to setup ads manager"));
|
|
@@ -383,10 +393,17 @@ function createImaController(video, options) {
|
|
|
383
393
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
384
394
|
adPlaying = false;
|
|
385
395
|
video.muted = originalMutedState;
|
|
386
|
-
if (adContainerEl)
|
|
396
|
+
if (adContainerEl) {
|
|
397
|
+
adContainerEl.style.pointerEvents = "none";
|
|
398
|
+
adContainerEl.style.display = "none";
|
|
399
|
+
console.log("[IMA] Ad container hidden after loader error");
|
|
400
|
+
}
|
|
387
401
|
if (!options?.continueLiveStreamDuringAds) {
|
|
388
|
-
video.
|
|
389
|
-
|
|
402
|
+
if (video.paused) {
|
|
403
|
+
console.log("[IMA] Resuming paused video after loader error");
|
|
404
|
+
video.play().catch(() => {
|
|
405
|
+
});
|
|
406
|
+
}
|
|
390
407
|
}
|
|
391
408
|
if (adsLoadedReject) {
|
|
392
409
|
adsLoadedReject(new Error("Ads loader error"));
|
|
@@ -683,10 +700,18 @@ async function getBrowserID(clientInfo) {
|
|
|
683
700
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
684
701
|
try {
|
|
685
702
|
await crypto.subtle.digest("SHA-256", new Uint8Array([1, 2, 3]));
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
new TextEncoder().encode(fingerprintString)
|
|
689
|
-
|
|
703
|
+
let encodedData;
|
|
704
|
+
if (typeof TextEncoder !== "undefined") {
|
|
705
|
+
encodedData = new TextEncoder().encode(fingerprintString);
|
|
706
|
+
} else {
|
|
707
|
+
const utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
708
|
+
const buffer = new Uint8Array(utf8.length);
|
|
709
|
+
for (let i = 0; i < utf8.length; i++) {
|
|
710
|
+
buffer[i] = utf8.charCodeAt(i);
|
|
711
|
+
}
|
|
712
|
+
encodedData = buffer;
|
|
713
|
+
}
|
|
714
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encodedData);
|
|
690
715
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
691
716
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
692
717
|
cachedBrowserId = hashHex;
|
|
@@ -963,15 +988,25 @@ var StormcloudVideoPlayer = class {
|
|
|
963
988
|
if (this.config.debugAdTiming) {
|
|
964
989
|
console.log("[StormcloudVideoPlayer] IMA ad_error event received");
|
|
965
990
|
}
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
991
|
+
if (this.showAds) {
|
|
992
|
+
if (this.inAdBreak) {
|
|
993
|
+
const remaining = this.getRemainingAdMs();
|
|
994
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
995
|
+
const next = this.adPodQueue.shift();
|
|
996
|
+
this.currentAdIndex++;
|
|
997
|
+
this.playSingleAd(next).catch(() => {
|
|
998
|
+
});
|
|
999
|
+
} else {
|
|
1000
|
+
this.handleAdFailure();
|
|
1001
|
+
}
|
|
1002
|
+
} else {
|
|
1003
|
+
if (this.config.debugAdTiming) {
|
|
1004
|
+
console.log(
|
|
1005
|
+
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
this.handleAdFailure();
|
|
1009
|
+
}
|
|
975
1010
|
}
|
|
976
1011
|
});
|
|
977
1012
|
this.ima.on("content_pause", () => {
|
|
@@ -1552,9 +1587,20 @@ var StormcloudVideoPlayer = class {
|
|
|
1552
1587
|
return;
|
|
1553
1588
|
}
|
|
1554
1589
|
if (vastTagUrl) {
|
|
1590
|
+
this.inAdBreak = true;
|
|
1555
1591
|
this.showAds = true;
|
|
1556
1592
|
this.currentAdIndex++;
|
|
1557
|
-
|
|
1593
|
+
try {
|
|
1594
|
+
await this.playSingleAd(vastTagUrl);
|
|
1595
|
+
} catch (error) {
|
|
1596
|
+
if (this.config.debugAdTiming) {
|
|
1597
|
+
console.error(
|
|
1598
|
+
"[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
|
|
1599
|
+
error
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
this.handleAdFailure();
|
|
1603
|
+
}
|
|
1558
1604
|
}
|
|
1559
1605
|
if (this.expectedAdBreakDurationMs == null && scheduled?.durationMs != null) {
|
|
1560
1606
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -1685,7 +1731,13 @@ var StormcloudVideoPlayer = class {
|
|
|
1685
1731
|
handleAdFailure() {
|
|
1686
1732
|
if (this.config.debugAdTiming) {
|
|
1687
1733
|
console.log(
|
|
1688
|
-
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1734
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
1735
|
+
{
|
|
1736
|
+
inAdBreak: this.inAdBreak,
|
|
1737
|
+
showAds: this.showAds,
|
|
1738
|
+
videoPaused: this.video.paused,
|
|
1739
|
+
adPlaying: this.ima.isAdPlaying()
|
|
1740
|
+
}
|
|
1689
1741
|
);
|
|
1690
1742
|
}
|
|
1691
1743
|
this.inAdBreak = false;
|
|
@@ -1706,13 +1758,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1706
1758
|
);
|
|
1707
1759
|
}
|
|
1708
1760
|
if (this.video.paused) {
|
|
1709
|
-
this.
|
|
1761
|
+
if (this.config.debugAdTiming) {
|
|
1762
|
+
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
1763
|
+
}
|
|
1764
|
+
this.video.play()?.catch((error) => {
|
|
1710
1765
|
if (this.config.debugAdTiming) {
|
|
1711
1766
|
console.error(
|
|
1712
|
-
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1767
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure:",
|
|
1768
|
+
error
|
|
1713
1769
|
);
|
|
1714
1770
|
}
|
|
1715
1771
|
});
|
|
1772
|
+
} else {
|
|
1773
|
+
if (this.config.debugAdTiming) {
|
|
1774
|
+
console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
|
|
1775
|
+
}
|
|
1716
1776
|
}
|
|
1717
1777
|
}
|
|
1718
1778
|
startAdFailsafeTimer() {
|
|
@@ -1724,10 +1784,12 @@ var StormcloudVideoPlayer = class {
|
|
|
1724
1784
|
);
|
|
1725
1785
|
}
|
|
1726
1786
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1727
|
-
|
|
1787
|
+
const shouldTrigger = this.video.paused || this.showAds && !this.ima.isAdPlaying();
|
|
1788
|
+
if (shouldTrigger) {
|
|
1728
1789
|
if (this.config.debugAdTiming) {
|
|
1729
1790
|
console.warn(
|
|
1730
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume"
|
|
1791
|
+
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
1792
|
+
{ paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
|
|
1731
1793
|
);
|
|
1732
1794
|
}
|
|
1733
1795
|
this.handleAdFailure();
|