stormcloud-video-player 0.8.43 → 0.8.45
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 +115 -7
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +115 -7
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +109 -5
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +1 -0
- package/lib/player/StormcloudVideoPlayer.cjs +115 -7
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +115 -7
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +115 -7
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +6 -2
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +115 -7
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -1309,7 +1309,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1309
1309
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1310
1310
|
if (contentVideo.paused) {
|
|
1311
1311
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
|
|
1312
|
-
contentVideo.play().catch(function() {
|
|
1312
|
+
contentVideo.play().catch(function(error) {
|
|
1313
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode:", error);
|
|
1314
|
+
});
|
|
1313
1315
|
} else {
|
|
1314
1316
|
console.log("[HlsAdPlayer] Content video already playing in live mode");
|
|
1315
1317
|
}
|
|
@@ -1543,7 +1545,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1543
1545
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1544
1546
|
if (contentVideo.paused) {
|
|
1545
1547
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback on stop");
|
|
1546
|
-
contentVideo.play().catch(function() {
|
|
1548
|
+
contentVideo.play().catch(function(error) {
|
|
1549
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode on stop:", error);
|
|
1550
|
+
});
|
|
1547
1551
|
}
|
|
1548
1552
|
}
|
|
1549
1553
|
if (adHls) {
|
|
@@ -8133,6 +8137,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8133
8137
|
return 0;
|
|
8134
8138
|
}
|
|
8135
8139
|
},
|
|
8140
|
+
{
|
|
8141
|
+
key: "describeVideoState",
|
|
8142
|
+
value: function describeVideoState() {
|
|
8143
|
+
var _networkStates_v_networkState, _readyStates_v_readyState;
|
|
8144
|
+
var v = this.host.video;
|
|
8145
|
+
var networkStates = [
|
|
8146
|
+
"EMPTY",
|
|
8147
|
+
"IDLE",
|
|
8148
|
+
"LOADING",
|
|
8149
|
+
"NO_SOURCE"
|
|
8150
|
+
];
|
|
8151
|
+
var readyStates = [
|
|
8152
|
+
"HAVE_NOTHING",
|
|
8153
|
+
"HAVE_METADATA",
|
|
8154
|
+
"HAVE_CURRENT_DATA",
|
|
8155
|
+
"HAVE_FUTURE_DATA",
|
|
8156
|
+
"HAVE_ENOUGH_DATA"
|
|
8157
|
+
];
|
|
8158
|
+
var net = (_networkStates_v_networkState = networkStates[v.networkState]) !== null && _networkStates_v_networkState !== void 0 ? _networkStates_v_networkState : String(v.networkState);
|
|
8159
|
+
var ready = (_readyStates_v_readyState = readyStates[v.readyState]) !== null && _readyStates_v_readyState !== void 0 ? _readyStates_v_readyState : String(v.readyState);
|
|
8160
|
+
var err = v.error ? "code=".concat(v.error.code).concat(v.error.message ? " (".concat(v.error.message, ")") : "") : "none";
|
|
8161
|
+
var ranges = [];
|
|
8162
|
+
for(var i = 0; i < v.buffered.length; i++){
|
|
8163
|
+
ranges.push("[".concat(v.buffered.start(i).toFixed(2), "–").concat(v.buffered.end(i).toFixed(2), "]"));
|
|
8164
|
+
}
|
|
8165
|
+
return "t=".concat(v.currentTime.toFixed(2), "s paused=").concat(v.paused, " ended=").concat(v.ended, " seeking=").concat(v.seeking, " readyState=").concat(ready, " networkState=").concat(net, " error=").concat(err, " buffered=").concat(ranges.length ? ranges.join(",") : "none");
|
|
8166
|
+
}
|
|
8167
|
+
},
|
|
8136
8168
|
{
|
|
8137
8169
|
key: "monitorLiveResumeStall",
|
|
8138
8170
|
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
@@ -8146,18 +8178,93 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8146
8178
|
var baseline = resumeBaseline;
|
|
8147
8179
|
var recoveries = 0;
|
|
8148
8180
|
var lastRecoveryAt = 0;
|
|
8181
|
+
var video = this.host.video;
|
|
8182
|
+
var listenersAttached = false;
|
|
8183
|
+
var onMediaEvent;
|
|
8184
|
+
var diagEvents = [
|
|
8185
|
+
"loadstart",
|
|
8186
|
+
"loadedmetadata",
|
|
8187
|
+
"loadeddata",
|
|
8188
|
+
"canplay",
|
|
8189
|
+
"canplaythrough",
|
|
8190
|
+
"play",
|
|
8191
|
+
"playing",
|
|
8192
|
+
"pause",
|
|
8193
|
+
"waiting",
|
|
8194
|
+
"stalled",
|
|
8195
|
+
"suspend",
|
|
8196
|
+
"seeking",
|
|
8197
|
+
"seeked",
|
|
8198
|
+
"emptied",
|
|
8199
|
+
"error",
|
|
8200
|
+
"ended"
|
|
8201
|
+
];
|
|
8202
|
+
if (this.debug) {
|
|
8203
|
+
onMediaEvent = function onMediaEvent(e) {
|
|
8204
|
+
var dt = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
8205
|
+
console.log("[ResumeDiag] +".concat(dt, "s event=").concat(e.type, " — ").concat(_this.describeVideoState()));
|
|
8206
|
+
};
|
|
8207
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8208
|
+
try {
|
|
8209
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8210
|
+
var name = _step.value;
|
|
8211
|
+
video.addEventListener(name, onMediaEvent);
|
|
8212
|
+
}
|
|
8213
|
+
} catch (err) {
|
|
8214
|
+
_didIteratorError = true;
|
|
8215
|
+
_iteratorError = err;
|
|
8216
|
+
} finally{
|
|
8217
|
+
try {
|
|
8218
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8219
|
+
_iterator.return();
|
|
8220
|
+
}
|
|
8221
|
+
} finally{
|
|
8222
|
+
if (_didIteratorError) {
|
|
8223
|
+
throw _iteratorError;
|
|
8224
|
+
}
|
|
8225
|
+
}
|
|
8226
|
+
}
|
|
8227
|
+
listenersAttached = true;
|
|
8228
|
+
console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
|
|
8229
|
+
}
|
|
8230
|
+
var cleanup = function cleanup() {
|
|
8231
|
+
if (listenersAttached && onMediaEvent) {
|
|
8232
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8233
|
+
try {
|
|
8234
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8235
|
+
var name = _step.value;
|
|
8236
|
+
video.removeEventListener(name, onMediaEvent);
|
|
8237
|
+
}
|
|
8238
|
+
} catch (err) {
|
|
8239
|
+
_didIteratorError = true;
|
|
8240
|
+
_iteratorError = err;
|
|
8241
|
+
} finally{
|
|
8242
|
+
try {
|
|
8243
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8244
|
+
_iterator.return();
|
|
8245
|
+
}
|
|
8246
|
+
} finally{
|
|
8247
|
+
if (_didIteratorError) {
|
|
8248
|
+
throw _iteratorError;
|
|
8249
|
+
}
|
|
8250
|
+
}
|
|
8251
|
+
}
|
|
8252
|
+
listenersAttached = false;
|
|
8253
|
+
}
|
|
8254
|
+
};
|
|
8149
8255
|
var poll = function poll1() {
|
|
8150
8256
|
if (_this.inAdBreak) {
|
|
8257
|
+
cleanup();
|
|
8151
8258
|
return;
|
|
8152
8259
|
}
|
|
8153
|
-
var video = _this.host.video;
|
|
8154
8260
|
var currentTime = video.currentTime;
|
|
8155
8261
|
var advanced = currentTime > baseline + 0.5;
|
|
8156
8262
|
var playing = !video.paused && video.readyState >= 3;
|
|
8157
8263
|
if (advanced && playing) {
|
|
8158
8264
|
if (_this.debug) {
|
|
8159
|
-
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8265
|
+
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break — ".concat(_this.describeVideoState()));
|
|
8160
8266
|
}
|
|
8267
|
+
cleanup();
|
|
8161
8268
|
return;
|
|
8162
8269
|
}
|
|
8163
8270
|
if (video.paused) {
|
|
@@ -8169,8 +8276,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8169
8276
|
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8170
8277
|
if (elapsed >= maxMonitorMs) {
|
|
8171
8278
|
if (_this.debug && !advanced) {
|
|
8172
|
-
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s
|
|
8279
|
+
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s — ").concat(_this.describeVideoState()));
|
|
8173
8280
|
}
|
|
8281
|
+
cleanup();
|
|
8174
8282
|
return;
|
|
8175
8283
|
}
|
|
8176
8284
|
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
@@ -8182,7 +8290,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8182
8290
|
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8183
8291
|
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8184
8292
|
if (_this.debug) {
|
|
8185
|
-
console.warn("[StormcloudVideoPlayer] Content wedged after ad break
|
|
8293
|
+
console.warn("[StormcloudVideoPlayer] Content wedged after ad break — restarting HLS load at ".concat(reloadPos.toFixed(2), "s (recovery ").concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
|
|
8186
8294
|
}
|
|
8187
8295
|
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8188
8296
|
video.currentTime = liveSyncPos;
|
|
@@ -8190,7 +8298,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8190
8298
|
_this.host.restartHlsLoad(reloadPos);
|
|
8191
8299
|
} else {
|
|
8192
8300
|
if (_this.debug) {
|
|
8193
|
-
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break
|
|
8301
|
+
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break — hard-reloading live stream (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
|
|
8194
8302
|
}
|
|
8195
8303
|
_this.host.reloadLiveStream();
|
|
8196
8304
|
}
|