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/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"));
|
|
@@ -649,10 +666,18 @@ async function getBrowserID(clientInfo) {
|
|
|
649
666
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
650
667
|
try {
|
|
651
668
|
await crypto.subtle.digest("SHA-256", new Uint8Array([1, 2, 3]));
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
new TextEncoder().encode(fingerprintString)
|
|
655
|
-
|
|
669
|
+
let encodedData;
|
|
670
|
+
if (typeof TextEncoder !== "undefined") {
|
|
671
|
+
encodedData = new TextEncoder().encode(fingerprintString);
|
|
672
|
+
} else {
|
|
673
|
+
const utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
674
|
+
const buffer = new Uint8Array(utf8.length);
|
|
675
|
+
for (let i = 0; i < utf8.length; i++) {
|
|
676
|
+
buffer[i] = utf8.charCodeAt(i);
|
|
677
|
+
}
|
|
678
|
+
encodedData = buffer;
|
|
679
|
+
}
|
|
680
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encodedData);
|
|
656
681
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
657
682
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
658
683
|
cachedBrowserId = hashHex;
|
|
@@ -929,15 +954,25 @@ var StormcloudVideoPlayer = class {
|
|
|
929
954
|
if (this.config.debugAdTiming) {
|
|
930
955
|
console.log("[StormcloudVideoPlayer] IMA ad_error event received");
|
|
931
956
|
}
|
|
932
|
-
if (
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
957
|
+
if (this.showAds) {
|
|
958
|
+
if (this.inAdBreak) {
|
|
959
|
+
const remaining = this.getRemainingAdMs();
|
|
960
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
961
|
+
const next = this.adPodQueue.shift();
|
|
962
|
+
this.currentAdIndex++;
|
|
963
|
+
this.playSingleAd(next).catch(() => {
|
|
964
|
+
});
|
|
965
|
+
} else {
|
|
966
|
+
this.handleAdFailure();
|
|
967
|
+
}
|
|
968
|
+
} else {
|
|
969
|
+
if (this.config.debugAdTiming) {
|
|
970
|
+
console.log(
|
|
971
|
+
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
this.handleAdFailure();
|
|
975
|
+
}
|
|
941
976
|
}
|
|
942
977
|
});
|
|
943
978
|
this.ima.on("content_pause", () => {
|
|
@@ -1518,9 +1553,20 @@ var StormcloudVideoPlayer = class {
|
|
|
1518
1553
|
return;
|
|
1519
1554
|
}
|
|
1520
1555
|
if (vastTagUrl) {
|
|
1556
|
+
this.inAdBreak = true;
|
|
1521
1557
|
this.showAds = true;
|
|
1522
1558
|
this.currentAdIndex++;
|
|
1523
|
-
|
|
1559
|
+
try {
|
|
1560
|
+
await this.playSingleAd(vastTagUrl);
|
|
1561
|
+
} catch (error) {
|
|
1562
|
+
if (this.config.debugAdTiming) {
|
|
1563
|
+
console.error(
|
|
1564
|
+
"[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
|
|
1565
|
+
error
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
this.handleAdFailure();
|
|
1569
|
+
}
|
|
1524
1570
|
}
|
|
1525
1571
|
if (this.expectedAdBreakDurationMs == null && scheduled?.durationMs != null) {
|
|
1526
1572
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -1651,7 +1697,13 @@ var StormcloudVideoPlayer = class {
|
|
|
1651
1697
|
handleAdFailure() {
|
|
1652
1698
|
if (this.config.debugAdTiming) {
|
|
1653
1699
|
console.log(
|
|
1654
|
-
"[StormcloudVideoPlayer] Handling ad failure - resuming content"
|
|
1700
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
1701
|
+
{
|
|
1702
|
+
inAdBreak: this.inAdBreak,
|
|
1703
|
+
showAds: this.showAds,
|
|
1704
|
+
videoPaused: this.video.paused,
|
|
1705
|
+
adPlaying: this.ima.isAdPlaying()
|
|
1706
|
+
}
|
|
1655
1707
|
);
|
|
1656
1708
|
}
|
|
1657
1709
|
this.inAdBreak = false;
|
|
@@ -1672,13 +1724,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1672
1724
|
);
|
|
1673
1725
|
}
|
|
1674
1726
|
if (this.video.paused) {
|
|
1675
|
-
this.
|
|
1727
|
+
if (this.config.debugAdTiming) {
|
|
1728
|
+
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
1729
|
+
}
|
|
1730
|
+
this.video.play()?.catch((error) => {
|
|
1676
1731
|
if (this.config.debugAdTiming) {
|
|
1677
1732
|
console.error(
|
|
1678
|
-
"[StormcloudVideoPlayer] Failed to resume video after ad failure"
|
|
1733
|
+
"[StormcloudVideoPlayer] Failed to resume video after ad failure:",
|
|
1734
|
+
error
|
|
1679
1735
|
);
|
|
1680
1736
|
}
|
|
1681
1737
|
});
|
|
1738
|
+
} else {
|
|
1739
|
+
if (this.config.debugAdTiming) {
|
|
1740
|
+
console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
|
|
1741
|
+
}
|
|
1682
1742
|
}
|
|
1683
1743
|
}
|
|
1684
1744
|
startAdFailsafeTimer() {
|
|
@@ -1690,10 +1750,12 @@ var StormcloudVideoPlayer = class {
|
|
|
1690
1750
|
);
|
|
1691
1751
|
}
|
|
1692
1752
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
1693
|
-
|
|
1753
|
+
const shouldTrigger = this.video.paused || this.showAds && !this.ima.isAdPlaying();
|
|
1754
|
+
if (shouldTrigger) {
|
|
1694
1755
|
if (this.config.debugAdTiming) {
|
|
1695
1756
|
console.warn(
|
|
1696
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume"
|
|
1757
|
+
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
1758
|
+
{ paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
|
|
1697
1759
|
);
|
|
1698
1760
|
}
|
|
1699
1761
|
this.handleAdFailure();
|
|
@@ -3420,10 +3482,30 @@ var randomString = () => {
|
|
|
3420
3482
|
};
|
|
3421
3483
|
var parseQuery = (url) => {
|
|
3422
3484
|
const query = {};
|
|
3423
|
-
const
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3485
|
+
const queryString = url.split("?")[1] || "";
|
|
3486
|
+
if (!queryString) return query;
|
|
3487
|
+
if (typeof URLSearchParams !== "undefined") {
|
|
3488
|
+
try {
|
|
3489
|
+
const params = new URLSearchParams(queryString);
|
|
3490
|
+
params.forEach((value, key) => {
|
|
3491
|
+
query[key] = value;
|
|
3492
|
+
});
|
|
3493
|
+
} catch (e) {
|
|
3494
|
+
queryString.split("&").forEach((param) => {
|
|
3495
|
+
const [key, value] = param.split("=");
|
|
3496
|
+
if (key) {
|
|
3497
|
+
query[decodeURIComponent(key)] = value ? decodeURIComponent(value) : "";
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
} else {
|
|
3502
|
+
queryString.split("&").forEach((param) => {
|
|
3503
|
+
const [key, value] = param.split("=");
|
|
3504
|
+
if (key) {
|
|
3505
|
+
query[decodeURIComponent(key)] = value ? decodeURIComponent(value) : "";
|
|
3506
|
+
}
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3427
3509
|
return query;
|
|
3428
3510
|
};
|
|
3429
3511
|
var merge = (target, ...sources) => {
|