stormcloud-video-player 0.3.64 → 0.3.66
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 +87 -45
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +25 -19
- package/lib/index.d.ts +25 -19
- package/lib/index.js +87 -45
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +90 -45
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +6 -0
- package/lib/players/HlsPlayer.cjs +90 -45
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +90 -45
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +90 -45
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -2428,6 +2428,9 @@ var DEFAULT_MQTT_CONFIG = {
|
|
|
2428
2428
|
qos: 1
|
|
2429
2429
|
};
|
|
2430
2430
|
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2431
|
+
function applyMQTTConfig(overrides) {
|
|
2432
|
+
Object.assign(mqttConfig, overrides);
|
|
2433
|
+
}
|
|
2431
2434
|
function isMQTTEnabled() {
|
|
2432
2435
|
return mqttConfig.enabled;
|
|
2433
2436
|
}
|
|
@@ -3865,7 +3868,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3865
3868
|
_this.showAds = true;
|
|
3866
3869
|
_this.resetGamNoFillCounter();
|
|
3867
3870
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3868
|
-
_this.
|
|
3871
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3869
3872
|
if (_this.config.debugAdTiming) {
|
|
3870
3873
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3871
3874
|
}
|
|
@@ -4509,12 +4512,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4509
4512
|
if (marker.durationSeconds != null) {
|
|
4510
4513
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4511
4514
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4512
|
-
this.
|
|
4513
|
-
|
|
4514
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4515
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4515
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4516
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4516
4517
|
if (this.config.debugAdTiming) {
|
|
4517
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4518
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4518
4519
|
}
|
|
4519
4520
|
}
|
|
4520
4521
|
}
|
|
@@ -4588,13 +4589,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4588
4589
|
}
|
|
4589
4590
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4590
4591
|
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);
|
|
4592
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4597
4593
|
}
|
|
4594
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4598
4595
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4599
4596
|
this.tryNextAvailableAdWithRateLimit();
|
|
4600
4597
|
}
|
|
@@ -4619,15 +4616,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4619
4616
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4620
4617
|
});
|
|
4621
4618
|
}
|
|
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;
|
|
4619
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4631
4620
|
this.clearAdStartTimer();
|
|
4632
4621
|
this.clearAdStopTimer();
|
|
4633
4622
|
if (adPlaying) {
|
|
@@ -4651,12 +4640,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4651
4640
|
this.inAdBreak = true;
|
|
4652
4641
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4653
4642
|
this.scheduledScte35BreakKey = void 0;
|
|
4654
|
-
this.
|
|
4655
|
-
this.
|
|
4643
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4644
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4656
4645
|
this.handleAdStart(marker);
|
|
4657
|
-
|
|
4658
|
-
|
|
4646
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4647
|
+
}
|
|
4648
|
+
},
|
|
4649
|
+
{
|
|
4650
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4651
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4652
|
+
var nowWallClockMs = Date.now();
|
|
4653
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4654
|
+
return nowWallClockMs;
|
|
4655
|
+
}
|
|
4656
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4657
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4658
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4659
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4660
|
+
return nowWallClockMs;
|
|
4659
4661
|
}
|
|
4662
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4663
|
+
}
|
|
4664
|
+
},
|
|
4665
|
+
{
|
|
4666
|
+
key: "setAdBreakDurationBoundary",
|
|
4667
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4668
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4669
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4670
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4671
|
+
} else {
|
|
4672
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
},
|
|
4676
|
+
{
|
|
4677
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4678
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4679
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4680
|
+
return;
|
|
4681
|
+
}
|
|
4682
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4660
4683
|
}
|
|
4661
4684
|
},
|
|
4662
4685
|
{
|
|
@@ -5382,6 +5405,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5382
5405
|
return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
|
|
5383
5406
|
}
|
|
5384
5407
|
},
|
|
5408
|
+
{
|
|
5409
|
+
key: "applyMqttConfigFromResponse",
|
|
5410
|
+
value: function applyMqttConfigFromResponse(data) {
|
|
5411
|
+
var _data_response;
|
|
5412
|
+
var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
|
|
5413
|
+
if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
|
|
5414
|
+
return;
|
|
5415
|
+
}
|
|
5416
|
+
applyMQTTConfig(mqttConfig2);
|
|
5417
|
+
if (this.config.debugAdTiming) {
|
|
5418
|
+
console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
},
|
|
5385
5422
|
{
|
|
5386
5423
|
key: "fetchAdConfiguration",
|
|
5387
5424
|
value: function fetchAdConfiguration() {
|
|
@@ -5468,6 +5505,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5468
5505
|
];
|
|
5469
5506
|
case 4:
|
|
5470
5507
|
data = _state.sent();
|
|
5508
|
+
this.applyMqttConfigFromResponse(data);
|
|
5471
5509
|
imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
|
|
5472
5510
|
if (imaPayload) {
|
|
5473
5511
|
this.apiVastTagUrl = decodeURIComponent(imaPayload);
|
|
@@ -6284,7 +6322,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6284
6322
|
}
|
|
6285
6323
|
}
|
|
6286
6324
|
this.inAdBreak = true;
|
|
6287
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6288
6325
|
this.currentAdIndex = 0;
|
|
6289
6326
|
this.totalAdsInBreak = 1;
|
|
6290
6327
|
this.adPodQueue = [];
|
|
@@ -6371,7 +6408,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6371
6408
|
case 2:
|
|
6372
6409
|
_state.sent();
|
|
6373
6410
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6374
|
-
this.
|
|
6411
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6375
6412
|
}
|
|
6376
6413
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6377
6414
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6414,7 +6451,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6414
6451
|
case 6:
|
|
6415
6452
|
_state.sent();
|
|
6416
6453
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6417
|
-
this.
|
|
6454
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6418
6455
|
}
|
|
6419
6456
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6420
6457
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6469,7 +6506,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6469
6506
|
case 10:
|
|
6470
6507
|
_state.sent();
|
|
6471
6508
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6472
|
-
this.
|
|
6509
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6473
6510
|
}
|
|
6474
6511
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6475
6512
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6821,7 +6858,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6821
6858
|
case 2:
|
|
6822
6859
|
_state.sent();
|
|
6823
6860
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6824
|
-
this.
|
|
6861
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6825
6862
|
}
|
|
6826
6863
|
currentMuted = this.video.muted;
|
|
6827
6864
|
currentVolume = this.video.volume;
|
|
@@ -7321,21 +7358,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7321
7358
|
{
|
|
7322
7359
|
key: "ensureAdStoppedByTimer",
|
|
7323
7360
|
value: function ensureAdStoppedByTimer() {
|
|
7324
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7361
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7325
7362
|
if (!this.inAdBreak) return;
|
|
7326
7363
|
this.adStopTimerId = void 0;
|
|
7327
7364
|
var adPlaying = this.ima.isAdPlaying();
|
|
7328
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7329
7365
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7330
7366
|
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;
|
|
7367
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7368
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7369
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7370
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7339
7371
|
if (shouldExtendAdBreak) {
|
|
7340
7372
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7341
7373
|
return;
|
|
@@ -7601,7 +7633,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7601
7633
|
case 5:
|
|
7602
7634
|
_state.sent();
|
|
7603
7635
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7604
|
-
this.
|
|
7636
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7605
7637
|
}
|
|
7606
7638
|
currentMuted = this.video.muted;
|
|
7607
7639
|
currentVolume = this.video.volume;
|
|
@@ -7651,7 +7683,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7651
7683
|
case 8:
|
|
7652
7684
|
_state.sent();
|
|
7653
7685
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7654
|
-
this.
|
|
7686
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7655
7687
|
}
|
|
7656
7688
|
currentMuted1 = this.video.muted;
|
|
7657
7689
|
currentVolume1 = this.video.volume;
|
|
@@ -7796,6 +7828,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7796
7828
|
this.scheduledScte35BreakKey = void 0;
|
|
7797
7829
|
this.expectedAdBreakDurationMs = void 0;
|
|
7798
7830
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7831
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7799
7832
|
this.clearAdStartTimer();
|
|
7800
7833
|
this.clearAdStopTimer();
|
|
7801
7834
|
this.adPodQueue = [];
|
|
@@ -7985,9 +8018,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7985
8018
|
{
|
|
7986
8019
|
key: "getRemainingAdMs",
|
|
7987
8020
|
value: function getRemainingAdMs() {
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
8021
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8022
|
+
if (endWallClockMs != null) {
|
|
8023
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8024
|
+
}
|
|
8025
|
+
return 0;
|
|
8026
|
+
}
|
|
8027
|
+
},
|
|
8028
|
+
{
|
|
8029
|
+
key: "getAdBreakEndWallClockMs",
|
|
8030
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8031
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8032
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8033
|
+
}
|
|
8034
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8035
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
7991
8036
|
}
|
|
7992
8037
|
},
|
|
7993
8038
|
{
|