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.js
CHANGED
|
@@ -1486,7 +1486,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1486
1486
|
}
|
|
1487
1487
|
if (adVideoElement) {
|
|
1488
1488
|
adVideoElement.pause();
|
|
1489
|
-
adVideoElement.src
|
|
1489
|
+
adVideoElement.removeAttribute("src");
|
|
1490
|
+
try {
|
|
1491
|
+
adVideoElement.load();
|
|
1492
|
+
} catch (unused) {}
|
|
1490
1493
|
}
|
|
1491
1494
|
currentAd = void 0;
|
|
1492
1495
|
podAds = [];
|
|
@@ -1532,7 +1535,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1532
1535
|
}
|
|
1533
1536
|
if (adVideoElement) {
|
|
1534
1537
|
adVideoElement.pause();
|
|
1535
|
-
adVideoElement.src
|
|
1538
|
+
adVideoElement.removeAttribute("src");
|
|
1539
|
+
try {
|
|
1540
|
+
adVideoElement.load();
|
|
1541
|
+
} catch (unused) {}
|
|
1536
1542
|
adVideoElement.remove();
|
|
1537
1543
|
adVideoElement = void 0;
|
|
1538
1544
|
}
|
|
@@ -6268,6 +6274,7 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6268
6274
|
this.isLiveStream = false;
|
|
6269
6275
|
this.nativeHlsMode = false;
|
|
6270
6276
|
this.videoSrcProtection = null;
|
|
6277
|
+
this.reloadingLiveStream = false;
|
|
6271
6278
|
this.bufferedSegmentsCount = 0;
|
|
6272
6279
|
this.shouldAutoplayAfterBuffering = false;
|
|
6273
6280
|
this.hasInitialBufferCompleted = false;
|
|
@@ -6401,6 +6408,7 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6401
6408
|
_state.sent();
|
|
6402
6409
|
_state.label = 3;
|
|
6403
6410
|
case 3:
|
|
6411
|
+
this.reloadingLiveStream = false;
|
|
6404
6412
|
return [
|
|
6405
6413
|
2
|
|
6406
6414
|
];
|
|
@@ -6745,6 +6753,33 @@ var HlsEngine = /*#__PURE__*/ function() {
|
|
|
6745
6753
|
}
|
|
6746
6754
|
}
|
|
6747
6755
|
},
|
|
6756
|
+
{
|
|
6757
|
+
key: "reloadLiveStream",
|
|
6758
|
+
value: function reloadLiveStream() {
|
|
6759
|
+
var hls = this.hls;
|
|
6760
|
+
if (!hls) {
|
|
6761
|
+
return;
|
|
6762
|
+
}
|
|
6763
|
+
if (this.debug) {
|
|
6764
|
+
console.log("[StormcloudVideoPlayer] Hard-reloading live stream (detach \u2192 reset video \u2192 re-attach)");
|
|
6765
|
+
}
|
|
6766
|
+
try {
|
|
6767
|
+
this.reloadingLiveStream = true;
|
|
6768
|
+
hls.stopLoad();
|
|
6769
|
+
hls.detachMedia();
|
|
6770
|
+
try {
|
|
6771
|
+
this.video.removeAttribute("src");
|
|
6772
|
+
this.video.load();
|
|
6773
|
+
} catch (unused) {}
|
|
6774
|
+
hls.attachMedia(this.video);
|
|
6775
|
+
} catch (error) {
|
|
6776
|
+
this.reloadingLiveStream = false;
|
|
6777
|
+
if (this.debug) {
|
|
6778
|
+
console.warn("[StormcloudVideoPlayer] Failed to hard-reload live stream:", error);
|
|
6779
|
+
}
|
|
6780
|
+
}
|
|
6781
|
+
}
|
|
6782
|
+
},
|
|
6748
6783
|
{
|
|
6749
6784
|
key: "destroy",
|
|
6750
6785
|
value: function destroy() {
|
|
@@ -8065,51 +8100,96 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8065
8100
|
this.host.restartHlsLoad(liveSyncPos);
|
|
8066
8101
|
}
|
|
8067
8102
|
this.resumeContentPlayback();
|
|
8068
|
-
this.monitorLiveResumeStall(
|
|
8103
|
+
this.monitorLiveResumeStall(this.host.video.currentTime);
|
|
8069
8104
|
return;
|
|
8070
8105
|
}
|
|
8071
8106
|
this.resumeContentPlayback();
|
|
8072
8107
|
}
|
|
8073
8108
|
},
|
|
8109
|
+
{
|
|
8110
|
+
key: "getBufferedAhead",
|
|
8111
|
+
value: function getBufferedAhead() {
|
|
8112
|
+
var video = this.host.video;
|
|
8113
|
+
var t = video.currentTime;
|
|
8114
|
+
var ranges = video.buffered;
|
|
8115
|
+
for(var i = 0; i < ranges.length; i++){
|
|
8116
|
+
if (t >= ranges.start(i) - 0.5 && t <= ranges.end(i)) {
|
|
8117
|
+
return ranges.end(i) - t;
|
|
8118
|
+
}
|
|
8119
|
+
}
|
|
8120
|
+
return 0;
|
|
8121
|
+
}
|
|
8122
|
+
},
|
|
8074
8123
|
{
|
|
8075
8124
|
key: "monitorLiveResumeStall",
|
|
8076
|
-
value: function monitorLiveResumeStall(
|
|
8125
|
+
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
8077
8126
|
var _this = this;
|
|
8078
|
-
var
|
|
8079
|
-
var
|
|
8080
|
-
|
|
8127
|
+
var pollIntervalMs = 1e3;
|
|
8128
|
+
var graceMs = 5e3;
|
|
8129
|
+
var recoveryCooldownMs = 5e3;
|
|
8130
|
+
var maxRecoveries = 2;
|
|
8131
|
+
var maxMonitorMs = 3e4;
|
|
8132
|
+
var startTime = Date.now();
|
|
8133
|
+
var baseline = resumeBaseline;
|
|
8134
|
+
var recoveries = 0;
|
|
8135
|
+
var lastRecoveryAt = 0;
|
|
8136
|
+
var poll = function poll1() {
|
|
8081
8137
|
if (_this.inAdBreak) {
|
|
8082
8138
|
return;
|
|
8083
8139
|
}
|
|
8084
|
-
var
|
|
8085
|
-
var
|
|
8086
|
-
|
|
8140
|
+
var video = _this.host.video;
|
|
8141
|
+
var currentTime = video.currentTime;
|
|
8142
|
+
var advanced = currentTime > baseline + 0.5;
|
|
8143
|
+
var playing = !video.paused && video.readyState >= 3;
|
|
8144
|
+
if (advanced && playing) {
|
|
8087
8145
|
if (_this.debug) {
|
|
8088
8146
|
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8089
8147
|
}
|
|
8090
8148
|
return;
|
|
8091
8149
|
}
|
|
8092
|
-
if (
|
|
8093
|
-
|
|
8094
|
-
|
|
8150
|
+
if (video.paused) {
|
|
8151
|
+
var _video_play;
|
|
8152
|
+
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
|
|
8153
|
+
}
|
|
8154
|
+
var elapsed = Date.now() - startTime;
|
|
8155
|
+
var bufferedAhead = _this.getBufferedAhead();
|
|
8156
|
+
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8157
|
+
if (elapsed >= maxMonitorMs) {
|
|
8158
|
+
if (_this.debug && !advanced) {
|
|
8159
|
+
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)"));
|
|
8095
8160
|
}
|
|
8096
8161
|
return;
|
|
8097
8162
|
}
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8163
|
+
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
8164
|
+
if (canRecover) {
|
|
8165
|
+
recoveries++;
|
|
8166
|
+
lastRecoveryAt = Date.now();
|
|
8167
|
+
var isFinalAttempt = recoveries >= maxRecoveries;
|
|
8168
|
+
if (!isFinalAttempt) {
|
|
8169
|
+
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8170
|
+
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8171
|
+
if (_this.debug) {
|
|
8172
|
+
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, ")"));
|
|
8173
|
+
}
|
|
8174
|
+
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8175
|
+
video.currentTime = liveSyncPos;
|
|
8176
|
+
}
|
|
8177
|
+
_this.host.restartHlsLoad(reloadPos);
|
|
8178
|
+
} else {
|
|
8179
|
+
if (_this.debug) {
|
|
8180
|
+
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, ")"));
|
|
8181
|
+
}
|
|
8182
|
+
_this.host.reloadLiveStream();
|
|
8183
|
+
}
|
|
8184
|
+
baseline = video.currentTime;
|
|
8185
|
+
if (video.paused) {
|
|
8186
|
+
var _video_play1;
|
|
8187
|
+
(_video_play1 = video.play()) === null || _video_play1 === void 0 ? void 0 : _video_play1.catch(function() {});
|
|
8188
|
+
}
|
|
8110
8189
|
}
|
|
8111
|
-
|
|
8112
|
-
}
|
|
8190
|
+
window.setTimeout(poll, pollIntervalMs);
|
|
8191
|
+
};
|
|
8192
|
+
window.setTimeout(poll, pollIntervalMs);
|
|
8113
8193
|
}
|
|
8114
8194
|
},
|
|
8115
8195
|
{
|
|
@@ -8264,6 +8344,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8264
8344
|
restartHlsLoad: function restartHlsLoad(position) {
|
|
8265
8345
|
return _this.hlsEngine.restartLoadAt(position);
|
|
8266
8346
|
},
|
|
8347
|
+
reloadLiveStream: function reloadLiveStream() {
|
|
8348
|
+
return _this.hlsEngine.reloadLiveStream();
|
|
8349
|
+
},
|
|
8267
8350
|
generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
|
|
8268
8351
|
return _this.generatePodVastUrl(base, breakDurationMs);
|
|
8269
8352
|
}
|
|
@@ -8395,6 +8478,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8395
8478
|
return _async_to_generator(function() {
|
|
8396
8479
|
var prerollKey, adBehavior;
|
|
8397
8480
|
return _ts_generator(this, function(_state) {
|
|
8481
|
+
if (this.hlsEngine.reloadingLiveStream) {
|
|
8482
|
+
if (this.debug) {
|
|
8483
|
+
console.log("[StormcloudVideoPlayer] Manifest re-parsed after hard reload \u2014 skipping ad-player setup");
|
|
8484
|
+
}
|
|
8485
|
+
return [
|
|
8486
|
+
2
|
|
8487
|
+
];
|
|
8488
|
+
}
|
|
8398
8489
|
if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
|
|
8399
8490
|
prerollKey = "synthetic-vod-preroll";
|
|
8400
8491
|
if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
|