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/index.js
CHANGED
|
@@ -1243,7 +1243,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1243
1243
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1244
1244
|
if (contentVideo.paused) {
|
|
1245
1245
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
|
|
1246
|
-
contentVideo.play().catch(function() {
|
|
1246
|
+
contentVideo.play().catch(function(error) {
|
|
1247
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode:", error);
|
|
1248
|
+
});
|
|
1247
1249
|
} else {
|
|
1248
1250
|
console.log("[HlsAdPlayer] Content video already playing in live mode");
|
|
1249
1251
|
}
|
|
@@ -1477,7 +1479,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1477
1479
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1478
1480
|
if (contentVideo.paused) {
|
|
1479
1481
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback on stop");
|
|
1480
|
-
contentVideo.play().catch(function() {
|
|
1482
|
+
contentVideo.play().catch(function(error) {
|
|
1483
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode on stop:", error);
|
|
1484
|
+
});
|
|
1481
1485
|
}
|
|
1482
1486
|
}
|
|
1483
1487
|
if (adHls) {
|
|
@@ -8120,6 +8124,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8120
8124
|
return 0;
|
|
8121
8125
|
}
|
|
8122
8126
|
},
|
|
8127
|
+
{
|
|
8128
|
+
key: "describeVideoState",
|
|
8129
|
+
value: function describeVideoState() {
|
|
8130
|
+
var _networkStates_v_networkState, _readyStates_v_readyState;
|
|
8131
|
+
var v = this.host.video;
|
|
8132
|
+
var networkStates = [
|
|
8133
|
+
"EMPTY",
|
|
8134
|
+
"IDLE",
|
|
8135
|
+
"LOADING",
|
|
8136
|
+
"NO_SOURCE"
|
|
8137
|
+
];
|
|
8138
|
+
var readyStates = [
|
|
8139
|
+
"HAVE_NOTHING",
|
|
8140
|
+
"HAVE_METADATA",
|
|
8141
|
+
"HAVE_CURRENT_DATA",
|
|
8142
|
+
"HAVE_FUTURE_DATA",
|
|
8143
|
+
"HAVE_ENOUGH_DATA"
|
|
8144
|
+
];
|
|
8145
|
+
var net = (_networkStates_v_networkState = networkStates[v.networkState]) !== null && _networkStates_v_networkState !== void 0 ? _networkStates_v_networkState : String(v.networkState);
|
|
8146
|
+
var ready = (_readyStates_v_readyState = readyStates[v.readyState]) !== null && _readyStates_v_readyState !== void 0 ? _readyStates_v_readyState : String(v.readyState);
|
|
8147
|
+
var err = v.error ? "code=".concat(v.error.code).concat(v.error.message ? " (".concat(v.error.message, ")") : "") : "none";
|
|
8148
|
+
var ranges = [];
|
|
8149
|
+
for(var i = 0; i < v.buffered.length; i++){
|
|
8150
|
+
ranges.push("[".concat(v.buffered.start(i).toFixed(2), "–").concat(v.buffered.end(i).toFixed(2), "]"));
|
|
8151
|
+
}
|
|
8152
|
+
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");
|
|
8153
|
+
}
|
|
8154
|
+
},
|
|
8123
8155
|
{
|
|
8124
8156
|
key: "monitorLiveResumeStall",
|
|
8125
8157
|
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
@@ -8133,18 +8165,93 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8133
8165
|
var baseline = resumeBaseline;
|
|
8134
8166
|
var recoveries = 0;
|
|
8135
8167
|
var lastRecoveryAt = 0;
|
|
8168
|
+
var video = this.host.video;
|
|
8169
|
+
var listenersAttached = false;
|
|
8170
|
+
var onMediaEvent;
|
|
8171
|
+
var diagEvents = [
|
|
8172
|
+
"loadstart",
|
|
8173
|
+
"loadedmetadata",
|
|
8174
|
+
"loadeddata",
|
|
8175
|
+
"canplay",
|
|
8176
|
+
"canplaythrough",
|
|
8177
|
+
"play",
|
|
8178
|
+
"playing",
|
|
8179
|
+
"pause",
|
|
8180
|
+
"waiting",
|
|
8181
|
+
"stalled",
|
|
8182
|
+
"suspend",
|
|
8183
|
+
"seeking",
|
|
8184
|
+
"seeked",
|
|
8185
|
+
"emptied",
|
|
8186
|
+
"error",
|
|
8187
|
+
"ended"
|
|
8188
|
+
];
|
|
8189
|
+
if (this.debug) {
|
|
8190
|
+
onMediaEvent = function onMediaEvent(e) {
|
|
8191
|
+
var dt = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
8192
|
+
console.log("[ResumeDiag] +".concat(dt, "s event=").concat(e.type, " — ").concat(_this.describeVideoState()));
|
|
8193
|
+
};
|
|
8194
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8195
|
+
try {
|
|
8196
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8197
|
+
var name = _step.value;
|
|
8198
|
+
video.addEventListener(name, onMediaEvent);
|
|
8199
|
+
}
|
|
8200
|
+
} catch (err) {
|
|
8201
|
+
_didIteratorError = true;
|
|
8202
|
+
_iteratorError = err;
|
|
8203
|
+
} finally{
|
|
8204
|
+
try {
|
|
8205
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8206
|
+
_iterator.return();
|
|
8207
|
+
}
|
|
8208
|
+
} finally{
|
|
8209
|
+
if (_didIteratorError) {
|
|
8210
|
+
throw _iteratorError;
|
|
8211
|
+
}
|
|
8212
|
+
}
|
|
8213
|
+
}
|
|
8214
|
+
listenersAttached = true;
|
|
8215
|
+
console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
|
|
8216
|
+
}
|
|
8217
|
+
var cleanup = function cleanup() {
|
|
8218
|
+
if (listenersAttached && onMediaEvent) {
|
|
8219
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8220
|
+
try {
|
|
8221
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8222
|
+
var name = _step.value;
|
|
8223
|
+
video.removeEventListener(name, onMediaEvent);
|
|
8224
|
+
}
|
|
8225
|
+
} catch (err) {
|
|
8226
|
+
_didIteratorError = true;
|
|
8227
|
+
_iteratorError = err;
|
|
8228
|
+
} finally{
|
|
8229
|
+
try {
|
|
8230
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8231
|
+
_iterator.return();
|
|
8232
|
+
}
|
|
8233
|
+
} finally{
|
|
8234
|
+
if (_didIteratorError) {
|
|
8235
|
+
throw _iteratorError;
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
}
|
|
8239
|
+
listenersAttached = false;
|
|
8240
|
+
}
|
|
8241
|
+
};
|
|
8136
8242
|
var poll = function poll1() {
|
|
8137
8243
|
if (_this.inAdBreak) {
|
|
8244
|
+
cleanup();
|
|
8138
8245
|
return;
|
|
8139
8246
|
}
|
|
8140
|
-
var video = _this.host.video;
|
|
8141
8247
|
var currentTime = video.currentTime;
|
|
8142
8248
|
var advanced = currentTime > baseline + 0.5;
|
|
8143
8249
|
var playing = !video.paused && video.readyState >= 3;
|
|
8144
8250
|
if (advanced && playing) {
|
|
8145
8251
|
if (_this.debug) {
|
|
8146
|
-
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8252
|
+
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break — ".concat(_this.describeVideoState()));
|
|
8147
8253
|
}
|
|
8254
|
+
cleanup();
|
|
8148
8255
|
return;
|
|
8149
8256
|
}
|
|
8150
8257
|
if (video.paused) {
|
|
@@ -8156,8 +8263,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8156
8263
|
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8157
8264
|
if (elapsed >= maxMonitorMs) {
|
|
8158
8265
|
if (_this.debug && !advanced) {
|
|
8159
|
-
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s
|
|
8266
|
+
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s — ").concat(_this.describeVideoState()));
|
|
8160
8267
|
}
|
|
8268
|
+
cleanup();
|
|
8161
8269
|
return;
|
|
8162
8270
|
}
|
|
8163
8271
|
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
@@ -8169,7 +8277,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8169
8277
|
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8170
8278
|
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8171
8279
|
if (_this.debug) {
|
|
8172
|
-
console.warn("[StormcloudVideoPlayer] Content wedged after ad break
|
|
8280
|
+
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()));
|
|
8173
8281
|
}
|
|
8174
8282
|
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8175
8283
|
video.currentTime = liveSyncPos;
|
|
@@ -8177,7 +8285,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8177
8285
|
_this.host.restartHlsLoad(reloadPos);
|
|
8178
8286
|
} else {
|
|
8179
8287
|
if (_this.debug) {
|
|
8180
|
-
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break
|
|
8288
|
+
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break — hard-reloading live stream (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
|
|
8181
8289
|
}
|
|
8182
8290
|
_this.host.reloadLiveStream();
|
|
8183
8291
|
}
|