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
|
@@ -1259,7 +1259,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1259
1259
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1260
1260
|
if (contentVideo.paused) {
|
|
1261
1261
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
|
|
1262
|
-
contentVideo.play().catch(function() {
|
|
1262
|
+
contentVideo.play().catch(function(error) {
|
|
1263
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode:", error);
|
|
1264
|
+
});
|
|
1263
1265
|
} else {
|
|
1264
1266
|
console.log("[HlsAdPlayer] Content video already playing in live mode");
|
|
1265
1267
|
}
|
|
@@ -1493,7 +1495,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1493
1495
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1494
1496
|
if (contentVideo.paused) {
|
|
1495
1497
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback on stop");
|
|
1496
|
-
contentVideo.play().catch(function() {
|
|
1498
|
+
contentVideo.play().catch(function(error) {
|
|
1499
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode on stop:", error);
|
|
1500
|
+
});
|
|
1497
1501
|
}
|
|
1498
1502
|
}
|
|
1499
1503
|
if (adHls) {
|
|
@@ -8083,6 +8087,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8083
8087
|
return 0;
|
|
8084
8088
|
}
|
|
8085
8089
|
},
|
|
8090
|
+
{
|
|
8091
|
+
key: "describeVideoState",
|
|
8092
|
+
value: function describeVideoState() {
|
|
8093
|
+
var _networkStates_v_networkState, _readyStates_v_readyState;
|
|
8094
|
+
var v = this.host.video;
|
|
8095
|
+
var networkStates = [
|
|
8096
|
+
"EMPTY",
|
|
8097
|
+
"IDLE",
|
|
8098
|
+
"LOADING",
|
|
8099
|
+
"NO_SOURCE"
|
|
8100
|
+
];
|
|
8101
|
+
var readyStates = [
|
|
8102
|
+
"HAVE_NOTHING",
|
|
8103
|
+
"HAVE_METADATA",
|
|
8104
|
+
"HAVE_CURRENT_DATA",
|
|
8105
|
+
"HAVE_FUTURE_DATA",
|
|
8106
|
+
"HAVE_ENOUGH_DATA"
|
|
8107
|
+
];
|
|
8108
|
+
var net = (_networkStates_v_networkState = networkStates[v.networkState]) !== null && _networkStates_v_networkState !== void 0 ? _networkStates_v_networkState : String(v.networkState);
|
|
8109
|
+
var ready = (_readyStates_v_readyState = readyStates[v.readyState]) !== null && _readyStates_v_readyState !== void 0 ? _readyStates_v_readyState : String(v.readyState);
|
|
8110
|
+
var err = v.error ? "code=".concat(v.error.code).concat(v.error.message ? " (".concat(v.error.message, ")") : "") : "none";
|
|
8111
|
+
var ranges = [];
|
|
8112
|
+
for(var i = 0; i < v.buffered.length; i++){
|
|
8113
|
+
ranges.push("[".concat(v.buffered.start(i).toFixed(2), "–").concat(v.buffered.end(i).toFixed(2), "]"));
|
|
8114
|
+
}
|
|
8115
|
+
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");
|
|
8116
|
+
}
|
|
8117
|
+
},
|
|
8086
8118
|
{
|
|
8087
8119
|
key: "monitorLiveResumeStall",
|
|
8088
8120
|
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
@@ -8096,18 +8128,93 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8096
8128
|
var baseline = resumeBaseline;
|
|
8097
8129
|
var recoveries = 0;
|
|
8098
8130
|
var lastRecoveryAt = 0;
|
|
8131
|
+
var video = this.host.video;
|
|
8132
|
+
var listenersAttached = false;
|
|
8133
|
+
var onMediaEvent;
|
|
8134
|
+
var diagEvents = [
|
|
8135
|
+
"loadstart",
|
|
8136
|
+
"loadedmetadata",
|
|
8137
|
+
"loadeddata",
|
|
8138
|
+
"canplay",
|
|
8139
|
+
"canplaythrough",
|
|
8140
|
+
"play",
|
|
8141
|
+
"playing",
|
|
8142
|
+
"pause",
|
|
8143
|
+
"waiting",
|
|
8144
|
+
"stalled",
|
|
8145
|
+
"suspend",
|
|
8146
|
+
"seeking",
|
|
8147
|
+
"seeked",
|
|
8148
|
+
"emptied",
|
|
8149
|
+
"error",
|
|
8150
|
+
"ended"
|
|
8151
|
+
];
|
|
8152
|
+
if (this.debug) {
|
|
8153
|
+
onMediaEvent = function onMediaEvent(e) {
|
|
8154
|
+
var dt = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
8155
|
+
console.log("[ResumeDiag] +".concat(dt, "s event=").concat(e.type, " — ").concat(_this.describeVideoState()));
|
|
8156
|
+
};
|
|
8157
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8158
|
+
try {
|
|
8159
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8160
|
+
var name = _step.value;
|
|
8161
|
+
video.addEventListener(name, onMediaEvent);
|
|
8162
|
+
}
|
|
8163
|
+
} catch (err) {
|
|
8164
|
+
_didIteratorError = true;
|
|
8165
|
+
_iteratorError = err;
|
|
8166
|
+
} finally{
|
|
8167
|
+
try {
|
|
8168
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8169
|
+
_iterator.return();
|
|
8170
|
+
}
|
|
8171
|
+
} finally{
|
|
8172
|
+
if (_didIteratorError) {
|
|
8173
|
+
throw _iteratorError;
|
|
8174
|
+
}
|
|
8175
|
+
}
|
|
8176
|
+
}
|
|
8177
|
+
listenersAttached = true;
|
|
8178
|
+
console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
|
|
8179
|
+
}
|
|
8180
|
+
var cleanup = function cleanup() {
|
|
8181
|
+
if (listenersAttached && onMediaEvent) {
|
|
8182
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8183
|
+
try {
|
|
8184
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8185
|
+
var name = _step.value;
|
|
8186
|
+
video.removeEventListener(name, onMediaEvent);
|
|
8187
|
+
}
|
|
8188
|
+
} catch (err) {
|
|
8189
|
+
_didIteratorError = true;
|
|
8190
|
+
_iteratorError = err;
|
|
8191
|
+
} finally{
|
|
8192
|
+
try {
|
|
8193
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8194
|
+
_iterator.return();
|
|
8195
|
+
}
|
|
8196
|
+
} finally{
|
|
8197
|
+
if (_didIteratorError) {
|
|
8198
|
+
throw _iteratorError;
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
}
|
|
8202
|
+
listenersAttached = false;
|
|
8203
|
+
}
|
|
8204
|
+
};
|
|
8099
8205
|
var poll = function poll1() {
|
|
8100
8206
|
if (_this.inAdBreak) {
|
|
8207
|
+
cleanup();
|
|
8101
8208
|
return;
|
|
8102
8209
|
}
|
|
8103
|
-
var video = _this.host.video;
|
|
8104
8210
|
var currentTime = video.currentTime;
|
|
8105
8211
|
var advanced = currentTime > baseline + 0.5;
|
|
8106
8212
|
var playing = !video.paused && video.readyState >= 3;
|
|
8107
8213
|
if (advanced && playing) {
|
|
8108
8214
|
if (_this.debug) {
|
|
8109
|
-
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8215
|
+
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break — ".concat(_this.describeVideoState()));
|
|
8110
8216
|
}
|
|
8217
|
+
cleanup();
|
|
8111
8218
|
return;
|
|
8112
8219
|
}
|
|
8113
8220
|
if (video.paused) {
|
|
@@ -8119,8 +8226,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8119
8226
|
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8120
8227
|
if (elapsed >= maxMonitorMs) {
|
|
8121
8228
|
if (_this.debug && !advanced) {
|
|
8122
|
-
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s
|
|
8229
|
+
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s — ").concat(_this.describeVideoState()));
|
|
8123
8230
|
}
|
|
8231
|
+
cleanup();
|
|
8124
8232
|
return;
|
|
8125
8233
|
}
|
|
8126
8234
|
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
@@ -8132,7 +8240,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8132
8240
|
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8133
8241
|
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8134
8242
|
if (_this.debug) {
|
|
8135
|
-
console.warn("[StormcloudVideoPlayer] Content wedged after ad break
|
|
8243
|
+
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()));
|
|
8136
8244
|
}
|
|
8137
8245
|
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8138
8246
|
video.currentTime = liveSyncPos;
|
|
@@ -8140,7 +8248,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8140
8248
|
_this.host.restartHlsLoad(reloadPos);
|
|
8141
8249
|
} else {
|
|
8142
8250
|
if (_this.debug) {
|
|
8143
|
-
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break
|
|
8251
|
+
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break — hard-reloading live stream (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
|
|
8144
8252
|
}
|
|
8145
8253
|
_this.host.reloadLiveStream();
|
|
8146
8254
|
}
|