stormcloud-video-player 0.3.12 → 0.3.14
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 +1 -1
- package/lib/index.cjs +32 -5
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +32 -5
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +32 -5
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +2 -0
- package/lib/players/HlsPlayer.cjs +32 -5
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +32 -5
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +17 -1
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +32 -5
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -964,6 +964,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
964
964
|
let sessionId;
|
|
965
965
|
const preloadedAds = /* @__PURE__ */ new Map();
|
|
966
966
|
const preloadingAds = /* @__PURE__ */ new Map();
|
|
967
|
+
let destroyed = false;
|
|
968
|
+
let pendingTimeouts = [];
|
|
967
969
|
let trackingFired = {
|
|
968
970
|
impression: false,
|
|
969
971
|
start: false,
|
|
@@ -1292,7 +1294,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1292
1294
|
adPlaying = false;
|
|
1293
1295
|
setAdPlayingFlag(false);
|
|
1294
1296
|
emit("content_resume");
|
|
1295
|
-
setTimeout(() => {
|
|
1297
|
+
const timeoutId = window.setTimeout(() => {
|
|
1298
|
+
if (destroyed) {
|
|
1299
|
+
console.log("[HlsAdPlayer] Player destroyed, skipping post-completion check");
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1296
1302
|
const stillInPod = contentVideo.dataset.stormcloudAdPlaying === "true";
|
|
1297
1303
|
if (stillInPod) {
|
|
1298
1304
|
console.log(
|
|
@@ -1303,7 +1309,12 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1303
1309
|
adContainerEl.style.pointerEvents = "auto";
|
|
1304
1310
|
}
|
|
1305
1311
|
}
|
|
1312
|
+
const idx = pendingTimeouts.indexOf(timeoutId);
|
|
1313
|
+
if (idx !== -1) {
|
|
1314
|
+
pendingTimeouts.splice(idx, 1);
|
|
1315
|
+
}
|
|
1306
1316
|
}, 50);
|
|
1317
|
+
pendingTimeouts.push(timeoutId);
|
|
1307
1318
|
}
|
|
1308
1319
|
function handleAdError() {
|
|
1309
1320
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -1533,6 +1544,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1533
1544
|
},
|
|
1534
1545
|
destroy() {
|
|
1535
1546
|
console.log("[HlsAdPlayer] Destroying");
|
|
1547
|
+
destroyed = true;
|
|
1548
|
+
for (const timeoutId of pendingTimeouts) {
|
|
1549
|
+
clearTimeout(timeoutId);
|
|
1550
|
+
}
|
|
1551
|
+
pendingTimeouts = [];
|
|
1536
1552
|
adPlaying = false;
|
|
1537
1553
|
setAdPlayingFlag(false);
|
|
1538
1554
|
contentVideo.muted = originalMutedState;
|
|
@@ -2445,10 +2461,11 @@ var StormcloudVideoPlayer = class {
|
|
|
2445
2461
|
this.handleAdPodComplete();
|
|
2446
2462
|
}
|
|
2447
2463
|
});
|
|
2448
|
-
this.
|
|
2464
|
+
this.timeUpdateHandler = () => {
|
|
2449
2465
|
this.onTimeUpdate(this.video.currentTime);
|
|
2450
|
-
}
|
|
2451
|
-
this.video.addEventListener("
|
|
2466
|
+
};
|
|
2467
|
+
this.video.addEventListener("timeupdate", this.timeUpdateHandler);
|
|
2468
|
+
this.emptiedHandler = () => {
|
|
2452
2469
|
if (this.nativeHlsMode && this.videoSrcProtection && !this.ima.isAdPlaying()) {
|
|
2453
2470
|
if (this.config.debugAdTiming) {
|
|
2454
2471
|
console.log(
|
|
@@ -2465,7 +2482,8 @@ var StormcloudVideoPlayer = class {
|
|
|
2465
2482
|
});
|
|
2466
2483
|
}
|
|
2467
2484
|
}
|
|
2468
|
-
}
|
|
2485
|
+
};
|
|
2486
|
+
this.video.addEventListener("emptied", this.emptiedHandler);
|
|
2469
2487
|
}
|
|
2470
2488
|
shouldUseNativeHls() {
|
|
2471
2489
|
const streamType = this.getStreamType();
|
|
@@ -4101,6 +4119,15 @@ var StormcloudVideoPlayer = class {
|
|
|
4101
4119
|
this.clearAdStartTimer();
|
|
4102
4120
|
this.clearAdStopTimer();
|
|
4103
4121
|
this.clearAdFailsafeTimer();
|
|
4122
|
+
this.clearAdRequestWatchdog();
|
|
4123
|
+
if (this.timeUpdateHandler) {
|
|
4124
|
+
this.video.removeEventListener("timeupdate", this.timeUpdateHandler);
|
|
4125
|
+
delete this.timeUpdateHandler;
|
|
4126
|
+
}
|
|
4127
|
+
if (this.emptiedHandler) {
|
|
4128
|
+
this.video.removeEventListener("emptied", this.emptiedHandler);
|
|
4129
|
+
delete this.emptiedHandler;
|
|
4130
|
+
}
|
|
4104
4131
|
if (this.heartbeatInterval) {
|
|
4105
4132
|
clearInterval(this.heartbeatInterval);
|
|
4106
4133
|
this.heartbeatInterval = void 0;
|