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.cjs
CHANGED
|
@@ -1460,7 +1460,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1460
1460
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1461
1461
|
if (contentVideo.paused) {
|
|
1462
1462
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
|
|
1463
|
-
contentVideo.play().catch(function() {
|
|
1463
|
+
contentVideo.play().catch(function(error) {
|
|
1464
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode:", error);
|
|
1465
|
+
});
|
|
1464
1466
|
} else {
|
|
1465
1467
|
console.log("[HlsAdPlayer] Content video already playing in live mode");
|
|
1466
1468
|
}
|
|
@@ -1694,7 +1696,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1694
1696
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1695
1697
|
if (contentVideo.paused) {
|
|
1696
1698
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback on stop");
|
|
1697
|
-
contentVideo.play().catch(function() {
|
|
1699
|
+
contentVideo.play().catch(function(error) {
|
|
1700
|
+
console.error("[HlsAdPlayer] Error resuming content playback in live mode on stop:", error);
|
|
1701
|
+
});
|
|
1698
1702
|
}
|
|
1699
1703
|
}
|
|
1700
1704
|
if (adHls) {
|
|
@@ -8328,6 +8332,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8328
8332
|
return 0;
|
|
8329
8333
|
}
|
|
8330
8334
|
},
|
|
8335
|
+
{
|
|
8336
|
+
key: "describeVideoState",
|
|
8337
|
+
value: function describeVideoState() {
|
|
8338
|
+
var _networkStates_v_networkState, _readyStates_v_readyState;
|
|
8339
|
+
var v = this.host.video;
|
|
8340
|
+
var networkStates = [
|
|
8341
|
+
"EMPTY",
|
|
8342
|
+
"IDLE",
|
|
8343
|
+
"LOADING",
|
|
8344
|
+
"NO_SOURCE"
|
|
8345
|
+
];
|
|
8346
|
+
var readyStates = [
|
|
8347
|
+
"HAVE_NOTHING",
|
|
8348
|
+
"HAVE_METADATA",
|
|
8349
|
+
"HAVE_CURRENT_DATA",
|
|
8350
|
+
"HAVE_FUTURE_DATA",
|
|
8351
|
+
"HAVE_ENOUGH_DATA"
|
|
8352
|
+
];
|
|
8353
|
+
var net = (_networkStates_v_networkState = networkStates[v.networkState]) !== null && _networkStates_v_networkState !== void 0 ? _networkStates_v_networkState : String(v.networkState);
|
|
8354
|
+
var ready = (_readyStates_v_readyState = readyStates[v.readyState]) !== null && _readyStates_v_readyState !== void 0 ? _readyStates_v_readyState : String(v.readyState);
|
|
8355
|
+
var err = v.error ? "code=".concat(v.error.code).concat(v.error.message ? " (".concat(v.error.message, ")") : "") : "none";
|
|
8356
|
+
var ranges = [];
|
|
8357
|
+
for(var i = 0; i < v.buffered.length; i++){
|
|
8358
|
+
ranges.push("[".concat(v.buffered.start(i).toFixed(2), "–").concat(v.buffered.end(i).toFixed(2), "]"));
|
|
8359
|
+
}
|
|
8360
|
+
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");
|
|
8361
|
+
}
|
|
8362
|
+
},
|
|
8331
8363
|
{
|
|
8332
8364
|
key: "monitorLiveResumeStall",
|
|
8333
8365
|
value: function monitorLiveResumeStall(resumeBaseline) {
|
|
@@ -8341,18 +8373,93 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8341
8373
|
var baseline = resumeBaseline;
|
|
8342
8374
|
var recoveries = 0;
|
|
8343
8375
|
var lastRecoveryAt = 0;
|
|
8376
|
+
var video = this.host.video;
|
|
8377
|
+
var listenersAttached = false;
|
|
8378
|
+
var onMediaEvent;
|
|
8379
|
+
var diagEvents = [
|
|
8380
|
+
"loadstart",
|
|
8381
|
+
"loadedmetadata",
|
|
8382
|
+
"loadeddata",
|
|
8383
|
+
"canplay",
|
|
8384
|
+
"canplaythrough",
|
|
8385
|
+
"play",
|
|
8386
|
+
"playing",
|
|
8387
|
+
"pause",
|
|
8388
|
+
"waiting",
|
|
8389
|
+
"stalled",
|
|
8390
|
+
"suspend",
|
|
8391
|
+
"seeking",
|
|
8392
|
+
"seeked",
|
|
8393
|
+
"emptied",
|
|
8394
|
+
"error",
|
|
8395
|
+
"ended"
|
|
8396
|
+
];
|
|
8397
|
+
if (this.debug) {
|
|
8398
|
+
onMediaEvent = function onMediaEvent(e) {
|
|
8399
|
+
var dt = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
8400
|
+
console.log("[ResumeDiag] +".concat(dt, "s event=").concat(e.type, " — ").concat(_this.describeVideoState()));
|
|
8401
|
+
};
|
|
8402
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8403
|
+
try {
|
|
8404
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8405
|
+
var name = _step.value;
|
|
8406
|
+
video.addEventListener(name, onMediaEvent);
|
|
8407
|
+
}
|
|
8408
|
+
} catch (err) {
|
|
8409
|
+
_didIteratorError = true;
|
|
8410
|
+
_iteratorError = err;
|
|
8411
|
+
} finally{
|
|
8412
|
+
try {
|
|
8413
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8414
|
+
_iterator.return();
|
|
8415
|
+
}
|
|
8416
|
+
} finally{
|
|
8417
|
+
if (_didIteratorError) {
|
|
8418
|
+
throw _iteratorError;
|
|
8419
|
+
}
|
|
8420
|
+
}
|
|
8421
|
+
}
|
|
8422
|
+
listenersAttached = true;
|
|
8423
|
+
console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
|
|
8424
|
+
}
|
|
8425
|
+
var cleanup = function cleanup() {
|
|
8426
|
+
if (listenersAttached && onMediaEvent) {
|
|
8427
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8428
|
+
try {
|
|
8429
|
+
for(var _iterator = diagEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8430
|
+
var name = _step.value;
|
|
8431
|
+
video.removeEventListener(name, onMediaEvent);
|
|
8432
|
+
}
|
|
8433
|
+
} catch (err) {
|
|
8434
|
+
_didIteratorError = true;
|
|
8435
|
+
_iteratorError = err;
|
|
8436
|
+
} finally{
|
|
8437
|
+
try {
|
|
8438
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8439
|
+
_iterator.return();
|
|
8440
|
+
}
|
|
8441
|
+
} finally{
|
|
8442
|
+
if (_didIteratorError) {
|
|
8443
|
+
throw _iteratorError;
|
|
8444
|
+
}
|
|
8445
|
+
}
|
|
8446
|
+
}
|
|
8447
|
+
listenersAttached = false;
|
|
8448
|
+
}
|
|
8449
|
+
};
|
|
8344
8450
|
var poll = function poll1() {
|
|
8345
8451
|
if (_this.inAdBreak) {
|
|
8452
|
+
cleanup();
|
|
8346
8453
|
return;
|
|
8347
8454
|
}
|
|
8348
|
-
var video = _this.host.video;
|
|
8349
8455
|
var currentTime = video.currentTime;
|
|
8350
8456
|
var advanced = currentTime > baseline + 0.5;
|
|
8351
8457
|
var playing = !video.paused && video.readyState >= 3;
|
|
8352
8458
|
if (advanced && playing) {
|
|
8353
8459
|
if (_this.debug) {
|
|
8354
|
-
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
|
|
8460
|
+
console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break — ".concat(_this.describeVideoState()));
|
|
8355
8461
|
}
|
|
8462
|
+
cleanup();
|
|
8356
8463
|
return;
|
|
8357
8464
|
}
|
|
8358
8465
|
if (video.paused) {
|
|
@@ -8364,8 +8471,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8364
8471
|
var wedged = bufferedAhead < 0.5 && !advanced;
|
|
8365
8472
|
if (elapsed >= maxMonitorMs) {
|
|
8366
8473
|
if (_this.debug && !advanced) {
|
|
8367
|
-
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s
|
|
8474
|
+
console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat((maxMonitorMs / 1e3).toFixed(0), "s — ").concat(_this.describeVideoState()));
|
|
8368
8475
|
}
|
|
8476
|
+
cleanup();
|
|
8369
8477
|
return;
|
|
8370
8478
|
}
|
|
8371
8479
|
var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
|
|
@@ -8377,7 +8485,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8377
8485
|
var liveSyncPos = _this.host.getLiveSyncPosition();
|
|
8378
8486
|
var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
|
|
8379
8487
|
if (_this.debug) {
|
|
8380
|
-
console.warn("[StormcloudVideoPlayer] Content wedged after ad break
|
|
8488
|
+
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()));
|
|
8381
8489
|
}
|
|
8382
8490
|
if (liveSyncPos != null && liveSyncPos > currentTime) {
|
|
8383
8491
|
video.currentTime = liveSyncPos;
|
|
@@ -8385,7 +8493,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8385
8493
|
_this.host.restartHlsLoad(reloadPos);
|
|
8386
8494
|
} else {
|
|
8387
8495
|
if (_this.debug) {
|
|
8388
|
-
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break
|
|
8496
|
+
console.warn("[StormcloudVideoPlayer] Content still wedged after ad break — hard-reloading live stream (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
|
|
8389
8497
|
}
|
|
8390
8498
|
_this.host.reloadLiveStream();
|
|
8391
8499
|
}
|