stormcloud-video-player 0.3.64 → 0.3.65
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 +2 -2
- package/lib/index.cjs +72 -45
- 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 +72 -45
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +72 -45
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -0
- package/lib/players/HlsPlayer.cjs +72 -45
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +72 -45
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +72 -45
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -3865,7 +3865,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3865
3865
|
_this.showAds = true;
|
|
3866
3866
|
_this.resetGamNoFillCounter();
|
|
3867
3867
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3868
|
-
_this.
|
|
3868
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3869
3869
|
if (_this.config.debugAdTiming) {
|
|
3870
3870
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3871
3871
|
}
|
|
@@ -4509,12 +4509,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4509
4509
|
if (marker.durationSeconds != null) {
|
|
4510
4510
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4511
4511
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4512
|
-
this.
|
|
4513
|
-
|
|
4514
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4515
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4512
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4513
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4516
4514
|
if (this.config.debugAdTiming) {
|
|
4517
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4515
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4518
4516
|
}
|
|
4519
4517
|
}
|
|
4520
4518
|
}
|
|
@@ -4588,13 +4586,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4588
4586
|
}
|
|
4589
4587
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4590
4588
|
if (marker.durationSeconds != null) {
|
|
4591
|
-
this.
|
|
4592
|
-
}
|
|
4593
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4594
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4595
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4596
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4589
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4597
4590
|
}
|
|
4591
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4598
4592
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4599
4593
|
this.tryNextAvailableAdWithRateLimit();
|
|
4600
4594
|
}
|
|
@@ -4619,15 +4613,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4619
4613
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4620
4614
|
});
|
|
4621
4615
|
}
|
|
4622
|
-
|
|
4623
|
-
if (this.config.debugAdTiming) {
|
|
4624
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4625
|
-
}
|
|
4626
|
-
return;
|
|
4627
|
-
}
|
|
4628
|
-
this.inAdBreak = false;
|
|
4629
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4630
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4616
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4631
4617
|
this.clearAdStartTimer();
|
|
4632
4618
|
this.clearAdStopTimer();
|
|
4633
4619
|
if (adPlaying) {
|
|
@@ -4651,12 +4637,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4651
4637
|
this.inAdBreak = true;
|
|
4652
4638
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4653
4639
|
this.scheduledScte35BreakKey = void 0;
|
|
4654
|
-
this.
|
|
4655
|
-
this.
|
|
4640
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4641
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4656
4642
|
this.handleAdStart(marker);
|
|
4657
|
-
|
|
4658
|
-
|
|
4643
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4644
|
+
}
|
|
4645
|
+
},
|
|
4646
|
+
{
|
|
4647
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4648
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4649
|
+
var nowWallClockMs = Date.now();
|
|
4650
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4651
|
+
return nowWallClockMs;
|
|
4659
4652
|
}
|
|
4653
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4654
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4655
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4656
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4657
|
+
return nowWallClockMs;
|
|
4658
|
+
}
|
|
4659
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4660
|
+
}
|
|
4661
|
+
},
|
|
4662
|
+
{
|
|
4663
|
+
key: "setAdBreakDurationBoundary",
|
|
4664
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4665
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4666
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4667
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4668
|
+
} else {
|
|
4669
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4672
|
+
},
|
|
4673
|
+
{
|
|
4674
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4675
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4676
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4677
|
+
return;
|
|
4678
|
+
}
|
|
4679
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4660
4680
|
}
|
|
4661
4681
|
},
|
|
4662
4682
|
{
|
|
@@ -6284,7 +6304,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6284
6304
|
}
|
|
6285
6305
|
}
|
|
6286
6306
|
this.inAdBreak = true;
|
|
6287
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6288
6307
|
this.currentAdIndex = 0;
|
|
6289
6308
|
this.totalAdsInBreak = 1;
|
|
6290
6309
|
this.adPodQueue = [];
|
|
@@ -6371,7 +6390,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6371
6390
|
case 2:
|
|
6372
6391
|
_state.sent();
|
|
6373
6392
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6374
|
-
this.
|
|
6393
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6375
6394
|
}
|
|
6376
6395
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6377
6396
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6414,7 +6433,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6414
6433
|
case 6:
|
|
6415
6434
|
_state.sent();
|
|
6416
6435
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6417
|
-
this.
|
|
6436
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6418
6437
|
}
|
|
6419
6438
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6420
6439
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6469,7 +6488,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6469
6488
|
case 10:
|
|
6470
6489
|
_state.sent();
|
|
6471
6490
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6472
|
-
this.
|
|
6491
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6473
6492
|
}
|
|
6474
6493
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6475
6494
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6821,7 +6840,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6821
6840
|
case 2:
|
|
6822
6841
|
_state.sent();
|
|
6823
6842
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6824
|
-
this.
|
|
6843
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6825
6844
|
}
|
|
6826
6845
|
currentMuted = this.video.muted;
|
|
6827
6846
|
currentVolume = this.video.volume;
|
|
@@ -7321,21 +7340,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7321
7340
|
{
|
|
7322
7341
|
key: "ensureAdStoppedByTimer",
|
|
7323
7342
|
value: function ensureAdStoppedByTimer() {
|
|
7324
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7343
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7325
7344
|
if (!this.inAdBreak) return;
|
|
7326
7345
|
this.adStopTimerId = void 0;
|
|
7327
7346
|
var adPlaying = this.ima.isAdPlaying();
|
|
7328
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7329
7347
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7330
7348
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7331
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7332
|
-
var
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
}
|
|
7336
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7337
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7338
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7349
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7350
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7351
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7352
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7339
7353
|
if (shouldExtendAdBreak) {
|
|
7340
7354
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7341
7355
|
return;
|
|
@@ -7601,7 +7615,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7601
7615
|
case 5:
|
|
7602
7616
|
_state.sent();
|
|
7603
7617
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7604
|
-
this.
|
|
7618
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7605
7619
|
}
|
|
7606
7620
|
currentMuted = this.video.muted;
|
|
7607
7621
|
currentVolume = this.video.volume;
|
|
@@ -7651,7 +7665,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7651
7665
|
case 8:
|
|
7652
7666
|
_state.sent();
|
|
7653
7667
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7654
|
-
this.
|
|
7668
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7655
7669
|
}
|
|
7656
7670
|
currentMuted1 = this.video.muted;
|
|
7657
7671
|
currentVolume1 = this.video.volume;
|
|
@@ -7796,6 +7810,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7796
7810
|
this.scheduledScte35BreakKey = void 0;
|
|
7797
7811
|
this.expectedAdBreakDurationMs = void 0;
|
|
7798
7812
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7813
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7799
7814
|
this.clearAdStartTimer();
|
|
7800
7815
|
this.clearAdStopTimer();
|
|
7801
7816
|
this.adPodQueue = [];
|
|
@@ -7985,9 +8000,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7985
8000
|
{
|
|
7986
8001
|
key: "getRemainingAdMs",
|
|
7987
8002
|
value: function getRemainingAdMs() {
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
8003
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8004
|
+
if (endWallClockMs != null) {
|
|
8005
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8006
|
+
}
|
|
8007
|
+
return 0;
|
|
8008
|
+
}
|
|
8009
|
+
},
|
|
8010
|
+
{
|
|
8011
|
+
key: "getAdBreakEndWallClockMs",
|
|
8012
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8013
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8014
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8015
|
+
}
|
|
8016
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8017
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
7991
8018
|
}
|
|
7992
8019
|
},
|
|
7993
8020
|
{
|