stormcloud-video-player 0.8.41 → 0.8.43
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 +118 -27
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +118 -27
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +70 -25
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +2 -0
- package/lib/player/HlsEngine.cjs +29 -0
- package/lib/player/HlsEngine.cjs.map +1 -1
- package/lib/player/HlsEngine.d.cts +2 -0
- package/lib/player/StormcloudVideoPlayer.cjs +118 -27
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +118 -27
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +118 -27
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +8 -2
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +118 -27
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1703,7 +1703,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1703
1703
|
}
|
|
1704
1704
|
if (adVideoElement) {
|
|
1705
1705
|
adVideoElement.pause();
|
|
1706
|
-
adVideoElement.src
|
|
1706
|
+
adVideoElement.removeAttribute("src");
|
|
1707
|
+
try {
|
|
1708
|
+
adVideoElement.load();
|
|
1709
|
+
} catch (unused) {}
|
|
1707
1710
|
}
|
|
1708
1711
|
currentAd = void 0;
|
|
1709
1712
|
podAds = [];
|
|
@@ -1749,7 +1752,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1749
1752
|
}
|
|
1750
1753
|
if (adVideoElement) {
|
|
1751
1754
|
adVideoElement.pause();
|
|
1752
|
-
adVideoElement.src
|
|
1755
|
+
adVideoElement.removeAttribute("src");
|
|
1756
|
+
try {
|
|
1757
|
+
adVideoElement.load();
|
|
1758
|
+
} catch (unused) {}
|
|
1753
1759
|
adVideoElement.remove();
|
|
1754
1760
|
adVideoElement = void 0;
|
|
1755
1761
|
}
|
|
@@ -6477,6 +6483,7 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6477
6483
|
this.isLiveStream = false;
|
|
6478
6484
|
this.nativeHlsMode = false;
|
|
6479
6485
|
this.videoSrcProtection = null;
|
|
6486
|
+
this.reloadingLiveStream = false;
|
|
6480
6487
|
this.bufferedSegmentsCount = 0;
|
|
6481
6488
|
this.shouldAutoplayAfterBuffering = false;
|
|
6482
6489
|
this.hasInitialBufferCompleted = false;
|
|
@@ -6610,6 +6617,7 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6610
6617
|
_state.sent();
|
|
6611
6618
|
_state.label = 3;
|
|
6612
6619
|
case 3:
|
|
6620
|
+
this.reloadingLiveStream = false;
|
|
6613
6621
|
return [
|
|
6614
6622
|
2
|
|
6615
6623
|
];
|
|
@@ -6954,6 +6962,33 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6954
6962
|
}
|
|
6955
6963
|
}
|
|
6956
6964
|
},
|
|
6965
|
+
{
|
|
6966
|
+
key: "reloadLiveStream",
|
|
6967
|
+
value: function reloadLiveStream() {
|
|
6968
|
+
var hls = this.hls;
|
|
6969
|
+
if (!hls) {
|
|
6970
|
+
return;
|
|
6971
|
+
}
|
|
6972
|
+
if (this.debug) {
|
|
6973
|
+
console.log("[StormcloudVideoPlayer] Hard-reloading live stream (detach \u2192 reset video \u2192 re-attach)");
|
|
6974
|
+
}
|
|
6975
|
+
try {
|
|
6976
|
+
this.reloadingLiveStream = true;
|
|
6977
|
+
hls.stopLoad();
|
|
6978
|
+
hls.detachMedia();
|
|
6979
|
+
try {
|
|
6980
|
+
this.video.removeAttribute("src");
|
|
6981
|
+
this.video.load();
|
|
6982
|
+
} catch (unused) {}
|
|
6983
|
+
hls.attachMedia(this.video);
|
|
6984
|
+
} catch (error) {
|
|
6985
|
+
this.reloadingLiveStream = false;
|
|
6986
|
+
if (this.debug) {
|
|
6987
|
+
console.warn("[StormcloudVideoPlayer] Failed to hard-reload live stream:", error);
|
|
6988
|
+
}
|
|
6989
|
+
}
|
|
6990
|
+
}
|
|
6991
|
+
},
|
|
6957
6992
|
{
|
|
6958
6993
|
key: "destroy",
|
|
6959
6994
|
value: function destroy() {
|
|
@@ -8273,51 +8308,96 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8273
8308
|
this.host.restartHlsLoad(liveSyncPos);
|
|
8274
8309
|
}
|
|
8275
8310
|
this.resumeContentPlayback();
|
|
8276
|
-
this.monitorLiveResumeStall(
|
|
8311
|
+
this.monitorLiveResumeStall(this.host.video.currentTime);
|
|
8277
8312
|
return;
|
|
8278
8313
|
}
|
|
8279
8314
|
this.resumeContentPlayback();
|
|
8280
8315
|
}
|
|
8281
8316
|
},
|
|
8317
|
+
{
|
|
8318
|
+
key: "getBufferedAhead",
|
|
8319
|
+
value: function getBufferedAhead() {
|
|
8320
|
+
var video = this.host.video;
|
|
8321
|
+
var t = video.currentTime;
|
|
8322
|
+
var ranges = video.buffered;
|
|
8323
|
+
for(var i = 0; i < ranges.length; i++){
|
|
8324
|
+
if (t >= ranges.start(i) - 0.5 && t <= ranges.end(i)) {
|
|
8325
|
+
return ranges.end(i) - t;
|
|
8326
|
+
}
|
|
8327
|
+
}
|
|
8328
|
+
return 0;
|
|
8329
|
+
}
|
|
8330
|
+
},
|
|
8282
8331
|
{
|
|
8283
8332
|
key: "monitorLiveResumeStall",
|
|
8284
|
-
value: function monitorLiveResumeStall(
|
|
8333
|
+
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
8285
8334
|
var _this = this;
|
|
8286
|
-
var
|
|
8287
|
-
var
|
|
8288
|
-
|
|
8335
|
+
var pollIntervalMs = 1e3;
|
|
8336
|
+
var graceMs = 5e3;
|
|
8337
|
+
var recoveryCooldownMs = 5e3;
|
|
8338
|
+
var maxRecoveries = 2;
|
|
8339
|
+
var maxMonitorMs = 3e4;
|
|
8340
|
+
var startTime = Date.now();
|
|
8341
|
+
var baseline = resumeBaseline;
|
|
8342
|
+
var recoveries = 0;
|
|
8343
|
+
var lastRecoveryAt = 0;
|
|
8344
|
+
var poll = function poll1() {
|
|
8289
8345
|
if (_this.inAdBreak) {
|
|
8290
8346
|
return;
|
|
8291
8347
|
}
|
|
8292
|
-
var
|
|
8293
|
-
var
|
|
8294
|
-
|
|
8348
|
+
var video = _this.host.video;
|
|
8349
|
+
var currentTime = video.currentTime;
|
|
8350
|
+
var advanced = currentTime > baseline + 0.5;
|
|
8351
|
+
var playing = !video.paused && video.readyState >= 3;
|
|
8352
|
+
if (advanced && playing) {
|
|
8295
8353
|
if (_this.debug) {
|
|
8296
8354
|
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8297
8355
|
}
|
|
8298
8356
|
return;
|
|
8299
8357
|
}
|
|
8300
|
-
if (
|
|
8301
|
-
|
|
8302
|
-
|
|
8358
|
+
if (video.paused) {
|
|
8359
|
+
var _video_play;
|
|
8360
|
+
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
|
|
8361
|
+
}
|
|
8362
|
+
var elapsed = Date.now() - startTime;
|
|
8363
|
+
var bufferedAhead = _this.getBufferedAhead();
|
|
8364
|
+
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8365
|
+
if (elapsed >= maxMonitorMs) {
|
|
8366
|
+
if (_this.debug && !advanced) {
|
|
8367
|
+
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s (t=").concat(currentTime.toFixed(2), "s, buffered=").concat(bufferedAhead.toFixed(2), "s)"));
|
|
8303
8368
|
}
|
|
8304
8369
|
return;
|
|
8305
8370
|
}
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8371
|
+
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
8372
|
+
if (canRecover) {
|
|
8373
|
+
recoveries++;
|
|
8374
|
+
lastRecoveryAt = Date.now();
|
|
8375
|
+
var isFinalAttempt = recoveries >= maxRecoveries;
|
|
8376
|
+
if (!isFinalAttempt) {
|
|
8377
|
+
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8378
|
+
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8379
|
+
if (_this.debug) {
|
|
8380
|
+
console.warn("[StormcloudVideoPlayer] Content wedged after ad break (t=".concat(currentTime.toFixed(2), "s, buffered=").concat(bufferedAhead.toFixed(2), "s) — restarting HLS load at ").concat(reloadPos.toFixed(2), "s (recovery ").concat(recoveries, "/").concat(maxRecoveries, ")"));
|
|
8381
|
+
}
|
|
8382
|
+
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8383
|
+
video.currentTime = liveSyncPos;
|
|
8384
|
+
}
|
|
8385
|
+
_this.host.restartHlsLoad(reloadPos);
|
|
8386
|
+
} else {
|
|
8387
|
+
if (_this.debug) {
|
|
8388
|
+
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break (t=".concat(currentTime.toFixed(2), "s, buffered=").concat(bufferedAhead.toFixed(2), "s) — hard-reloading live stream (recovery ").concat(recoveries, "/").concat(maxRecoveries, ")"));
|
|
8389
|
+
}
|
|
8390
|
+
_this.host.reloadLiveStream();
|
|
8391
|
+
}
|
|
8392
|
+
baseline = video.currentTime;
|
|
8393
|
+
if (video.paused) {
|
|
8394
|
+
var _video_play1;
|
|
8395
|
+
(_video_play1 = video.play()) === null || _video_play1 === void 0 ? void 0 : _video_play1.catch(function() {});
|
|
8396
|
+
}
|
|
8318
8397
|
}
|
|
8319
|
-
|
|
8320
|
-
}
|
|
8398
|
+
window.setTimeout(poll, pollIntervalMs);
|
|
8399
|
+
};
|
|
8400
|
+
window.setTimeout(poll, pollIntervalMs);
|
|
8321
8401
|
}
|
|
8322
8402
|
},
|
|
8323
8403
|
{
|
|
@@ -8471,6 +8551,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8471
8551
|
restartHlsLoad: function restartHlsLoad(position) {
|
|
8472
8552
|
return _this.hlsEngine.restartLoadAt(position);
|
|
8473
8553
|
},
|
|
8554
|
+
reloadLiveStream: function reloadLiveStream() {
|
|
8555
|
+
return _this.hlsEngine.reloadLiveStream();
|
|
8556
|
+
},
|
|
8474
8557
|
generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
|
|
8475
8558
|
return _this.generatePodVastUrl(base, breakDurationMs);
|
|
8476
8559
|
}
|
|
@@ -8602,6 +8685,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8602
8685
|
return _async_to_generator(function() {
|
|
8603
8686
|
var prerollKey, adBehavior;
|
|
8604
8687
|
return _ts_generator(this, function(_state) {
|
|
8688
|
+
if (this.hlsEngine.reloadingLiveStream) {
|
|
8689
|
+
if (this.debug) {
|
|
8690
|
+
console.log("[StormcloudVideoPlayer] Manifest re-parsed after hard reload \u2014 skipping ad-player setup");
|
|
8691
|
+
}
|
|
8692
|
+
return [
|
|
8693
|
+
2
|
|
8694
|
+
];
|
|
8695
|
+
}
|
|
8605
8696
|
if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
|
|
8606
8697
|
prerollKey = "synthetic-vod-preroll";
|
|
8607
8698
|
if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
|