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
|
@@ -2390,6 +2390,9 @@ var DEFAULT_MQTT_CONFIG = {
|
|
|
2390
2390
|
qos: 1
|
|
2391
2391
|
};
|
|
2392
2392
|
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2393
|
+
function applyMQTTConfig(overrides) {
|
|
2394
|
+
Object.assign(mqttConfig, overrides);
|
|
2395
|
+
}
|
|
2393
2396
|
function isMQTTEnabled() {
|
|
2394
2397
|
return mqttConfig.enabled;
|
|
2395
2398
|
}
|
|
@@ -3827,7 +3830,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3827
3830
|
_this.showAds = true;
|
|
3828
3831
|
_this.resetGamNoFillCounter();
|
|
3829
3832
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3830
|
-
_this.
|
|
3833
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3831
3834
|
if (_this.config.debugAdTiming) {
|
|
3832
3835
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3833
3836
|
}
|
|
@@ -4471,12 +4474,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4471
4474
|
if (marker.durationSeconds != null) {
|
|
4472
4475
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4473
4476
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4474
|
-
this.
|
|
4475
|
-
|
|
4476
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4477
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4477
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4478
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4478
4479
|
if (this.config.debugAdTiming) {
|
|
4479
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4480
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4480
4481
|
}
|
|
4481
4482
|
}
|
|
4482
4483
|
}
|
|
@@ -4550,13 +4551,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4550
4551
|
}
|
|
4551
4552
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4552
4553
|
if (marker.durationSeconds != null) {
|
|
4553
|
-
this.
|
|
4554
|
-
}
|
|
4555
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4556
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4557
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4558
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4554
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4559
4555
|
}
|
|
4556
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4560
4557
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4561
4558
|
this.tryNextAvailableAdWithRateLimit();
|
|
4562
4559
|
}
|
|
@@ -4581,15 +4578,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4581
4578
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4582
4579
|
});
|
|
4583
4580
|
}
|
|
4584
|
-
|
|
4585
|
-
if (this.config.debugAdTiming) {
|
|
4586
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4587
|
-
}
|
|
4588
|
-
return;
|
|
4589
|
-
}
|
|
4590
|
-
this.inAdBreak = false;
|
|
4591
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4592
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4581
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4593
4582
|
this.clearAdStartTimer();
|
|
4594
4583
|
this.clearAdStopTimer();
|
|
4595
4584
|
if (adPlaying) {
|
|
@@ -4613,12 +4602,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4613
4602
|
this.inAdBreak = true;
|
|
4614
4603
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4615
4604
|
this.scheduledScte35BreakKey = void 0;
|
|
4616
|
-
this.
|
|
4617
|
-
this.
|
|
4605
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4606
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4618
4607
|
this.handleAdStart(marker);
|
|
4619
|
-
|
|
4620
|
-
|
|
4608
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4609
|
+
}
|
|
4610
|
+
},
|
|
4611
|
+
{
|
|
4612
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4613
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4614
|
+
var nowWallClockMs = Date.now();
|
|
4615
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4616
|
+
return nowWallClockMs;
|
|
4617
|
+
}
|
|
4618
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4619
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4620
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4621
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4622
|
+
return nowWallClockMs;
|
|
4621
4623
|
}
|
|
4624
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4625
|
+
}
|
|
4626
|
+
},
|
|
4627
|
+
{
|
|
4628
|
+
key: "setAdBreakDurationBoundary",
|
|
4629
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4630
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4631
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4632
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4633
|
+
} else {
|
|
4634
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4637
|
+
},
|
|
4638
|
+
{
|
|
4639
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4640
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4641
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4642
|
+
return;
|
|
4643
|
+
}
|
|
4644
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4622
4645
|
}
|
|
4623
4646
|
},
|
|
4624
4647
|
{
|
|
@@ -5344,6 +5367,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5344
5367
|
return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
|
|
5345
5368
|
}
|
|
5346
5369
|
},
|
|
5370
|
+
{
|
|
5371
|
+
key: "applyMqttConfigFromResponse",
|
|
5372
|
+
value: function applyMqttConfigFromResponse(data) {
|
|
5373
|
+
var _data_response;
|
|
5374
|
+
var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
|
|
5375
|
+
if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
|
|
5376
|
+
return;
|
|
5377
|
+
}
|
|
5378
|
+
applyMQTTConfig(mqttConfig2);
|
|
5379
|
+
if (this.config.debugAdTiming) {
|
|
5380
|
+
console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
},
|
|
5347
5384
|
{
|
|
5348
5385
|
key: "fetchAdConfiguration",
|
|
5349
5386
|
value: function fetchAdConfiguration() {
|
|
@@ -5430,6 +5467,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5430
5467
|
];
|
|
5431
5468
|
case 4:
|
|
5432
5469
|
data = _state.sent();
|
|
5470
|
+
this.applyMqttConfigFromResponse(data);
|
|
5433
5471
|
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;
|
|
5434
5472
|
if (imaPayload) {
|
|
5435
5473
|
this.apiVastTagUrl = decodeURIComponent(imaPayload);
|
|
@@ -6246,7 +6284,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6246
6284
|
}
|
|
6247
6285
|
}
|
|
6248
6286
|
this.inAdBreak = true;
|
|
6249
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6250
6287
|
this.currentAdIndex = 0;
|
|
6251
6288
|
this.totalAdsInBreak = 1;
|
|
6252
6289
|
this.adPodQueue = [];
|
|
@@ -6333,7 +6370,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6333
6370
|
case 2:
|
|
6334
6371
|
_state.sent();
|
|
6335
6372
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6336
|
-
this.
|
|
6373
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6337
6374
|
}
|
|
6338
6375
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6339
6376
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6376,7 +6413,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6376
6413
|
case 6:
|
|
6377
6414
|
_state.sent();
|
|
6378
6415
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6379
|
-
this.
|
|
6416
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6380
6417
|
}
|
|
6381
6418
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6382
6419
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6431,7 +6468,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6431
6468
|
case 10:
|
|
6432
6469
|
_state.sent();
|
|
6433
6470
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6434
|
-
this.
|
|
6471
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6435
6472
|
}
|
|
6436
6473
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6437
6474
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6783,7 +6820,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6783
6820
|
case 2:
|
|
6784
6821
|
_state.sent();
|
|
6785
6822
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6786
|
-
this.
|
|
6823
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6787
6824
|
}
|
|
6788
6825
|
currentMuted = this.video.muted;
|
|
6789
6826
|
currentVolume = this.video.volume;
|
|
@@ -7283,21 +7320,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7283
7320
|
{
|
|
7284
7321
|
key: "ensureAdStoppedByTimer",
|
|
7285
7322
|
value: function ensureAdStoppedByTimer() {
|
|
7286
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7323
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7287
7324
|
if (!this.inAdBreak) return;
|
|
7288
7325
|
this.adStopTimerId = void 0;
|
|
7289
7326
|
var adPlaying = this.ima.isAdPlaying();
|
|
7290
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7291
7327
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7292
7328
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7293
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7294
|
-
var
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
}
|
|
7298
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7299
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7300
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7329
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7330
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7331
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7332
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7301
7333
|
if (shouldExtendAdBreak) {
|
|
7302
7334
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7303
7335
|
return;
|
|
@@ -7563,7 +7595,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7563
7595
|
case 5:
|
|
7564
7596
|
_state.sent();
|
|
7565
7597
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7566
|
-
this.
|
|
7598
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7567
7599
|
}
|
|
7568
7600
|
currentMuted = this.video.muted;
|
|
7569
7601
|
currentVolume = this.video.volume;
|
|
@@ -7613,7 +7645,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7613
7645
|
case 8:
|
|
7614
7646
|
_state.sent();
|
|
7615
7647
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7616
|
-
this.
|
|
7648
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7617
7649
|
}
|
|
7618
7650
|
currentMuted1 = this.video.muted;
|
|
7619
7651
|
currentVolume1 = this.video.volume;
|
|
@@ -7758,6 +7790,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7758
7790
|
this.scheduledScte35BreakKey = void 0;
|
|
7759
7791
|
this.expectedAdBreakDurationMs = void 0;
|
|
7760
7792
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7793
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7761
7794
|
this.clearAdStartTimer();
|
|
7762
7795
|
this.clearAdStopTimer();
|
|
7763
7796
|
this.adPodQueue = [];
|
|
@@ -7947,9 +7980,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7947
7980
|
{
|
|
7948
7981
|
key: "getRemainingAdMs",
|
|
7949
7982
|
value: function getRemainingAdMs() {
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7983
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
7984
|
+
if (endWallClockMs != null) {
|
|
7985
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
7986
|
+
}
|
|
7987
|
+
return 0;
|
|
7988
|
+
}
|
|
7989
|
+
},
|
|
7990
|
+
{
|
|
7991
|
+
key: "getAdBreakEndWallClockMs",
|
|
7992
|
+
value: function getAdBreakEndWallClockMs() {
|
|
7993
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
7994
|
+
return this.scteAdBreakEndWallClockMs;
|
|
7995
|
+
}
|
|
7996
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
7997
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
7953
7998
|
}
|
|
7954
7999
|
},
|
|
7955
8000
|
{
|