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
|
@@ -61,6 +61,7 @@ declare class AdBreakOrchestrator {
|
|
|
61
61
|
private showPlaceholderAndWaitForAds;
|
|
62
62
|
handleAdPodComplete(): void;
|
|
63
63
|
private getBufferedAhead;
|
|
64
|
+
private describeVideoState;
|
|
64
65
|
private monitorLiveResumeStall;
|
|
65
66
|
private resumeContentPlayback;
|
|
66
67
|
handleAdFailure(): void;
|
|
@@ -1222,7 +1222,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1222
1222
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1223
1223
|
if (contentVideo.paused) {
|
|
1224
1224
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
|
|
1225
|
-
contentVideo.play().catch(function() {
|
|
1225
|
+
contentVideo.play().catch(function(error) {
|
|
1226
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode:", error);
|
|
1227
|
+
});
|
|
1226
1228
|
} else {
|
|
1227
1229
|
console.log("[HlsAdPlayer] Content video already playing in live mode");
|
|
1228
1230
|
}
|
|
@@ -1456,7 +1458,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1456
1458
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1457
1459
|
if (contentVideo.paused) {
|
|
1458
1460
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback on stop");
|
|
1459
|
-
contentVideo.play().catch(function() {
|
|
1461
|
+
contentVideo.play().catch(function(error) {
|
|
1462
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode on stop:", error);
|
|
1463
|
+
});
|
|
1460
1464
|
}
|
|
1461
1465
|
}
|
|
1462
1466
|
if (adHls) {
|
|
@@ -8046,6 +8050,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8046
8050
|
return 0;
|
|
8047
8051
|
}
|
|
8048
8052
|
},
|
|
8053
|
+
{
|
|
8054
|
+
key: "describeVideoState",
|
|
8055
|
+
value: function describeVideoState() {
|
|
8056
|
+
var _networkStates_v_networkState, _readyStates_v_readyState;
|
|
8057
|
+
var v = this.host.video;
|
|
8058
|
+
var networkStates = [
|
|
8059
|
+
"EMPTY",
|
|
8060
|
+
"IDLE",
|
|
8061
|
+
"LOADING",
|
|
8062
|
+
"NO_SOURCE"
|
|
8063
|
+
];
|
|
8064
|
+
var readyStates = [
|
|
8065
|
+
"HAVE_NOTHING",
|
|
8066
|
+
"HAVE_METADATA",
|
|
8067
|
+
"HAVE_CURRENT_DATA",
|
|
8068
|
+
"HAVE_FUTURE_DATA",
|
|
8069
|
+
"HAVE_ENOUGH_DATA"
|
|
8070
|
+
];
|
|
8071
|
+
var net = (_networkStates_v_networkState = networkStates[v.networkState]) !== null && _networkStates_v_networkState !== void 0 ? _networkStates_v_networkState : String(v.networkState);
|
|
8072
|
+
var ready = (_readyStates_v_readyState = readyStates[v.readyState]) !== null && _readyStates_v_readyState !== void 0 ? _readyStates_v_readyState : String(v.readyState);
|
|
8073
|
+
var err = v.error ? "code=".concat(v.error.code).concat(v.error.message ? " (".concat(v.error.message, ")") : "") : "none";
|
|
8074
|
+
var ranges = [];
|
|
8075
|
+
for(var i = 0; i < v.buffered.length; i++){
|
|
8076
|
+
ranges.push("[".concat(v.buffered.start(i).toFixed(2), "–").concat(v.buffered.end(i).toFixed(2), "]"));
|
|
8077
|
+
}
|
|
8078
|
+
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");
|
|
8079
|
+
}
|
|
8080
|
+
},
|
|
8049
8081
|
{
|
|
8050
8082
|
key: "monitorLiveResumeStall",
|
|
8051
8083
|
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
@@ -8059,18 +8091,93 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8059
8091
|
var baseline = resumeBaseline;
|
|
8060
8092
|
var recoveries = 0;
|
|
8061
8093
|
var lastRecoveryAt = 0;
|
|
8094
|
+
var video = this.host.video;
|
|
8095
|
+
var listenersAttached = false;
|
|
8096
|
+
var onMediaEvent;
|
|
8097
|
+
var diagEvents = [
|
|
8098
|
+
"loadstart",
|
|
8099
|
+
"loadedmetadata",
|
|
8100
|
+
"loadeddata",
|
|
8101
|
+
"canplay",
|
|
8102
|
+
"canplaythrough",
|
|
8103
|
+
"play",
|
|
8104
|
+
"playing",
|
|
8105
|
+
"pause",
|
|
8106
|
+
"waiting",
|
|
8107
|
+
"stalled",
|
|
8108
|
+
"suspend",
|
|
8109
|
+
"seeking",
|
|
8110
|
+
"seeked",
|
|
8111
|
+
"emptied",
|
|
8112
|
+
"error",
|
|
8113
|
+
"ended"
|
|
8114
|
+
];
|
|
8115
|
+
if (this.debug) {
|
|
8116
|
+
onMediaEvent = function onMediaEvent(e) {
|
|
8117
|
+
var dt = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
8118
|
+
console.log("[ResumeDiag] +".concat(dt, "s event=").concat(e.type, " — ").concat(_this.describeVideoState()));
|
|
8119
|
+
};
|
|
8120
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8121
|
+
try {
|
|
8122
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8123
|
+
var name = _step.value;
|
|
8124
|
+
video.addEventListener(name, onMediaEvent);
|
|
8125
|
+
}
|
|
8126
|
+
} catch (err) {
|
|
8127
|
+
_didIteratorError = true;
|
|
8128
|
+
_iteratorError = err;
|
|
8129
|
+
} finally{
|
|
8130
|
+
try {
|
|
8131
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8132
|
+
_iterator.return();
|
|
8133
|
+
}
|
|
8134
|
+
} finally{
|
|
8135
|
+
if (_didIteratorError) {
|
|
8136
|
+
throw _iteratorError;
|
|
8137
|
+
}
|
|
8138
|
+
}
|
|
8139
|
+
}
|
|
8140
|
+
listenersAttached = true;
|
|
8141
|
+
console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
|
|
8142
|
+
}
|
|
8143
|
+
var cleanup = function cleanup() {
|
|
8144
|
+
if (listenersAttached && onMediaEvent) {
|
|
8145
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8146
|
+
try {
|
|
8147
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8148
|
+
var name = _step.value;
|
|
8149
|
+
video.removeEventListener(name, onMediaEvent);
|
|
8150
|
+
}
|
|
8151
|
+
} catch (err) {
|
|
8152
|
+
_didIteratorError = true;
|
|
8153
|
+
_iteratorError = err;
|
|
8154
|
+
} finally{
|
|
8155
|
+
try {
|
|
8156
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8157
|
+
_iterator.return();
|
|
8158
|
+
}
|
|
8159
|
+
} finally{
|
|
8160
|
+
if (_didIteratorError) {
|
|
8161
|
+
throw _iteratorError;
|
|
8162
|
+
}
|
|
8163
|
+
}
|
|
8164
|
+
}
|
|
8165
|
+
listenersAttached = false;
|
|
8166
|
+
}
|
|
8167
|
+
};
|
|
8062
8168
|
var poll = function poll1() {
|
|
8063
8169
|
if (_this.inAdBreak) {
|
|
8170
|
+
cleanup();
|
|
8064
8171
|
return;
|
|
8065
8172
|
}
|
|
8066
|
-
var video = _this.host.video;
|
|
8067
8173
|
var currentTime = video.currentTime;
|
|
8068
8174
|
var advanced = currentTime > baseline + 0.5;
|
|
8069
8175
|
var playing = !video.paused && video.readyState >= 3;
|
|
8070
8176
|
if (advanced && playing) {
|
|
8071
8177
|
if (_this.debug) {
|
|
8072
|
-
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8178
|
+
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break — ".concat(_this.describeVideoState()));
|
|
8073
8179
|
}
|
|
8180
|
+
cleanup();
|
|
8074
8181
|
return;
|
|
8075
8182
|
}
|
|
8076
8183
|
if (video.paused) {
|
|
@@ -8082,8 +8189,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8082
8189
|
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8083
8190
|
if (elapsed >= maxMonitorMs) {
|
|
8084
8191
|
if (_this.debug && !advanced) {
|
|
8085
|
-
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s
|
|
8192
|
+
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s — ").concat(_this.describeVideoState()));
|
|
8086
8193
|
}
|
|
8194
|
+
cleanup();
|
|
8087
8195
|
return;
|
|
8088
8196
|
}
|
|
8089
8197
|
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
@@ -8095,7 +8203,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8095
8203
|
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8096
8204
|
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8097
8205
|
if (_this.debug) {
|
|
8098
|
-
console.warn("[StormcloudVideoPlayer] Content wedged after ad break
|
|
8206
|
+
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()));
|
|
8099
8207
|
}
|
|
8100
8208
|
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8101
8209
|
video.currentTime = liveSyncPos;
|
|
@@ -8103,7 +8211,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8103
8211
|
_this.host.restartHlsLoad(reloadPos);
|
|
8104
8212
|
} else {
|
|
8105
8213
|
if (_this.debug) {
|
|
8106
|
-
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break
|
|
8214
|
+
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break — hard-reloading live stream (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
|
|
8107
8215
|
}
|
|
8108
8216
|
_this.host.reloadLiveStream();
|
|
8109
8217
|
}
|