stormcloud-video-player 0.2.10 → 0.2.11
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 +77 -23
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +77 -23
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +77 -23
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +77 -23
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +77 -23
- 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 +77 -23
- package/lib/ui/StormcloudVideoPlayer.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"));
|
|
@@ -963,15 +980,25 @@ var StormcloudVideoPlayer = class {
|
|
|
963
980
|
if (this.config.debugAdTiming) {
|
|
964
981
|
console.log("[StormcloudVideoPlayer] IMA ad_error event received");
|
|
965
982
|
}
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
983
|
+
if (this.showAds) {
|
|
984
|
+
if (this.inAdBreak) {
|
|
985
|
+
const remaining = this.getRemainingAdMs();
|
|
986
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
987
|
+
const next = this.adPodQueue.shift();
|
|
988
|
+
this.currentAdIndex++;
|
|
989
|
+
this.playSingleAd(next).catch(() => {
|
|
990
|
+
});
|
|
991
|
+
} else {
|
|
992
|
+
this.handleAdFailure();
|
|
993
|
+
}
|
|
994
|
+
} else {
|
|
995
|
+
if (this.config.debugAdTiming) {
|
|
996
|
+
console.log(
|
|
997
|
+
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
this.handleAdFailure();
|
|
1001
|
+
}
|
|
975
1002
|
}
|
|
976
1003
|
});
|
|
977
1004
|
this.ima.on("content_pause", () => {
|
|
@@ -1552,9 +1579,20 @@ var StormcloudVideoPlayer = class {
|
|
|
1552
1579
|
return;
|
|
1553
1580
|
}
|
|
1554
1581
|
if (vastTagUrl) {
|
|
1582
|
+
this.inAdBreak = true;
|
|
1555
1583
|
this.showAds = true;
|
|
1556
1584
|
this.currentAdIndex++;
|
|
1557
|
-
|
|
1585
|
+
try {
|
|
1586
|
+
await this.playSingleAd(vastTagUrl);
|
|
1587
|
+
} catch (error) {
|
|
1588
|
+
if (this.config.debugAdTiming) {
|
|
1589
|
+
console.error(
|
|
1590
|
+
"[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
|
|
1591
|
+
error
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
this.handleAdFailure();
|
|
1595
|
+
}
|
|
1558
1596
|
}
|
|
1559
1597
|
if (this.expectedAdBreakDurationMs == null && scheduled?.durationMs != null) {
|
|
1560
1598
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -1685,7 +1723,13 @@ var StormcloudVideoPlayer = class {
|
|
|
1685
1723
|
handleAdFailure() {
|
|
1686
1724
|
if (this.config.debugAdTiming) {
|
|
1687
1725
|
console.log(
|
|
1688
|
-
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1726
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
1727
|
+
{
|
|
1728
|
+
inAdBreak: this.inAdBreak,
|
|
1729
|
+
showAds: this.showAds,
|
|
1730
|
+
videoPaused: this.video.paused,
|
|
1731
|
+
adPlaying: this.ima.isAdPlaying()
|
|
1732
|
+
}
|
|
1689
1733
|
);
|
|
1690
1734
|
}
|
|
1691
1735
|
this.inAdBreak = false;
|
|
@@ -1706,13 +1750,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1706
1750
|
);
|
|
1707
1751
|
}
|
|
1708
1752
|
if (this.video.paused) {
|
|
1709
|
-
this.
|
|
1753
|
+
if (this.config.debugAdTiming) {
|
|
1754
|
+
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
1755
|
+
}
|
|
1756
|
+
this.video.play()?.catch((error) => {
|
|
1710
1757
|
if (this.config.debugAdTiming) {
|
|
1711
1758
|
console.error(
|
|
1712
|
-
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1759
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure:",
|
|
1760
|
+
error
|
|
1713
1761
|
);
|
|
1714
1762
|
}
|
|
1715
1763
|
});
|
|
1764
|
+
} else {
|
|
1765
|
+
if (this.config.debugAdTiming) {
|
|
1766
|
+
console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
|
|
1767
|
+
}
|
|
1716
1768
|
}
|
|
1717
1769
|
}
|
|
1718
1770
|
startAdFailsafeTimer() {
|
|
@@ -1724,10 +1776,12 @@ var StormcloudVideoPlayer = class {
|
|
|
1724
1776
|
);
|
|
1725
1777
|
}
|
|
1726
1778
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1727
|
-
|
|
1779
|
+
const shouldTrigger = this.video.paused || this.showAds && !this.ima.isAdPlaying();
|
|
1780
|
+
if (shouldTrigger) {
|
|
1728
1781
|
if (this.config.debugAdTiming) {
|
|
1729
1782
|
console.warn(
|
|
1730
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume"
|
|
1783
|
+
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
1784
|
+
{ paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
|
|
1731
1785
|
);
|
|
1732
1786
|
}
|
|
1733
1787
|
this.handleAdFailure();
|