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
package/lib/players/index.cjs
CHANGED
|
@@ -2478,6 +2478,9 @@ var DEFAULT_MQTT_CONFIG = {
|
|
|
2478
2478
|
qos: 1
|
|
2479
2479
|
};
|
|
2480
2480
|
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2481
|
+
function applyMQTTConfig(overrides) {
|
|
2482
|
+
Object.assign(mqttConfig, overrides);
|
|
2483
|
+
}
|
|
2481
2484
|
function isMQTTEnabled() {
|
|
2482
2485
|
return mqttConfig.enabled;
|
|
2483
2486
|
}
|
|
@@ -3915,7 +3918,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3915
3918
|
_this.showAds = true;
|
|
3916
3919
|
_this.resetGamNoFillCounter();
|
|
3917
3920
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3918
|
-
_this.
|
|
3921
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3919
3922
|
if (_this.config.debugAdTiming) {
|
|
3920
3923
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3921
3924
|
}
|
|
@@ -4559,12 +4562,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4559
4562
|
if (marker.durationSeconds != null) {
|
|
4560
4563
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4561
4564
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4562
|
-
this.
|
|
4563
|
-
|
|
4564
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4565
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4565
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4566
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4566
4567
|
if (this.config.debugAdTiming) {
|
|
4567
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4568
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4568
4569
|
}
|
|
4569
4570
|
}
|
|
4570
4571
|
}
|
|
@@ -4638,13 +4639,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4638
4639
|
}
|
|
4639
4640
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4640
4641
|
if (marker.durationSeconds != null) {
|
|
4641
|
-
this.
|
|
4642
|
-
}
|
|
4643
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4644
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4645
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4646
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4642
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4647
4643
|
}
|
|
4644
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4648
4645
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4649
4646
|
this.tryNextAvailableAdWithRateLimit();
|
|
4650
4647
|
}
|
|
@@ -4669,15 +4666,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4669
4666
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4670
4667
|
});
|
|
4671
4668
|
}
|
|
4672
|
-
|
|
4673
|
-
if (this.config.debugAdTiming) {
|
|
4674
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4675
|
-
}
|
|
4676
|
-
return;
|
|
4677
|
-
}
|
|
4678
|
-
this.inAdBreak = false;
|
|
4679
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4680
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4669
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4681
4670
|
this.clearAdStartTimer();
|
|
4682
4671
|
this.clearAdStopTimer();
|
|
4683
4672
|
if (adPlaying) {
|
|
@@ -4701,12 +4690,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4701
4690
|
this.inAdBreak = true;
|
|
4702
4691
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4703
4692
|
this.scheduledScte35BreakKey = void 0;
|
|
4704
|
-
this.
|
|
4705
|
-
this.
|
|
4693
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4694
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4706
4695
|
this.handleAdStart(marker);
|
|
4707
|
-
|
|
4708
|
-
|
|
4696
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4697
|
+
}
|
|
4698
|
+
},
|
|
4699
|
+
{
|
|
4700
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4701
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4702
|
+
var nowWallClockMs = Date.now();
|
|
4703
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4704
|
+
return nowWallClockMs;
|
|
4705
|
+
}
|
|
4706
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4707
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4708
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4709
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4710
|
+
return nowWallClockMs;
|
|
4709
4711
|
}
|
|
4712
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4713
|
+
}
|
|
4714
|
+
},
|
|
4715
|
+
{
|
|
4716
|
+
key: "setAdBreakDurationBoundary",
|
|
4717
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4718
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4719
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4720
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4721
|
+
} else {
|
|
4722
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
},
|
|
4726
|
+
{
|
|
4727
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4728
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4729
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4730
|
+
return;
|
|
4731
|
+
}
|
|
4732
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4710
4733
|
}
|
|
4711
4734
|
},
|
|
4712
4735
|
{
|
|
@@ -5432,6 +5455,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5432
5455
|
return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
|
|
5433
5456
|
}
|
|
5434
5457
|
},
|
|
5458
|
+
{
|
|
5459
|
+
key: "applyMqttConfigFromResponse",
|
|
5460
|
+
value: function applyMqttConfigFromResponse(data) {
|
|
5461
|
+
var _data_response;
|
|
5462
|
+
var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
|
|
5463
|
+
if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
|
|
5464
|
+
return;
|
|
5465
|
+
}
|
|
5466
|
+
applyMQTTConfig(mqttConfig2);
|
|
5467
|
+
if (this.config.debugAdTiming) {
|
|
5468
|
+
console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
},
|
|
5435
5472
|
{
|
|
5436
5473
|
key: "fetchAdConfiguration",
|
|
5437
5474
|
value: function fetchAdConfiguration() {
|
|
@@ -5518,6 +5555,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5518
5555
|
];
|
|
5519
5556
|
case 4:
|
|
5520
5557
|
data = _state.sent();
|
|
5558
|
+
this.applyMqttConfigFromResponse(data);
|
|
5521
5559
|
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;
|
|
5522
5560
|
if (imaPayload) {
|
|
5523
5561
|
this.apiVastTagUrl = decodeURIComponent(imaPayload);
|
|
@@ -6334,7 +6372,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6334
6372
|
}
|
|
6335
6373
|
}
|
|
6336
6374
|
this.inAdBreak = true;
|
|
6337
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6338
6375
|
this.currentAdIndex = 0;
|
|
6339
6376
|
this.totalAdsInBreak = 1;
|
|
6340
6377
|
this.adPodQueue = [];
|
|
@@ -6421,7 +6458,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6421
6458
|
case 2:
|
|
6422
6459
|
_state.sent();
|
|
6423
6460
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6424
|
-
this.
|
|
6461
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6425
6462
|
}
|
|
6426
6463
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6427
6464
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6464,7 +6501,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6464
6501
|
case 6:
|
|
6465
6502
|
_state.sent();
|
|
6466
6503
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6467
|
-
this.
|
|
6504
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6468
6505
|
}
|
|
6469
6506
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6470
6507
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6519,7 +6556,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6519
6556
|
case 10:
|
|
6520
6557
|
_state.sent();
|
|
6521
6558
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6522
|
-
this.
|
|
6559
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6523
6560
|
}
|
|
6524
6561
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6525
6562
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6871,7 +6908,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6871
6908
|
case 2:
|
|
6872
6909
|
_state.sent();
|
|
6873
6910
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6874
|
-
this.
|
|
6911
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6875
6912
|
}
|
|
6876
6913
|
currentMuted = this.video.muted;
|
|
6877
6914
|
currentVolume = this.video.volume;
|
|
@@ -7371,21 +7408,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7371
7408
|
{
|
|
7372
7409
|
key: "ensureAdStoppedByTimer",
|
|
7373
7410
|
value: function ensureAdStoppedByTimer() {
|
|
7374
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7411
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7375
7412
|
if (!this.inAdBreak) return;
|
|
7376
7413
|
this.adStopTimerId = void 0;
|
|
7377
7414
|
var adPlaying = this.ima.isAdPlaying();
|
|
7378
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7379
7415
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7380
7416
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7381
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7382
|
-
var
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
}
|
|
7386
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7387
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7388
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7417
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7418
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7419
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7420
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7389
7421
|
if (shouldExtendAdBreak) {
|
|
7390
7422
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7391
7423
|
return;
|
|
@@ -7651,7 +7683,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7651
7683
|
case 5:
|
|
7652
7684
|
_state.sent();
|
|
7653
7685
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7654
|
-
this.
|
|
7686
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7655
7687
|
}
|
|
7656
7688
|
currentMuted = this.video.muted;
|
|
7657
7689
|
currentVolume = this.video.volume;
|
|
@@ -7701,7 +7733,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7701
7733
|
case 8:
|
|
7702
7734
|
_state.sent();
|
|
7703
7735
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7704
|
-
this.
|
|
7736
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7705
7737
|
}
|
|
7706
7738
|
currentMuted1 = this.video.muted;
|
|
7707
7739
|
currentVolume1 = this.video.volume;
|
|
@@ -7846,6 +7878,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7846
7878
|
this.scheduledScte35BreakKey = void 0;
|
|
7847
7879
|
this.expectedAdBreakDurationMs = void 0;
|
|
7848
7880
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7881
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7849
7882
|
this.clearAdStartTimer();
|
|
7850
7883
|
this.clearAdStopTimer();
|
|
7851
7884
|
this.adPodQueue = [];
|
|
@@ -8035,9 +8068,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8035
8068
|
{
|
|
8036
8069
|
key: "getRemainingAdMs",
|
|
8037
8070
|
value: function getRemainingAdMs() {
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8071
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8072
|
+
if (endWallClockMs != null) {
|
|
8073
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8074
|
+
}
|
|
8075
|
+
return 0;
|
|
8076
|
+
}
|
|
8077
|
+
},
|
|
8078
|
+
{
|
|
8079
|
+
key: "getAdBreakEndWallClockMs",
|
|
8080
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8081
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8082
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8083
|
+
}
|
|
8084
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8085
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
8041
8086
|
}
|
|
8042
8087
|
},
|
|
8043
8088
|
{
|