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
package/lib/index.js
CHANGED
|
@@ -236,8 +236,11 @@ function createImaController(video, options) {
|
|
|
236
236
|
);
|
|
237
237
|
emit("ad_error");
|
|
238
238
|
if (!options?.continueLiveStreamDuringAds) {
|
|
239
|
-
video.
|
|
240
|
-
|
|
239
|
+
if (video.paused) {
|
|
240
|
+
console.log("[IMA] Resuming paused video after ad error");
|
|
241
|
+
video.play()?.catch(() => {
|
|
242
|
+
});
|
|
243
|
+
}
|
|
241
244
|
}
|
|
242
245
|
}
|
|
243
246
|
}
|
|
@@ -328,10 +331,17 @@ function createImaController(video, options) {
|
|
|
328
331
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
329
332
|
adPlaying = false;
|
|
330
333
|
video.muted = originalMutedState;
|
|
331
|
-
if (adContainerEl)
|
|
334
|
+
if (adContainerEl) {
|
|
335
|
+
adContainerEl.style.pointerEvents = "none";
|
|
336
|
+
adContainerEl.style.display = "none";
|
|
337
|
+
console.log("[IMA] Ad container hidden after setup error");
|
|
338
|
+
}
|
|
332
339
|
if (!options?.continueLiveStreamDuringAds) {
|
|
333
|
-
video.
|
|
334
|
-
|
|
340
|
+
if (video.paused) {
|
|
341
|
+
console.log("[IMA] Resuming paused video after setup error");
|
|
342
|
+
video.play().catch(() => {
|
|
343
|
+
});
|
|
344
|
+
}
|
|
335
345
|
}
|
|
336
346
|
if (adsLoadedReject) {
|
|
337
347
|
adsLoadedReject(new Error("Failed to setup ads manager"));
|
|
@@ -349,10 +359,17 @@ function createImaController(video, options) {
|
|
|
349
359
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
350
360
|
adPlaying = false;
|
|
351
361
|
video.muted = originalMutedState;
|
|
352
|
-
if (adContainerEl)
|
|
362
|
+
if (adContainerEl) {
|
|
363
|
+
adContainerEl.style.pointerEvents = "none";
|
|
364
|
+
adContainerEl.style.display = "none";
|
|
365
|
+
console.log("[IMA] Ad container hidden after loader error");
|
|
366
|
+
}
|
|
353
367
|
if (!options?.continueLiveStreamDuringAds) {
|
|
354
|
-
video.
|
|
355
|
-
|
|
368
|
+
if (video.paused) {
|
|
369
|
+
console.log("[IMA] Resuming paused video after loader error");
|
|
370
|
+
video.play().catch(() => {
|
|
371
|
+
});
|
|
372
|
+
}
|
|
356
373
|
}
|
|
357
374
|
if (adsLoadedReject) {
|
|
358
375
|
adsLoadedReject(new Error("Ads loader error"));
|
|
@@ -929,15 +946,25 @@ var StormcloudVideoPlayer = class {
|
|
|
929
946
|
if (this.config.debugAdTiming) {
|
|
930
947
|
console.log("[StormcloudVideoPlayer] IMA ad_error event received");
|
|
931
948
|
}
|
|
932
|
-
if (
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
949
|
+
if (this.showAds) {
|
|
950
|
+
if (this.inAdBreak) {
|
|
951
|
+
const remaining = this.getRemainingAdMs();
|
|
952
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
953
|
+
const next = this.adPodQueue.shift();
|
|
954
|
+
this.currentAdIndex++;
|
|
955
|
+
this.playSingleAd(next).catch(() => {
|
|
956
|
+
});
|
|
957
|
+
} else {
|
|
958
|
+
this.handleAdFailure();
|
|
959
|
+
}
|
|
960
|
+
} else {
|
|
961
|
+
if (this.config.debugAdTiming) {
|
|
962
|
+
console.log(
|
|
963
|
+
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
this.handleAdFailure();
|
|
967
|
+
}
|
|
941
968
|
}
|
|
942
969
|
});
|
|
943
970
|
this.ima.on("content_pause", () => {
|
|
@@ -1518,9 +1545,20 @@ var StormcloudVideoPlayer = class {
|
|
|
1518
1545
|
return;
|
|
1519
1546
|
}
|
|
1520
1547
|
if (vastTagUrl) {
|
|
1548
|
+
this.inAdBreak = true;
|
|
1521
1549
|
this.showAds = true;
|
|
1522
1550
|
this.currentAdIndex++;
|
|
1523
|
-
|
|
1551
|
+
try {
|
|
1552
|
+
await this.playSingleAd(vastTagUrl);
|
|
1553
|
+
} catch (error) {
|
|
1554
|
+
if (this.config.debugAdTiming) {
|
|
1555
|
+
console.error(
|
|
1556
|
+
"[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
|
|
1557
|
+
error
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
this.handleAdFailure();
|
|
1561
|
+
}
|
|
1524
1562
|
}
|
|
1525
1563
|
if (this.expectedAdBreakDurationMs == null && scheduled?.durationMs != null) {
|
|
1526
1564
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -1651,7 +1689,13 @@ var StormcloudVideoPlayer = class {
|
|
|
1651
1689
|
handleAdFailure() {
|
|
1652
1690
|
if (this.config.debugAdTiming) {
|
|
1653
1691
|
console.log(
|
|
1654
|
-
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1692
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
1693
|
+
{
|
|
1694
|
+
inAdBreak: this.inAdBreak,
|
|
1695
|
+
showAds: this.showAds,
|
|
1696
|
+
videoPaused: this.video.paused,
|
|
1697
|
+
adPlaying: this.ima.isAdPlaying()
|
|
1698
|
+
}
|
|
1655
1699
|
);
|
|
1656
1700
|
}
|
|
1657
1701
|
this.inAdBreak = false;
|
|
@@ -1672,13 +1716,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1672
1716
|
);
|
|
1673
1717
|
}
|
|
1674
1718
|
if (this.video.paused) {
|
|
1675
|
-
this.
|
|
1719
|
+
if (this.config.debugAdTiming) {
|
|
1720
|
+
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
1721
|
+
}
|
|
1722
|
+
this.video.play()?.catch((error) => {
|
|
1676
1723
|
if (this.config.debugAdTiming) {
|
|
1677
1724
|
console.error(
|
|
1678
|
-
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1725
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure:",
|
|
1726
|
+
error
|
|
1679
1727
|
);
|
|
1680
1728
|
}
|
|
1681
1729
|
});
|
|
1730
|
+
} else {
|
|
1731
|
+
if (this.config.debugAdTiming) {
|
|
1732
|
+
console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
|
|
1733
|
+
}
|
|
1682
1734
|
}
|
|
1683
1735
|
}
|
|
1684
1736
|
startAdFailsafeTimer() {
|
|
@@ -1690,10 +1742,12 @@ var StormcloudVideoPlayer = class {
|
|
|
1690
1742
|
);
|
|
1691
1743
|
}
|
|
1692
1744
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1693
|
-
|
|
1745
|
+
const shouldTrigger = this.video.paused || this.showAds && !this.ima.isAdPlaying();
|
|
1746
|
+
if (shouldTrigger) {
|
|
1694
1747
|
if (this.config.debugAdTiming) {
|
|
1695
1748
|
console.warn(
|
|
1696
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume"
|
|
1749
|
+
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
1750
|
+
{ paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
|
|
1697
1751
|
);
|
|
1698
1752
|
}
|
|
1699
1753
|
this.handleAdFailure();
|