stormcloud-video-player 0.3.55 → 0.3.56
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 +271 -26
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +9 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +271 -26
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +264 -25
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +8 -1
- package/lib/players/HlsPlayer.cjs +264 -25
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +264 -25
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-C23mJ_hh.d.cts → types-Vj55FghO.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +269 -26
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -34,6 +34,7 @@ interface StormcloudVideoPlayerConfig {
|
|
|
34
34
|
licenseKey?: string;
|
|
35
35
|
adPlayerType?: 'ima' | 'hls';
|
|
36
36
|
vastTagUrl?: string;
|
|
37
|
+
vmapUrl?: string;
|
|
37
38
|
vastMode?: 'adstorm' | 'default';
|
|
38
39
|
minSegmentsBeforePlay?: number;
|
|
39
40
|
}
|
|
@@ -138,6 +139,8 @@ declare class StormcloudVideoPlayer {
|
|
|
138
139
|
private adPodQueue;
|
|
139
140
|
private apiVastTagUrl;
|
|
140
141
|
private apiNumberAds;
|
|
142
|
+
private vmapBreaks;
|
|
143
|
+
private consumedVmapBreakIds;
|
|
141
144
|
private lastHeartbeatTime;
|
|
142
145
|
private heartbeatInterval;
|
|
143
146
|
private currentAdIndex;
|
|
@@ -209,6 +212,11 @@ declare class StormcloudVideoPlayer {
|
|
|
209
212
|
private initializeTracking;
|
|
210
213
|
private sendHeartbeatIfNeeded;
|
|
211
214
|
private fetchAdConfiguration;
|
|
215
|
+
private fetchAndParseVmap;
|
|
216
|
+
private parseVmapToBreaks;
|
|
217
|
+
private parseVmapTimeOffsetToMs;
|
|
218
|
+
private getAdBreakKey;
|
|
219
|
+
private resolveBreakStartMs;
|
|
212
220
|
getCurrentAdIndex(): number;
|
|
213
221
|
getTotalAdsInBreak(): number;
|
|
214
222
|
private generateVastUrlsWithCorrelators;
|
|
@@ -313,6 +321,7 @@ interface BaseStormcloudPlayerProps {
|
|
|
313
321
|
showCustomControls?: boolean;
|
|
314
322
|
hideLoadingIndicator?: boolean;
|
|
315
323
|
licenseKey?: string;
|
|
324
|
+
vmapUrl?: string;
|
|
316
325
|
adFailsafeTimeoutMs?: number;
|
|
317
326
|
minSegmentsBeforePlay?: number;
|
|
318
327
|
onReady?: (player: StormcloudVideoPlayer) => void;
|
package/lib/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ interface StormcloudVideoPlayerConfig {
|
|
|
34
34
|
licenseKey?: string;
|
|
35
35
|
adPlayerType?: 'ima' | 'hls';
|
|
36
36
|
vastTagUrl?: string;
|
|
37
|
+
vmapUrl?: string;
|
|
37
38
|
vastMode?: 'adstorm' | 'default';
|
|
38
39
|
minSegmentsBeforePlay?: number;
|
|
39
40
|
}
|
|
@@ -138,6 +139,8 @@ declare class StormcloudVideoPlayer {
|
|
|
138
139
|
private adPodQueue;
|
|
139
140
|
private apiVastTagUrl;
|
|
140
141
|
private apiNumberAds;
|
|
142
|
+
private vmapBreaks;
|
|
143
|
+
private consumedVmapBreakIds;
|
|
141
144
|
private lastHeartbeatTime;
|
|
142
145
|
private heartbeatInterval;
|
|
143
146
|
private currentAdIndex;
|
|
@@ -209,6 +212,11 @@ declare class StormcloudVideoPlayer {
|
|
|
209
212
|
private initializeTracking;
|
|
210
213
|
private sendHeartbeatIfNeeded;
|
|
211
214
|
private fetchAdConfiguration;
|
|
215
|
+
private fetchAndParseVmap;
|
|
216
|
+
private parseVmapToBreaks;
|
|
217
|
+
private parseVmapTimeOffsetToMs;
|
|
218
|
+
private getAdBreakKey;
|
|
219
|
+
private resolveBreakStartMs;
|
|
212
220
|
getCurrentAdIndex(): number;
|
|
213
221
|
getTotalAdsInBreak(): number;
|
|
214
222
|
private generateVastUrlsWithCorrelators;
|
|
@@ -313,6 +321,7 @@ interface BaseStormcloudPlayerProps {
|
|
|
313
321
|
showCustomControls?: boolean;
|
|
314
322
|
hideLoadingIndicator?: boolean;
|
|
315
323
|
licenseKey?: string;
|
|
324
|
+
vmapUrl?: string;
|
|
316
325
|
adFailsafeTimeoutMs?: number;
|
|
317
326
|
minSegmentsBeforePlay?: number;
|
|
318
327
|
onReady?: (player: StormcloudVideoPlayer) => void;
|
package/lib/index.js
CHANGED
|
@@ -3255,6 +3255,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3255
3255
|
this.inAdBreak = false;
|
|
3256
3256
|
this.ptsDriftEmaMs = 0;
|
|
3257
3257
|
this.adPodQueue = [];
|
|
3258
|
+
this.vmapBreaks = [];
|
|
3259
|
+
this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
|
|
3258
3260
|
this.lastHeartbeatTime = 0;
|
|
3259
3261
|
this.currentAdIndex = 0;
|
|
3260
3262
|
this.totalAdsInBreak = 0;
|
|
@@ -4583,6 +4585,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4583
4585
|
return _ts_generator(this, function(_state) {
|
|
4584
4586
|
switch(_state.label){
|
|
4585
4587
|
case 0:
|
|
4588
|
+
if (!this.config.vmapUrl) return [
|
|
4589
|
+
3,
|
|
4590
|
+
2
|
|
4591
|
+
];
|
|
4592
|
+
return [
|
|
4593
|
+
4,
|
|
4594
|
+
this.fetchAndParseVmap(this.config.vmapUrl)
|
|
4595
|
+
];
|
|
4596
|
+
case 1:
|
|
4597
|
+
_state.sent();
|
|
4598
|
+
_state.label = 2;
|
|
4599
|
+
case 2:
|
|
4586
4600
|
vastMode = this.config.vastMode || "default";
|
|
4587
4601
|
if (this.config.debugAdTiming) {
|
|
4588
4602
|
console.log("[StormcloudVideoPlayer] VAST mode:", vastMode);
|
|
@@ -4628,7 +4642,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4628
4642
|
headers: headers
|
|
4629
4643
|
})
|
|
4630
4644
|
];
|
|
4631
|
-
case
|
|
4645
|
+
case 3:
|
|
4632
4646
|
response = _state.sent();
|
|
4633
4647
|
if (!response.ok) {
|
|
4634
4648
|
if (this.config.debugAdTiming) {
|
|
@@ -4642,7 +4656,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4642
4656
|
4,
|
|
4643
4657
|
response.json()
|
|
4644
4658
|
];
|
|
4645
|
-
case
|
|
4659
|
+
case 4:
|
|
4646
4660
|
data = _state.sent();
|
|
4647
4661
|
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;
|
|
4648
4662
|
if (imaPayload) {
|
|
@@ -4670,6 +4684,171 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4670
4684
|
}).call(this);
|
|
4671
4685
|
}
|
|
4672
4686
|
},
|
|
4687
|
+
{
|
|
4688
|
+
key: "fetchAndParseVmap",
|
|
4689
|
+
value: function fetchAndParseVmap(vmapUrl) {
|
|
4690
|
+
return _async_to_generator(function() {
|
|
4691
|
+
var response, vmapXml, error;
|
|
4692
|
+
return _ts_generator(this, function(_state) {
|
|
4693
|
+
switch(_state.label){
|
|
4694
|
+
case 0:
|
|
4695
|
+
if (!vmapUrl.trim()) {
|
|
4696
|
+
return [
|
|
4697
|
+
2
|
|
4698
|
+
];
|
|
4699
|
+
}
|
|
4700
|
+
_state.label = 1;
|
|
4701
|
+
case 1:
|
|
4702
|
+
_state.trys.push([
|
|
4703
|
+
1,
|
|
4704
|
+
4,
|
|
4705
|
+
,
|
|
4706
|
+
5
|
|
4707
|
+
]);
|
|
4708
|
+
return [
|
|
4709
|
+
4,
|
|
4710
|
+
fetch(vmapUrl)
|
|
4711
|
+
];
|
|
4712
|
+
case 2:
|
|
4713
|
+
response = _state.sent();
|
|
4714
|
+
if (!response.ok) {
|
|
4715
|
+
throw new Error("Failed to fetch VMAP (".concat(response.status, ")"));
|
|
4716
|
+
}
|
|
4717
|
+
return [
|
|
4718
|
+
4,
|
|
4719
|
+
response.text()
|
|
4720
|
+
];
|
|
4721
|
+
case 3:
|
|
4722
|
+
vmapXml = _state.sent();
|
|
4723
|
+
this.vmapBreaks = this.parseVmapToBreaks(vmapXml);
|
|
4724
|
+
this.consumedVmapBreakIds.clear();
|
|
4725
|
+
if (this.config.debugAdTiming) {
|
|
4726
|
+
console.log("[StormcloudVideoPlayer] Loaded ".concat(this.vmapBreaks.length, " VMAP ad break(s) from:"), vmapUrl);
|
|
4727
|
+
}
|
|
4728
|
+
return [
|
|
4729
|
+
3,
|
|
4730
|
+
5
|
|
4731
|
+
];
|
|
4732
|
+
case 4:
|
|
4733
|
+
error = _state.sent();
|
|
4734
|
+
this.vmapBreaks = [];
|
|
4735
|
+
this.consumedVmapBreakIds.clear();
|
|
4736
|
+
if (this.config.debugAdTiming) {
|
|
4737
|
+
console.warn("[StormcloudVideoPlayer] Failed to load VMAP:", error);
|
|
4738
|
+
}
|
|
4739
|
+
return [
|
|
4740
|
+
3,
|
|
4741
|
+
5
|
|
4742
|
+
];
|
|
4743
|
+
case 5:
|
|
4744
|
+
return [
|
|
4745
|
+
2
|
|
4746
|
+
];
|
|
4747
|
+
}
|
|
4748
|
+
});
|
|
4749
|
+
}).call(this);
|
|
4750
|
+
}
|
|
4751
|
+
},
|
|
4752
|
+
{
|
|
4753
|
+
key: "parseVmapToBreaks",
|
|
4754
|
+
value: function parseVmapToBreaks(vmapXml) {
|
|
4755
|
+
var _this = this;
|
|
4756
|
+
if (typeof DOMParser === "undefined") {
|
|
4757
|
+
return [];
|
|
4758
|
+
}
|
|
4759
|
+
var doc = new DOMParser().parseFromString(vmapXml, "application/xml");
|
|
4760
|
+
if (doc.querySelector("parsererror")) {
|
|
4761
|
+
if (this.config.debugAdTiming) {
|
|
4762
|
+
console.warn("[StormcloudVideoPlayer] Invalid VMAP XML received");
|
|
4763
|
+
}
|
|
4764
|
+
return [];
|
|
4765
|
+
}
|
|
4766
|
+
var adBreakNodes = Array.from(doc.querySelectorAll("AdBreak, vmap\\:AdBreak"));
|
|
4767
|
+
var parsed = [];
|
|
4768
|
+
adBreakNodes.forEach(function(node, index) {
|
|
4769
|
+
var timeOffsetRaw = (node.getAttribute("timeOffset") || "").trim();
|
|
4770
|
+
var startTimeMs = _this.parseVmapTimeOffsetToMs(timeOffsetRaw);
|
|
4771
|
+
if (startTimeMs == null) {
|
|
4772
|
+
return;
|
|
4773
|
+
}
|
|
4774
|
+
var adTagNode = node.querySelector("AdTagURI, vmap\\:AdTagURI");
|
|
4775
|
+
var adTagUrl = ((adTagNode === null || adTagNode === void 0 ? void 0 : adTagNode.textContent) || "").trim();
|
|
4776
|
+
if (!adTagUrl) {
|
|
4777
|
+
return;
|
|
4778
|
+
}
|
|
4779
|
+
var breakId = node.getAttribute("breakId") || "vmap-break-".concat(index, "-").concat(timeOffsetRaw || "unknown");
|
|
4780
|
+
parsed.push({
|
|
4781
|
+
id: breakId,
|
|
4782
|
+
startTimeMs: startTimeMs,
|
|
4783
|
+
vastTagUrl: adTagUrl
|
|
4784
|
+
});
|
|
4785
|
+
});
|
|
4786
|
+
parsed.sort(function(a, b) {
|
|
4787
|
+
var aStart = a.startTimeMs < 0 ? Number.MAX_SAFE_INTEGER : a.startTimeMs;
|
|
4788
|
+
var bStart = b.startTimeMs < 0 ? Number.MAX_SAFE_INTEGER : b.startTimeMs;
|
|
4789
|
+
return aStart - bStart;
|
|
4790
|
+
});
|
|
4791
|
+
return parsed;
|
|
4792
|
+
}
|
|
4793
|
+
},
|
|
4794
|
+
{
|
|
4795
|
+
key: "parseVmapTimeOffsetToMs",
|
|
4796
|
+
value: function parseVmapTimeOffsetToMs(timeOffset) {
|
|
4797
|
+
if (!timeOffset) {
|
|
4798
|
+
return void 0;
|
|
4799
|
+
}
|
|
4800
|
+
var normalized = timeOffset.trim().toLowerCase();
|
|
4801
|
+
if (normalized === "start") {
|
|
4802
|
+
return 0;
|
|
4803
|
+
}
|
|
4804
|
+
if (normalized === "end") {
|
|
4805
|
+
return -1;
|
|
4806
|
+
}
|
|
4807
|
+
var hms = timeOffset.match(/^(\d{1,2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/);
|
|
4808
|
+
if (hms) {
|
|
4809
|
+
var _hms = _sliced_to_array(hms, 5), hh = _hms[1], mm = _hms[2], ss = _hms[3], tmp = _hms[4], ms = tmp === void 0 ? "0" : tmp;
|
|
4810
|
+
var hours = Number(hh);
|
|
4811
|
+
var minutes = Number(mm);
|
|
4812
|
+
var seconds = Number(ss);
|
|
4813
|
+
var millis = Number(ms.padEnd(3, "0").slice(0, 3));
|
|
4814
|
+
return (hours * 3600 + minutes * 60 + seconds) * 1e3 + millis;
|
|
4815
|
+
}
|
|
4816
|
+
var percent = timeOffset.match(/^(\d+(?:\.\d+)?)%$/);
|
|
4817
|
+
if (percent) {
|
|
4818
|
+
var ratio = Number(percent[1]) / 100;
|
|
4819
|
+
var durationSec = this.video.duration;
|
|
4820
|
+
if (Number.isFinite(durationSec) && durationSec > 0) {
|
|
4821
|
+
return Math.floor(durationSec * 1e3 * ratio);
|
|
4822
|
+
}
|
|
4823
|
+
return void 0;
|
|
4824
|
+
}
|
|
4825
|
+
return void 0;
|
|
4826
|
+
}
|
|
4827
|
+
},
|
|
4828
|
+
{
|
|
4829
|
+
key: "getAdBreakKey",
|
|
4830
|
+
value: function getAdBreakKey(adBreak) {
|
|
4831
|
+
if (adBreak.id) {
|
|
4832
|
+
return adBreak.id;
|
|
4833
|
+
}
|
|
4834
|
+
return "".concat(adBreak.startTimeMs, "-").concat(adBreak.vastTagUrl || "");
|
|
4835
|
+
}
|
|
4836
|
+
},
|
|
4837
|
+
{
|
|
4838
|
+
key: "resolveBreakStartMs",
|
|
4839
|
+
value: function resolveBreakStartMs(adBreak) {
|
|
4840
|
+
if (adBreak.startTimeMs >= 0) {
|
|
4841
|
+
return adBreak.startTimeMs;
|
|
4842
|
+
}
|
|
4843
|
+
if (adBreak.startTimeMs === -1) {
|
|
4844
|
+
var durationSec = this.video.duration;
|
|
4845
|
+
if (Number.isFinite(durationSec) && durationSec > 0) {
|
|
4846
|
+
return Math.floor(durationSec * 1e3);
|
|
4847
|
+
}
|
|
4848
|
+
}
|
|
4849
|
+
return void 0;
|
|
4850
|
+
}
|
|
4851
|
+
},
|
|
4673
4852
|
{
|
|
4674
4853
|
key: "getCurrentAdIndex",
|
|
4675
4854
|
value: function getCurrentAdIndex() {
|
|
@@ -4760,10 +4939,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4760
4939
|
var scheduled = this.findCurrentOrNextBreak(this.video.currentTime * 1e3);
|
|
4761
4940
|
var tags = this.selectVastTagsForBreak(scheduled);
|
|
4762
4941
|
var baseVastUrl;
|
|
4763
|
-
if (
|
|
4764
|
-
baseVastUrl = this.apiVastTagUrl;
|
|
4765
|
-
} else if (tags && tags.length > 0 && tags[0]) {
|
|
4942
|
+
if (tags && tags.length > 0 && tags[0]) {
|
|
4766
4943
|
baseVastUrl = tags[0];
|
|
4944
|
+
} else if (this.apiVastTagUrl) {
|
|
4945
|
+
baseVastUrl = this.apiVastTagUrl;
|
|
4767
4946
|
} else {
|
|
4768
4947
|
if (this.config.debugAdTiming) {
|
|
4769
4948
|
console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
@@ -5213,11 +5392,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5213
5392
|
switch(_state.label){
|
|
5214
5393
|
case 0:
|
|
5215
5394
|
scheduled = this.findCurrentOrNextBreak(this.video.currentTime * 1e3);
|
|
5395
|
+
if (scheduled) {
|
|
5396
|
+
this.consumedVmapBreakIds.add(this.getAdBreakKey(scheduled));
|
|
5397
|
+
}
|
|
5216
5398
|
tags = this.selectVastTagsForBreak(scheduled);
|
|
5217
|
-
if (
|
|
5218
|
-
baseVastUrl = this.apiVastTagUrl;
|
|
5219
|
-
} else if (tags && tags.length > 0 && tags[0]) {
|
|
5399
|
+
if (tags && tags.length > 0 && tags[0]) {
|
|
5220
5400
|
baseVastUrl = tags[0];
|
|
5401
|
+
} else if (this.apiVastTagUrl) {
|
|
5402
|
+
baseVastUrl = this.apiVastTagUrl;
|
|
5221
5403
|
} else {
|
|
5222
5404
|
this.clearPendingAdBreak();
|
|
5223
5405
|
return [
|
|
@@ -6096,15 +6278,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6096
6278
|
{
|
|
6097
6279
|
key: "findCurrentOrNextBreak",
|
|
6098
6280
|
value: function findCurrentOrNextBreak(nowMs) {
|
|
6099
|
-
var schedule =
|
|
6281
|
+
var schedule = this.vmapBreaks;
|
|
6100
6282
|
var candidate;
|
|
6101
6283
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
6102
6284
|
try {
|
|
6103
6285
|
for(var _iterator = schedule[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
6104
6286
|
var b = _step.value;
|
|
6105
|
-
var _this_config_driftToleranceMs;
|
|
6287
|
+
var _this_config_driftToleranceMs, _this_resolveBreakStartMs;
|
|
6288
|
+
if (this.consumedVmapBreakIds.has(this.getAdBreakKey(b))) {
|
|
6289
|
+
continue;
|
|
6290
|
+
}
|
|
6291
|
+
var breakStartMs = this.resolveBreakStartMs(b);
|
|
6292
|
+
if (breakStartMs == null) {
|
|
6293
|
+
continue;
|
|
6294
|
+
}
|
|
6106
6295
|
var tol = (_this_config_driftToleranceMs = this.config.driftToleranceMs) !== null && _this_config_driftToleranceMs !== void 0 ? _this_config_driftToleranceMs : 1e3;
|
|
6107
|
-
if (
|
|
6296
|
+
if (breakStartMs <= nowMs + tol && (candidate == null || breakStartMs > ((_this_resolveBreakStartMs = this.resolveBreakStartMs(candidate)) !== null && _this_resolveBreakStartMs !== void 0 ? _this_resolveBreakStartMs : 0))) {
|
|
6108
6297
|
candidate = b;
|
|
6109
6298
|
}
|
|
6110
6299
|
}
|
|
@@ -6128,11 +6317,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6128
6317
|
{
|
|
6129
6318
|
key: "onTimeUpdate",
|
|
6130
6319
|
value: function onTimeUpdate(currentTimeSec) {
|
|
6131
|
-
|
|
6320
|
+
var _this = this;
|
|
6321
|
+
if (this.ima.isAdPlaying() || this.inAdBreak) return;
|
|
6132
6322
|
var nowMs = currentTimeSec * 1e3;
|
|
6133
6323
|
var breakToPlay = this.findBreakForTime(nowMs);
|
|
6134
6324
|
if (breakToPlay) {
|
|
6135
|
-
this.handleMidAdJoin(breakToPlay, nowMs)
|
|
6325
|
+
void this.handleMidAdJoin(breakToPlay, nowMs).catch(function(error) {
|
|
6326
|
+
if (_this.config.debugAdTiming) {
|
|
6327
|
+
console.warn("[StormcloudVideoPlayer] Mid-roll VMAP join failed gracefully:", error);
|
|
6328
|
+
}
|
|
6329
|
+
});
|
|
6136
6330
|
}
|
|
6137
6331
|
}
|
|
6138
6332
|
},
|
|
@@ -6140,40 +6334,76 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6140
6334
|
key: "handleMidAdJoin",
|
|
6141
6335
|
value: function handleMidAdJoin(adBreak, nowMs) {
|
|
6142
6336
|
return _async_to_generator(function() {
|
|
6143
|
-
var _adBreak_durationMs, durationMs, endMs, remainingMs, tags, first, rest;
|
|
6337
|
+
var _adBreak_durationMs, _this_config_driftToleranceMs, key, breakStartMs, durationMs, endMs, tol, inWindow, remainingMs, tags, first, rest, error;
|
|
6144
6338
|
return _ts_generator(this, function(_state) {
|
|
6145
6339
|
switch(_state.label){
|
|
6146
6340
|
case 0:
|
|
6341
|
+
key = this.getAdBreakKey(adBreak);
|
|
6342
|
+
if (this.consumedVmapBreakIds.has(key)) {
|
|
6343
|
+
return [
|
|
6344
|
+
2
|
|
6345
|
+
];
|
|
6346
|
+
}
|
|
6347
|
+
breakStartMs = this.resolveBreakStartMs(adBreak);
|
|
6348
|
+
if (breakStartMs == null) {
|
|
6349
|
+
return [
|
|
6350
|
+
2
|
|
6351
|
+
];
|
|
6352
|
+
}
|
|
6147
6353
|
durationMs = (_adBreak_durationMs = adBreak.durationMs) !== null && _adBreak_durationMs !== void 0 ? _adBreak_durationMs : 0;
|
|
6148
|
-
endMs =
|
|
6149
|
-
|
|
6354
|
+
endMs = breakStartMs + durationMs;
|
|
6355
|
+
tol = (_this_config_driftToleranceMs = this.config.driftToleranceMs) !== null && _this_config_driftToleranceMs !== void 0 ? _this_config_driftToleranceMs : 1e3;
|
|
6356
|
+
inWindow = durationMs > 0 ? nowMs > breakStartMs && nowMs < endMs : nowMs + tol >= breakStartMs;
|
|
6357
|
+
if (!inWindow) return [
|
|
6150
6358
|
3,
|
|
6151
|
-
|
|
6359
|
+
4
|
|
6152
6360
|
];
|
|
6153
|
-
|
|
6361
|
+
this.consumedVmapBreakIds.add(key);
|
|
6362
|
+
remainingMs = durationMs > 0 ? Math.max(0, endMs - nowMs) : 0;
|
|
6154
6363
|
tags = this.selectVastTagsForBreak(adBreak) || (this.apiVastTagUrl ? [
|
|
6155
6364
|
this.apiVastTagUrl
|
|
6156
6365
|
] : void 0);
|
|
6157
6366
|
if (!(tags && tags.length > 0)) return [
|
|
6158
6367
|
3,
|
|
6159
|
-
|
|
6368
|
+
4
|
|
6160
6369
|
];
|
|
6161
6370
|
first = tags[0];
|
|
6162
6371
|
rest = tags.slice(1);
|
|
6163
6372
|
this.adPodQueue = rest;
|
|
6164
6373
|
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
6374
|
+
_state.label = 1;
|
|
6375
|
+
case 1:
|
|
6376
|
+
_state.trys.push([
|
|
6377
|
+
1,
|
|
6378
|
+
3,
|
|
6379
|
+
,
|
|
6380
|
+
4
|
|
6381
|
+
]);
|
|
6165
6382
|
return [
|
|
6166
6383
|
4,
|
|
6167
6384
|
this.playSingleAd(first)
|
|
6168
6385
|
];
|
|
6169
|
-
case
|
|
6386
|
+
case 2:
|
|
6170
6387
|
_state.sent();
|
|
6171
6388
|
this.inAdBreak = true;
|
|
6172
6389
|
this.expectedAdBreakDurationMs = remainingMs;
|
|
6173
6390
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6174
6391
|
this.scheduleAdStopCountdown(remainingMs);
|
|
6175
|
-
|
|
6176
|
-
|
|
6392
|
+
return [
|
|
6393
|
+
3,
|
|
6394
|
+
4
|
|
6395
|
+
];
|
|
6396
|
+
case 3:
|
|
6397
|
+
error = _state.sent();
|
|
6398
|
+
this.adPodQueue = [];
|
|
6399
|
+
if (this.config.debugAdTiming) {
|
|
6400
|
+
console.warn("[StormcloudVideoPlayer] Mid-roll VMAP ad request failed:", error);
|
|
6401
|
+
}
|
|
6402
|
+
return [
|
|
6403
|
+
3,
|
|
6404
|
+
4
|
|
6405
|
+
];
|
|
6406
|
+
case 4:
|
|
6177
6407
|
return [
|
|
6178
6408
|
2
|
|
6179
6409
|
];
|
|
@@ -6879,13 +7109,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6879
7109
|
{
|
|
6880
7110
|
key: "findBreakForTime",
|
|
6881
7111
|
value: function findBreakForTime(nowMs) {
|
|
6882
|
-
var
|
|
7112
|
+
var _this_config_driftToleranceMs;
|
|
7113
|
+
var schedule = this.vmapBreaks;
|
|
7114
|
+
var tol = (_this_config_driftToleranceMs = this.config.driftToleranceMs) !== null && _this_config_driftToleranceMs !== void 0 ? _this_config_driftToleranceMs : 1e3;
|
|
6883
7115
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
6884
7116
|
try {
|
|
6885
7117
|
for(var _iterator = schedule[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
6886
7118
|
var b = _step.value;
|
|
6887
|
-
|
|
6888
|
-
|
|
7119
|
+
if (this.consumedVmapBreakIds.has(this.getAdBreakKey(b))) {
|
|
7120
|
+
continue;
|
|
7121
|
+
}
|
|
7122
|
+
var breakStartMs = this.resolveBreakStartMs(b);
|
|
7123
|
+
if (breakStartMs == null) {
|
|
7124
|
+
continue;
|
|
7125
|
+
}
|
|
7126
|
+
var end = breakStartMs + (b.durationMs || 0);
|
|
7127
|
+
if (nowMs >= breakStartMs && (b.durationMs ? nowMs < end : nowMs <= breakStartMs + tol)) {
|
|
6889
7128
|
return b;
|
|
6890
7129
|
}
|
|
6891
7130
|
}
|
|
@@ -7117,13 +7356,14 @@ var CRITICAL_PROPS = [
|
|
|
7117
7356
|
"src",
|
|
7118
7357
|
"allowNativeHls",
|
|
7119
7358
|
"licenseKey",
|
|
7359
|
+
"vmapUrl",
|
|
7120
7360
|
"lowLatencyMode",
|
|
7121
7361
|
"driftToleranceMs",
|
|
7122
7362
|
"vastMode"
|
|
7123
7363
|
];
|
|
7124
7364
|
var CONTROLS_HIDE_DELAY = 3e3;
|
|
7125
7365
|
var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
7126
|
-
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, adPlayerType = props.adPlayerType, minSegmentsBeforePlay = props.minSegmentsBeforePlay, restVideoAttrs = _object_without_properties(props, [
|
|
7366
|
+
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, vmapUrl = props.vmapUrl, adPlayerType = props.adPlayerType, minSegmentsBeforePlay = props.minSegmentsBeforePlay, restVideoAttrs = _object_without_properties(props, [
|
|
7127
7367
|
"src",
|
|
7128
7368
|
"autoplay",
|
|
7129
7369
|
"muted",
|
|
@@ -7150,6 +7390,7 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
|
7150
7390
|
"licenseKey",
|
|
7151
7391
|
"vastMode",
|
|
7152
7392
|
"vastTagUrl",
|
|
7393
|
+
"vmapUrl",
|
|
7153
7394
|
"adPlayerType",
|
|
7154
7395
|
"minSegmentsBeforePlay"
|
|
7155
7396
|
]);
|
|
@@ -7289,6 +7530,7 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
|
7289
7530
|
src,
|
|
7290
7531
|
allowNativeHls,
|
|
7291
7532
|
licenseKey,
|
|
7533
|
+
vmapUrl,
|
|
7292
7534
|
lowLatencyMode,
|
|
7293
7535
|
driftToleranceMs,
|
|
7294
7536
|
vastMode
|
|
@@ -7331,6 +7573,7 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
|
7331
7573
|
if (licenseKey !== void 0) cfg.licenseKey = licenseKey;
|
|
7332
7574
|
if (vastMode !== void 0) cfg.vastMode = vastMode;
|
|
7333
7575
|
if (vastTagUrl !== void 0) cfg.vastTagUrl = vastTagUrl;
|
|
7576
|
+
if (vmapUrl !== void 0) cfg.vmapUrl = vmapUrl;
|
|
7334
7577
|
if (adPlayerType !== void 0) cfg.adPlayerType = adPlayerType;
|
|
7335
7578
|
if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
|
|
7336
7579
|
var player = new StormcloudVideoPlayer(cfg);
|
|
@@ -8370,6 +8613,7 @@ var defaultProps = {
|
|
|
8370
8613
|
showCustomControls: false,
|
|
8371
8614
|
hideLoadingIndicator: false,
|
|
8372
8615
|
licenseKey: "",
|
|
8616
|
+
vmapUrl: "",
|
|
8373
8617
|
adFailsafeTimeoutMs: 1e4,
|
|
8374
8618
|
minSegmentsBeforePlay: 2,
|
|
8375
8619
|
onStart: noop,
|
|
@@ -9316,6 +9560,7 @@ var SUPPORTED_PROPS = [
|
|
|
9316
9560
|
"debugAdTiming",
|
|
9317
9561
|
"showCustomControls",
|
|
9318
9562
|
"licenseKey",
|
|
9563
|
+
"vmapUrl",
|
|
9319
9564
|
"adFailsafeTimeoutMs",
|
|
9320
9565
|
"minSegmentsBeforePlay",
|
|
9321
9566
|
"onReady",
|