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/players/index.cjs
CHANGED
|
@@ -1552,7 +1552,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1552
1552
|
}
|
|
1553
1553
|
if (adVideoElement) {
|
|
1554
1554
|
adVideoElement.pause();
|
|
1555
|
-
adVideoElement.src
|
|
1555
|
+
adVideoElement.removeAttribute("src");
|
|
1556
|
+
try {
|
|
1557
|
+
adVideoElement.load();
|
|
1558
|
+
} catch (unused) {}
|
|
1556
1559
|
}
|
|
1557
1560
|
currentAd = void 0;
|
|
1558
1561
|
podAds = [];
|
|
@@ -1598,7 +1601,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1598
1601
|
}
|
|
1599
1602
|
if (adVideoElement) {
|
|
1600
1603
|
adVideoElement.pause();
|
|
1601
|
-
adVideoElement.src
|
|
1604
|
+
adVideoElement.removeAttribute("src");
|
|
1605
|
+
try {
|
|
1606
|
+
adVideoElement.load();
|
|
1607
|
+
} catch (unused) {}
|
|
1602
1608
|
adVideoElement.remove();
|
|
1603
1609
|
adVideoElement = void 0;
|
|
1604
1610
|
}
|
|
@@ -6282,6 +6288,7 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6282
6288
|
this.isLiveStream = false;
|
|
6283
6289
|
this.nativeHlsMode = false;
|
|
6284
6290
|
this.videoSrcProtection = null;
|
|
6291
|
+
this.reloadingLiveStream = false;
|
|
6285
6292
|
this.bufferedSegmentsCount = 0;
|
|
6286
6293
|
this.shouldAutoplayAfterBuffering = false;
|
|
6287
6294
|
this.hasInitialBufferCompleted = false;
|
|
@@ -6415,6 +6422,7 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6415
6422
|
_state.sent();
|
|
6416
6423
|
_state.label = 3;
|
|
6417
6424
|
case 3:
|
|
6425
|
+
this.reloadingLiveStream = false;
|
|
6418
6426
|
return [
|
|
6419
6427
|
2
|
|
6420
6428
|
];
|
|
@@ -6759,6 +6767,33 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6759
6767
|
}
|
|
6760
6768
|
}
|
|
6761
6769
|
},
|
|
6770
|
+
{
|
|
6771
|
+
key: "reloadLiveStream",
|
|
6772
|
+
value: function reloadLiveStream() {
|
|
6773
|
+
var hls = this.hls;
|
|
6774
|
+
if (!hls) {
|
|
6775
|
+
return;
|
|
6776
|
+
}
|
|
6777
|
+
if (this.debug) {
|
|
6778
|
+
console.log("[StormcloudVideoPlayer] Hard-reloading live stream (detach \u2192 reset video \u2192 re-attach)");
|
|
6779
|
+
}
|
|
6780
|
+
try {
|
|
6781
|
+
this.reloadingLiveStream = true;
|
|
6782
|
+
hls.stopLoad();
|
|
6783
|
+
hls.detachMedia();
|
|
6784
|
+
try {
|
|
6785
|
+
this.video.removeAttribute("src");
|
|
6786
|
+
this.video.load();
|
|
6787
|
+
} catch (unused) {}
|
|
6788
|
+
hls.attachMedia(this.video);
|
|
6789
|
+
} catch (error) {
|
|
6790
|
+
this.reloadingLiveStream = false;
|
|
6791
|
+
if (this.debug) {
|
|
6792
|
+
console.warn("[StormcloudVideoPlayer] Failed to hard-reload live stream:", error);
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6795
|
+
}
|
|
6796
|
+
},
|
|
6762
6797
|
{
|
|
6763
6798
|
key: "destroy",
|
|
6764
6799
|
value: function destroy() {
|
|
@@ -8078,51 +8113,96 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8078
8113
|
this.host.restartHlsLoad(liveSyncPos);
|
|
8079
8114
|
}
|
|
8080
8115
|
this.resumeContentPlayback();
|
|
8081
|
-
this.monitorLiveResumeStall(
|
|
8116
|
+
this.monitorLiveResumeStall(this.host.video.currentTime);
|
|
8082
8117
|
return;
|
|
8083
8118
|
}
|
|
8084
8119
|
this.resumeContentPlayback();
|
|
8085
8120
|
}
|
|
8086
8121
|
},
|
|
8122
|
+
{
|
|
8123
|
+
key: "getBufferedAhead",
|
|
8124
|
+
value: function getBufferedAhead() {
|
|
8125
|
+
var video = this.host.video;
|
|
8126
|
+
var t = video.currentTime;
|
|
8127
|
+
var ranges = video.buffered;
|
|
8128
|
+
for(var i = 0; i < ranges.length; i++){
|
|
8129
|
+
if (t >= ranges.start(i) - 0.5 && t <= ranges.end(i)) {
|
|
8130
|
+
return ranges.end(i) - t;
|
|
8131
|
+
}
|
|
8132
|
+
}
|
|
8133
|
+
return 0;
|
|
8134
|
+
}
|
|
8135
|
+
},
|
|
8087
8136
|
{
|
|
8088
8137
|
key: "monitorLiveResumeStall",
|
|
8089
|
-
value: function monitorLiveResumeStall(
|
|
8138
|
+
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
8090
8139
|
var _this = this;
|
|
8091
|
-
var
|
|
8092
|
-
var
|
|
8093
|
-
|
|
8140
|
+
var pollIntervalMs = 1e3;
|
|
8141
|
+
var graceMs = 5e3;
|
|
8142
|
+
var recoveryCooldownMs = 5e3;
|
|
8143
|
+
var maxRecoveries = 2;
|
|
8144
|
+
var maxMonitorMs = 3e4;
|
|
8145
|
+
var startTime = Date.now();
|
|
8146
|
+
var baseline = resumeBaseline;
|
|
8147
|
+
var recoveries = 0;
|
|
8148
|
+
var lastRecoveryAt = 0;
|
|
8149
|
+
var poll = function poll1() {
|
|
8094
8150
|
if (_this.inAdBreak) {
|
|
8095
8151
|
return;
|
|
8096
8152
|
}
|
|
8097
|
-
var
|
|
8098
|
-
var
|
|
8099
|
-
|
|
8153
|
+
var video = _this.host.video;
|
|
8154
|
+
var currentTime = video.currentTime;
|
|
8155
|
+
var advanced = currentTime > baseline + 0.5;
|
|
8156
|
+
var playing = !video.paused && video.readyState >= 3;
|
|
8157
|
+
if (advanced && playing) {
|
|
8100
8158
|
if (_this.debug) {
|
|
8101
8159
|
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8102
8160
|
}
|
|
8103
8161
|
return;
|
|
8104
8162
|
}
|
|
8105
|
-
if (
|
|
8106
|
-
|
|
8107
|
-
|
|
8163
|
+
if (video.paused) {
|
|
8164
|
+
var _video_play;
|
|
8165
|
+
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
|
|
8166
|
+
}
|
|
8167
|
+
var elapsed = Date.now() - startTime;
|
|
8168
|
+
var bufferedAhead = _this.getBufferedAhead();
|
|
8169
|
+
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8170
|
+
if (elapsed >= maxMonitorMs) {
|
|
8171
|
+
if (_this.debug && !advanced) {
|
|
8172
|
+
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)"));
|
|
8108
8173
|
}
|
|
8109
8174
|
return;
|
|
8110
8175
|
}
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8176
|
+
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
8177
|
+
if (canRecover) {
|
|
8178
|
+
recoveries++;
|
|
8179
|
+
lastRecoveryAt = Date.now();
|
|
8180
|
+
var isFinalAttempt = recoveries >= maxRecoveries;
|
|
8181
|
+
if (!isFinalAttempt) {
|
|
8182
|
+
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8183
|
+
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8184
|
+
if (_this.debug) {
|
|
8185
|
+
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, ")"));
|
|
8186
|
+
}
|
|
8187
|
+
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8188
|
+
video.currentTime = liveSyncPos;
|
|
8189
|
+
}
|
|
8190
|
+
_this.host.restartHlsLoad(reloadPos);
|
|
8191
|
+
} else {
|
|
8192
|
+
if (_this.debug) {
|
|
8193
|
+
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, ")"));
|
|
8194
|
+
}
|
|
8195
|
+
_this.host.reloadLiveStream();
|
|
8196
|
+
}
|
|
8197
|
+
baseline = video.currentTime;
|
|
8198
|
+
if (video.paused) {
|
|
8199
|
+
var _video_play1;
|
|
8200
|
+
(_video_play1 = video.play()) === null || _video_play1 === void 0 ? void 0 : _video_play1.catch(function() {});
|
|
8201
|
+
}
|
|
8123
8202
|
}
|
|
8124
|
-
|
|
8125
|
-
}
|
|
8203
|
+
window.setTimeout(poll, pollIntervalMs);
|
|
8204
|
+
};
|
|
8205
|
+
window.setTimeout(poll, pollIntervalMs);
|
|
8126
8206
|
}
|
|
8127
8207
|
},
|
|
8128
8208
|
{
|
|
@@ -8276,6 +8356,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8276
8356
|
restartHlsLoad: function restartHlsLoad(position) {
|
|
8277
8357
|
return _this.hlsEngine.restartLoadAt(position);
|
|
8278
8358
|
},
|
|
8359
|
+
reloadLiveStream: function reloadLiveStream() {
|
|
8360
|
+
return _this.hlsEngine.reloadLiveStream();
|
|
8361
|
+
},
|
|
8279
8362
|
generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
|
|
8280
8363
|
return _this.generatePodVastUrl(base, breakDurationMs);
|
|
8281
8364
|
}
|
|
@@ -8407,6 +8490,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8407
8490
|
return _async_to_generator(function() {
|
|
8408
8491
|
var prerollKey, adBehavior;
|
|
8409
8492
|
return _ts_generator(this, function(_state) {
|
|
8493
|
+
if (this.hlsEngine.reloadingLiveStream) {
|
|
8494
|
+
if (this.debug) {
|
|
8495
|
+
console.log("[StormcloudVideoPlayer] Manifest re-parsed after hard reload \u2014 skipping ad-player setup");
|
|
8496
|
+
}
|
|
8497
|
+
return [
|
|
8498
|
+
2
|
|
8499
|
+
];
|
|
8500
|
+
}
|
|
8410
8501
|
if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
|
|
8411
8502
|
prerollKey = "synthetic-vod-preroll";
|
|
8412
8503
|
if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
|