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
package/lib/players/index.cjs
CHANGED
|
@@ -309,8 +309,11 @@ function createImaController(video, options) {
|
|
|
309
309
|
);
|
|
310
310
|
emit("ad_error");
|
|
311
311
|
if (!options?.continueLiveStreamDuringAds) {
|
|
312
|
-
video.
|
|
313
|
-
|
|
312
|
+
if (video.paused) {
|
|
313
|
+
console.log("[IMA] Resuming paused video after ad error");
|
|
314
|
+
video.play()?.catch(() => {
|
|
315
|
+
});
|
|
316
|
+
}
|
|
314
317
|
}
|
|
315
318
|
}
|
|
316
319
|
}
|
|
@@ -401,10 +404,17 @@ function createImaController(video, options) {
|
|
|
401
404
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
402
405
|
adPlaying = false;
|
|
403
406
|
video.muted = originalMutedState;
|
|
404
|
-
if (adContainerEl)
|
|
407
|
+
if (adContainerEl) {
|
|
408
|
+
adContainerEl.style.pointerEvents = "none";
|
|
409
|
+
adContainerEl.style.display = "none";
|
|
410
|
+
console.log("[IMA] Ad container hidden after setup error");
|
|
411
|
+
}
|
|
405
412
|
if (!options?.continueLiveStreamDuringAds) {
|
|
406
|
-
video.
|
|
407
|
-
|
|
413
|
+
if (video.paused) {
|
|
414
|
+
console.log("[IMA] Resuming paused video after setup error");
|
|
415
|
+
video.play().catch(() => {
|
|
416
|
+
});
|
|
417
|
+
}
|
|
408
418
|
}
|
|
409
419
|
if (adsLoadedReject) {
|
|
410
420
|
adsLoadedReject(new Error("Failed to setup ads manager"));
|
|
@@ -422,10 +432,17 @@ function createImaController(video, options) {
|
|
|
422
432
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
423
433
|
adPlaying = false;
|
|
424
434
|
video.muted = originalMutedState;
|
|
425
|
-
if (adContainerEl)
|
|
435
|
+
if (adContainerEl) {
|
|
436
|
+
adContainerEl.style.pointerEvents = "none";
|
|
437
|
+
adContainerEl.style.display = "none";
|
|
438
|
+
console.log("[IMA] Ad container hidden after loader error");
|
|
439
|
+
}
|
|
426
440
|
if (!options?.continueLiveStreamDuringAds) {
|
|
427
|
-
video.
|
|
428
|
-
|
|
441
|
+
if (video.paused) {
|
|
442
|
+
console.log("[IMA] Resuming paused video after loader error");
|
|
443
|
+
video.play().catch(() => {
|
|
444
|
+
});
|
|
445
|
+
}
|
|
429
446
|
}
|
|
430
447
|
if (adsLoadedReject) {
|
|
431
448
|
adsLoadedReject(new Error("Ads loader error"));
|
|
@@ -722,10 +739,18 @@ async function getBrowserID(clientInfo) {
|
|
|
722
739
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
723
740
|
try {
|
|
724
741
|
await crypto.subtle.digest("SHA-256", new Uint8Array([1, 2, 3]));
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
new TextEncoder().encode(fingerprintString)
|
|
728
|
-
|
|
742
|
+
let encodedData;
|
|
743
|
+
if (typeof TextEncoder !== "undefined") {
|
|
744
|
+
encodedData = new TextEncoder().encode(fingerprintString);
|
|
745
|
+
} else {
|
|
746
|
+
const utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
747
|
+
const buffer = new Uint8Array(utf8.length);
|
|
748
|
+
for (let i = 0; i < utf8.length; i++) {
|
|
749
|
+
buffer[i] = utf8.charCodeAt(i);
|
|
750
|
+
}
|
|
751
|
+
encodedData = buffer;
|
|
752
|
+
}
|
|
753
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encodedData);
|
|
729
754
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
730
755
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
731
756
|
cachedBrowserId = hashHex;
|
|
@@ -1002,15 +1027,25 @@ var StormcloudVideoPlayer = class {
|
|
|
1002
1027
|
if (this.config.debugAdTiming) {
|
|
1003
1028
|
console.log("[StormcloudVideoPlayer] IMA ad_error event received");
|
|
1004
1029
|
}
|
|
1005
|
-
if (
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1030
|
+
if (this.showAds) {
|
|
1031
|
+
if (this.inAdBreak) {
|
|
1032
|
+
const remaining = this.getRemainingAdMs();
|
|
1033
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
1034
|
+
const next = this.adPodQueue.shift();
|
|
1035
|
+
this.currentAdIndex++;
|
|
1036
|
+
this.playSingleAd(next).catch(() => {
|
|
1037
|
+
});
|
|
1038
|
+
} else {
|
|
1039
|
+
this.handleAdFailure();
|
|
1040
|
+
}
|
|
1041
|
+
} else {
|
|
1042
|
+
if (this.config.debugAdTiming) {
|
|
1043
|
+
console.log(
|
|
1044
|
+
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
this.handleAdFailure();
|
|
1048
|
+
}
|
|
1014
1049
|
}
|
|
1015
1050
|
});
|
|
1016
1051
|
this.ima.on("content_pause", () => {
|
|
@@ -1591,9 +1626,20 @@ var StormcloudVideoPlayer = class {
|
|
|
1591
1626
|
return;
|
|
1592
1627
|
}
|
|
1593
1628
|
if (vastTagUrl) {
|
|
1629
|
+
this.inAdBreak = true;
|
|
1594
1630
|
this.showAds = true;
|
|
1595
1631
|
this.currentAdIndex++;
|
|
1596
|
-
|
|
1632
|
+
try {
|
|
1633
|
+
await this.playSingleAd(vastTagUrl);
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
if (this.config.debugAdTiming) {
|
|
1636
|
+
console.error(
|
|
1637
|
+
"[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
|
|
1638
|
+
error
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
this.handleAdFailure();
|
|
1642
|
+
}
|
|
1597
1643
|
}
|
|
1598
1644
|
if (this.expectedAdBreakDurationMs == null && scheduled?.durationMs != null) {
|
|
1599
1645
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -1724,7 +1770,13 @@ var StormcloudVideoPlayer = class {
|
|
|
1724
1770
|
handleAdFailure() {
|
|
1725
1771
|
if (this.config.debugAdTiming) {
|
|
1726
1772
|
console.log(
|
|
1727
|
-
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1773
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
1774
|
+
{
|
|
1775
|
+
inAdBreak: this.inAdBreak,
|
|
1776
|
+
showAds: this.showAds,
|
|
1777
|
+
videoPaused: this.video.paused,
|
|
1778
|
+
adPlaying: this.ima.isAdPlaying()
|
|
1779
|
+
}
|
|
1728
1780
|
);
|
|
1729
1781
|
}
|
|
1730
1782
|
this.inAdBreak = false;
|
|
@@ -1745,13 +1797,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1745
1797
|
);
|
|
1746
1798
|
}
|
|
1747
1799
|
if (this.video.paused) {
|
|
1748
|
-
this.
|
|
1800
|
+
if (this.config.debugAdTiming) {
|
|
1801
|
+
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
1802
|
+
}
|
|
1803
|
+
this.video.play()?.catch((error) => {
|
|
1749
1804
|
if (this.config.debugAdTiming) {
|
|
1750
1805
|
console.error(
|
|
1751
|
-
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1806
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure:",
|
|
1807
|
+
error
|
|
1752
1808
|
);
|
|
1753
1809
|
}
|
|
1754
1810
|
});
|
|
1811
|
+
} else {
|
|
1812
|
+
if (this.config.debugAdTiming) {
|
|
1813
|
+
console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
|
|
1814
|
+
}
|
|
1755
1815
|
}
|
|
1756
1816
|
}
|
|
1757
1817
|
startAdFailsafeTimer() {
|
|
@@ -1763,10 +1823,12 @@ var StormcloudVideoPlayer = class {
|
|
|
1763
1823
|
);
|
|
1764
1824
|
}
|
|
1765
1825
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1766
|
-
|
|
1826
|
+
const shouldTrigger = this.video.paused || this.showAds && !this.ima.isAdPlaying();
|
|
1827
|
+
if (shouldTrigger) {
|
|
1767
1828
|
if (this.config.debugAdTiming) {
|
|
1768
1829
|
console.warn(
|
|
1769
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume"
|
|
1830
|
+
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
1831
|
+
{ paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
|
|
1770
1832
|
);
|
|
1771
1833
|
}
|
|
1772
1834
|
this.handleAdFailure();
|