stormcloud-video-player 0.8.15 → 0.8.16
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 +70 -42
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +70 -42
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +70 -42
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -0
- package/lib/players/HlsPlayer.cjs +70 -42
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +70 -42
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +70 -42
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -3802,7 +3802,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3802
3802
|
_this.showAds = true;
|
|
3803
3803
|
_this.resetGamNoFillCounter();
|
|
3804
3804
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3805
|
-
_this.
|
|
3805
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3806
3806
|
if (_this.config.debugAdTiming) {
|
|
3807
3807
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3808
3808
|
}
|
|
@@ -4457,12 +4457,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4457
4457
|
if (marker.durationSeconds != null) {
|
|
4458
4458
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4459
4459
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4460
|
-
this.
|
|
4461
|
-
|
|
4462
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4463
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4460
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4461
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4464
4462
|
if (this.config.debugAdTiming) {
|
|
4465
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4463
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getWallClockRemainingAdMs(), "ms"));
|
|
4466
4464
|
}
|
|
4467
4465
|
}
|
|
4468
4466
|
}
|
|
@@ -4536,13 +4534,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4536
4534
|
}
|
|
4537
4535
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4538
4536
|
if (marker.durationSeconds != null) {
|
|
4539
|
-
this.
|
|
4540
|
-
}
|
|
4541
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4542
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4543
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4544
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4537
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4545
4538
|
}
|
|
4539
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4546
4540
|
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0 && this.hasTimeToStartAnotherAd()) {
|
|
4547
4541
|
this.tryNextAvailableAdWithRateLimit();
|
|
4548
4542
|
}
|
|
@@ -4566,15 +4560,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4566
4560
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4567
4561
|
});
|
|
4568
4562
|
}
|
|
4569
|
-
|
|
4570
|
-
if (this.config.debugAdTiming) {
|
|
4571
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4572
|
-
}
|
|
4573
|
-
return;
|
|
4574
|
-
}
|
|
4575
|
-
this.inAdBreak = false;
|
|
4576
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4577
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4563
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4578
4564
|
this.clearAdStartTimer();
|
|
4579
4565
|
this.clearAdStopTimer();
|
|
4580
4566
|
if (adPlaying) {
|
|
@@ -4591,14 +4577,48 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4591
4577
|
this.inAdBreak = true;
|
|
4592
4578
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4593
4579
|
this.scheduledScte35BreakKey = void 0;
|
|
4594
|
-
this.
|
|
4595
|
-
this.
|
|
4580
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4581
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4596
4582
|
this.handleAdStart(marker);
|
|
4597
|
-
|
|
4598
|
-
|
|
4583
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4584
|
+
}
|
|
4585
|
+
},
|
|
4586
|
+
{
|
|
4587
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4588
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4589
|
+
var nowWallClockMs = Date.now();
|
|
4590
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4591
|
+
return nowWallClockMs;
|
|
4592
|
+
}
|
|
4593
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4594
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4595
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4596
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4597
|
+
return nowWallClockMs;
|
|
4598
|
+
}
|
|
4599
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4600
|
+
}
|
|
4601
|
+
},
|
|
4602
|
+
{
|
|
4603
|
+
key: "setAdBreakDurationBoundary",
|
|
4604
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4605
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4606
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4607
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4608
|
+
} else {
|
|
4609
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4599
4610
|
}
|
|
4600
4611
|
}
|
|
4601
4612
|
},
|
|
4613
|
+
{
|
|
4614
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4615
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4616
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4617
|
+
return;
|
|
4618
|
+
}
|
|
4619
|
+
this.scheduleAdStopCountdown(this.getWallClockRemainingAdMs());
|
|
4620
|
+
}
|
|
4621
|
+
},
|
|
4602
4622
|
{
|
|
4603
4623
|
key: "parseCueOutDuration",
|
|
4604
4624
|
value: function parseCueOutDuration(value) {
|
|
@@ -6246,7 +6266,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6246
6266
|
currentVolume = this.video.volume;
|
|
6247
6267
|
this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
|
|
6248
6268
|
this.inAdBreak = true;
|
|
6249
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6250
6269
|
this.adBreakPlayedDurationMs = 0;
|
|
6251
6270
|
this.currentAdIndex = 0;
|
|
6252
6271
|
this.totalAdsInBreak = 0;
|
|
@@ -6352,7 +6371,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6352
6371
|
_state.sent();
|
|
6353
6372
|
this.markAdStarted();
|
|
6354
6373
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6355
|
-
this.
|
|
6374
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6356
6375
|
}
|
|
6357
6376
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6358
6377
|
this.adPlayer.setAdVolume(adVolume);
|
|
@@ -6412,7 +6431,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6412
6431
|
_state.sent();
|
|
6413
6432
|
this.markAdStarted();
|
|
6414
6433
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6415
|
-
this.
|
|
6434
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6416
6435
|
}
|
|
6417
6436
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6418
6437
|
this.adPlayer.setAdVolume(adVolume1);
|
|
@@ -6485,7 +6504,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6485
6504
|
_state.sent();
|
|
6486
6505
|
this.markAdStarted();
|
|
6487
6506
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6488
|
-
this.
|
|
6507
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6489
6508
|
}
|
|
6490
6509
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6491
6510
|
this.adPlayer.setAdVolume(adVolume2);
|
|
@@ -6868,7 +6887,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6868
6887
|
_state.sent();
|
|
6869
6888
|
this.markAdStarted();
|
|
6870
6889
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6871
|
-
this.
|
|
6890
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6872
6891
|
}
|
|
6873
6892
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
6874
6893
|
this.consecutiveFailures = 0;
|
|
@@ -7396,19 +7415,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7396
7415
|
{
|
|
7397
7416
|
key: "ensureAdStoppedByTimer",
|
|
7398
7417
|
value: function ensureAdStoppedByTimer() {
|
|
7399
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7418
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7400
7419
|
if (!this.inAdBreak) return;
|
|
7401
7420
|
this.adStopTimerId = void 0;
|
|
7402
7421
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
7403
7422
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7404
7423
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7405
7424
|
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7406
|
-
var
|
|
7407
|
-
|
|
7408
|
-
elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
7409
|
-
}
|
|
7410
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7411
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7425
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7426
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7412
7427
|
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7413
7428
|
if (shouldExtendAdBreak) {
|
|
7414
7429
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
@@ -7684,7 +7699,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7684
7699
|
_state.sent();
|
|
7685
7700
|
this.markAdStarted();
|
|
7686
7701
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7687
|
-
this.
|
|
7702
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7688
7703
|
}
|
|
7689
7704
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
7690
7705
|
this.consecutiveFailures = 0;
|
|
@@ -7736,7 +7751,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7736
7751
|
_state.sent();
|
|
7737
7752
|
this.markAdStarted();
|
|
7738
7753
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7739
|
-
this.
|
|
7754
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7740
7755
|
}
|
|
7741
7756
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
7742
7757
|
return [
|
|
@@ -7882,6 +7897,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7882
7897
|
this.scheduledScte35BreakKey = void 0;
|
|
7883
7898
|
this.expectedAdBreakDurationMs = void 0;
|
|
7884
7899
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7900
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7885
7901
|
this.clearAdStartTimer();
|
|
7886
7902
|
this.clearAdStopTimer();
|
|
7887
7903
|
this.adPodQueue = [];
|
|
@@ -8069,11 +8085,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8069
8085
|
{
|
|
8070
8086
|
key: "getWallClockRemainingAdMs",
|
|
8071
8087
|
value: function getWallClockRemainingAdMs() {
|
|
8088
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8089
|
+
if (endWallClockMs != null) {
|
|
8090
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8091
|
+
}
|
|
8092
|
+
return 0;
|
|
8093
|
+
}
|
|
8094
|
+
},
|
|
8095
|
+
{
|
|
8096
|
+
key: "getAdBreakEndWallClockMs",
|
|
8097
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8098
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8099
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8100
|
+
}
|
|
8072
8101
|
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) {
|
|
8073
|
-
return 0;
|
|
8102
|
+
return void 0;
|
|
8074
8103
|
}
|
|
8075
|
-
|
|
8076
|
-
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
8104
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
8077
8105
|
}
|
|
8078
8106
|
},
|
|
8079
8107
|
{
|