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
|
@@ -267,8 +267,11 @@ function createImaController(video, options) {
|
|
|
267
267
|
);
|
|
268
268
|
emit("ad_error");
|
|
269
269
|
if (!options?.continueLiveStreamDuringAds) {
|
|
270
|
-
video.
|
|
271
|
-
|
|
270
|
+
if (video.paused) {
|
|
271
|
+
console.log("[IMA] Resuming paused video after ad error");
|
|
272
|
+
video.play()?.catch(() => {
|
|
273
|
+
});
|
|
274
|
+
}
|
|
272
275
|
}
|
|
273
276
|
}
|
|
274
277
|
}
|
|
@@ -359,10 +362,17 @@ function createImaController(video, options) {
|
|
|
359
362
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
360
363
|
adPlaying = false;
|
|
361
364
|
video.muted = originalMutedState;
|
|
362
|
-
if (adContainerEl)
|
|
365
|
+
if (adContainerEl) {
|
|
366
|
+
adContainerEl.style.pointerEvents = "none";
|
|
367
|
+
adContainerEl.style.display = "none";
|
|
368
|
+
console.log("[IMA] Ad container hidden after setup error");
|
|
369
|
+
}
|
|
363
370
|
if (!options?.continueLiveStreamDuringAds) {
|
|
364
|
-
video.
|
|
365
|
-
|
|
371
|
+
if (video.paused) {
|
|
372
|
+
console.log("[IMA] Resuming paused video after setup error");
|
|
373
|
+
video.play().catch(() => {
|
|
374
|
+
});
|
|
375
|
+
}
|
|
366
376
|
}
|
|
367
377
|
if (adsLoadedReject) {
|
|
368
378
|
adsLoadedReject(new Error("Failed to setup ads manager"));
|
|
@@ -380,10 +390,17 @@ function createImaController(video, options) {
|
|
|
380
390
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
381
391
|
adPlaying = false;
|
|
382
392
|
video.muted = originalMutedState;
|
|
383
|
-
if (adContainerEl)
|
|
393
|
+
if (adContainerEl) {
|
|
394
|
+
adContainerEl.style.pointerEvents = "none";
|
|
395
|
+
adContainerEl.style.display = "none";
|
|
396
|
+
console.log("[IMA] Ad container hidden after loader error");
|
|
397
|
+
}
|
|
384
398
|
if (!options?.continueLiveStreamDuringAds) {
|
|
385
|
-
video.
|
|
386
|
-
|
|
399
|
+
if (video.paused) {
|
|
400
|
+
console.log("[IMA] Resuming paused video after loader error");
|
|
401
|
+
video.play().catch(() => {
|
|
402
|
+
});
|
|
403
|
+
}
|
|
387
404
|
}
|
|
388
405
|
if (adsLoadedReject) {
|
|
389
406
|
adsLoadedReject(new Error("Ads loader error"));
|
|
@@ -960,15 +977,25 @@ var StormcloudVideoPlayer = class {
|
|
|
960
977
|
if (this.config.debugAdTiming) {
|
|
961
978
|
console.log("[StormcloudVideoPlayer] IMA ad_error event received");
|
|
962
979
|
}
|
|
963
|
-
if (
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
980
|
+
if (this.showAds) {
|
|
981
|
+
if (this.inAdBreak) {
|
|
982
|
+
const remaining = this.getRemainingAdMs();
|
|
983
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
984
|
+
const next = this.adPodQueue.shift();
|
|
985
|
+
this.currentAdIndex++;
|
|
986
|
+
this.playSingleAd(next).catch(() => {
|
|
987
|
+
});
|
|
988
|
+
} else {
|
|
989
|
+
this.handleAdFailure();
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
if (this.config.debugAdTiming) {
|
|
993
|
+
console.log(
|
|
994
|
+
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
this.handleAdFailure();
|
|
998
|
+
}
|
|
972
999
|
}
|
|
973
1000
|
});
|
|
974
1001
|
this.ima.on("content_pause", () => {
|
|
@@ -1549,9 +1576,20 @@ var StormcloudVideoPlayer = class {
|
|
|
1549
1576
|
return;
|
|
1550
1577
|
}
|
|
1551
1578
|
if (vastTagUrl) {
|
|
1579
|
+
this.inAdBreak = true;
|
|
1552
1580
|
this.showAds = true;
|
|
1553
1581
|
this.currentAdIndex++;
|
|
1554
|
-
|
|
1582
|
+
try {
|
|
1583
|
+
await this.playSingleAd(vastTagUrl);
|
|
1584
|
+
} catch (error) {
|
|
1585
|
+
if (this.config.debugAdTiming) {
|
|
1586
|
+
console.error(
|
|
1587
|
+
"[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
|
|
1588
|
+
error
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1591
|
+
this.handleAdFailure();
|
|
1592
|
+
}
|
|
1555
1593
|
}
|
|
1556
1594
|
if (this.expectedAdBreakDurationMs == null && scheduled?.durationMs != null) {
|
|
1557
1595
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -1682,7 +1720,13 @@ var StormcloudVideoPlayer = class {
|
|
|
1682
1720
|
handleAdFailure() {
|
|
1683
1721
|
if (this.config.debugAdTiming) {
|
|
1684
1722
|
console.log(
|
|
1685
|
-
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1723
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
1724
|
+
{
|
|
1725
|
+
inAdBreak: this.inAdBreak,
|
|
1726
|
+
showAds: this.showAds,
|
|
1727
|
+
videoPaused: this.video.paused,
|
|
1728
|
+
adPlaying: this.ima.isAdPlaying()
|
|
1729
|
+
}
|
|
1686
1730
|
);
|
|
1687
1731
|
}
|
|
1688
1732
|
this.inAdBreak = false;
|
|
@@ -1703,13 +1747,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1703
1747
|
);
|
|
1704
1748
|
}
|
|
1705
1749
|
if (this.video.paused) {
|
|
1706
|
-
this.
|
|
1750
|
+
if (this.config.debugAdTiming) {
|
|
1751
|
+
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
1752
|
+
}
|
|
1753
|
+
this.video.play()?.catch((error) => {
|
|
1707
1754
|
if (this.config.debugAdTiming) {
|
|
1708
1755
|
console.error(
|
|
1709
|
-
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1756
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure:",
|
|
1757
|
+
error
|
|
1710
1758
|
);
|
|
1711
1759
|
}
|
|
1712
1760
|
});
|
|
1761
|
+
} else {
|
|
1762
|
+
if (this.config.debugAdTiming) {
|
|
1763
|
+
console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
|
|
1764
|
+
}
|
|
1713
1765
|
}
|
|
1714
1766
|
}
|
|
1715
1767
|
startAdFailsafeTimer() {
|
|
@@ -1721,10 +1773,12 @@ var StormcloudVideoPlayer = class {
|
|
|
1721
1773
|
);
|
|
1722
1774
|
}
|
|
1723
1775
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1724
|
-
|
|
1776
|
+
const shouldTrigger = this.video.paused || this.showAds && !this.ima.isAdPlaying();
|
|
1777
|
+
if (shouldTrigger) {
|
|
1725
1778
|
if (this.config.debugAdTiming) {
|
|
1726
1779
|
console.warn(
|
|
1727
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume"
|
|
1780
|
+
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
1781
|
+
{ paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
|
|
1728
1782
|
);
|
|
1729
1783
|
}
|
|
1730
1784
|
this.handleAdFailure();
|