stormcloud-video-player 0.6.9 → 0.6.11
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 +124 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +124 -17
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +124 -17
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +124 -17
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +124 -17
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.cjs +15 -1
- package/lib/sdk/vastAdLayer.cjs.map +1 -1
- package/lib/sdk/vastManager.cjs +93 -10
- package/lib/sdk/vastManager.cjs.map +1 -1
- package/lib/sdk/vastManager.d.cts +2 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +124 -17
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -649,7 +649,8 @@ function fireTrackingPixels(urls, sessionId) {
|
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
651
|
// src/sdk/vastManager.ts
|
|
652
|
-
var
|
|
652
|
+
var VAST_TAG_URL_FALLBACK = "https://pubads.g.doubleclick.net/gampad/ads?iu=/21821455290/Airy-Android&description_url=http%3A%2F%2Fairy.tv&tfcd=0&npa=0&sz=1x1%7C300x250%7C400x300%7C640x480&gdfp_req=1&unviewed_position_start=1&correlator=[placeholder]&vpos=preroll&output=vast&env=vp&vpmute=0&vpa=click";
|
|
653
|
+
var ADSTORM_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
|
|
653
654
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
654
655
|
var MAX_RETRIES = 3;
|
|
655
656
|
var RETRY_BACKOFF_MS = 1500;
|
|
@@ -657,6 +658,7 @@ function createVastManager() {
|
|
|
657
658
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
658
659
|
var _options_debug;
|
|
659
660
|
var initialized = false;
|
|
661
|
+
var vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
660
662
|
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
661
663
|
function log() {
|
|
662
664
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -678,17 +680,97 @@ function createVastManager() {
|
|
|
678
680
|
"[VastManager]"
|
|
679
681
|
].concat(_to_consumable_array(args)));
|
|
680
682
|
}
|
|
683
|
+
function fetchVastUrlFromApi() {
|
|
684
|
+
return _async_to_generator(function() {
|
|
685
|
+
var apiUrl, _data_response_ima_publisherdeskima, _data_response_ima, _data_response, res, data, payload, err;
|
|
686
|
+
return _ts_generator(this, function(_state) {
|
|
687
|
+
switch(_state.label){
|
|
688
|
+
case 0:
|
|
689
|
+
apiUrl = options.adstormApiUrl || ADSTORM_API_URL;
|
|
690
|
+
_state.label = 1;
|
|
691
|
+
case 1:
|
|
692
|
+
_state.trys.push([
|
|
693
|
+
1,
|
|
694
|
+
4,
|
|
695
|
+
,
|
|
696
|
+
5
|
|
697
|
+
]);
|
|
698
|
+
return [
|
|
699
|
+
4,
|
|
700
|
+
fetch(apiUrl, {
|
|
701
|
+
method: "GET",
|
|
702
|
+
headers: {
|
|
703
|
+
Authorization: "Bearer ".concat(options.licenseKey),
|
|
704
|
+
Accept: "application/json"
|
|
705
|
+
}
|
|
706
|
+
})
|
|
707
|
+
];
|
|
708
|
+
case 2:
|
|
709
|
+
res = _state.sent();
|
|
710
|
+
if (!res.ok) {
|
|
711
|
+
warn("Failed to fetch VAST URL from API (HTTP ".concat(res.status, "), using fallback"));
|
|
712
|
+
return [
|
|
713
|
+
2
|
|
714
|
+
];
|
|
715
|
+
}
|
|
716
|
+
return [
|
|
717
|
+
4,
|
|
718
|
+
res.json()
|
|
719
|
+
];
|
|
720
|
+
case 3:
|
|
721
|
+
data = _state.sent();
|
|
722
|
+
payload = data === null || data === void 0 ? void 0 : (_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;
|
|
723
|
+
if (payload) {
|
|
724
|
+
vastTagUrl = payload;
|
|
725
|
+
log("VAST tag URL fetched from API:", vastTagUrl.split("?")[0]);
|
|
726
|
+
} else {
|
|
727
|
+
log("API response had no VAST payload, using fallback URL");
|
|
728
|
+
}
|
|
729
|
+
return [
|
|
730
|
+
3,
|
|
731
|
+
5
|
|
732
|
+
];
|
|
733
|
+
case 4:
|
|
734
|
+
err = _state.sent();
|
|
735
|
+
warn("Error fetching VAST URL from API, using fallback:", err);
|
|
736
|
+
return [
|
|
737
|
+
3,
|
|
738
|
+
5
|
|
739
|
+
];
|
|
740
|
+
case 5:
|
|
741
|
+
return [
|
|
742
|
+
2
|
|
743
|
+
];
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
})();
|
|
747
|
+
}
|
|
681
748
|
function initialize() {
|
|
682
749
|
return _async_to_generator(function() {
|
|
683
750
|
return _ts_generator(this, function(_state) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
751
|
+
switch(_state.label){
|
|
752
|
+
case 0:
|
|
753
|
+
if (initialized) return [
|
|
754
|
+
2
|
|
755
|
+
];
|
|
756
|
+
initialized = true;
|
|
757
|
+
if (!options.licenseKey) return [
|
|
758
|
+
3,
|
|
759
|
+
2
|
|
760
|
+
];
|
|
761
|
+
return [
|
|
762
|
+
4,
|
|
763
|
+
fetchVastUrlFromApi()
|
|
764
|
+
];
|
|
765
|
+
case 1:
|
|
766
|
+
_state.sent();
|
|
767
|
+
_state.label = 2;
|
|
768
|
+
case 2:
|
|
769
|
+
log("Initialized, VAST tag URL:", vastTagUrl.split("?")[0]);
|
|
770
|
+
return [
|
|
771
|
+
2
|
|
772
|
+
];
|
|
773
|
+
}
|
|
692
774
|
});
|
|
693
775
|
})();
|
|
694
776
|
}
|
|
@@ -702,7 +784,7 @@ function createVastManager() {
|
|
|
702
784
|
throw new Error("VastManager not initialized. Call initialize() first.");
|
|
703
785
|
}
|
|
704
786
|
correlator = Math.floor(Math.random() * 1e12).toString();
|
|
705
|
-
url =
|
|
787
|
+
url = vastTagUrl.replace("[placeholder]", correlator);
|
|
706
788
|
log("Fetching VAST tag, correlator:", correlator);
|
|
707
789
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
708
790
|
timeoutId = setTimeout(function() {
|
|
@@ -896,6 +978,7 @@ function createVastManager() {
|
|
|
896
978
|
}
|
|
897
979
|
function destroy() {
|
|
898
980
|
initialized = false;
|
|
981
|
+
vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
899
982
|
log("Destroyed");
|
|
900
983
|
}
|
|
901
984
|
return {
|
|
@@ -937,6 +1020,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
937
1020
|
var adHls;
|
|
938
1021
|
var adContainerEl;
|
|
939
1022
|
var currentAd;
|
|
1023
|
+
var currentMediaFile;
|
|
940
1024
|
var sessionId;
|
|
941
1025
|
var destroyed = false;
|
|
942
1026
|
var tornDown = false;
|
|
@@ -1183,7 +1267,12 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1183
1267
|
adContainerEl.style.display = "none";
|
|
1184
1268
|
adContainerEl.style.pointerEvents = "none";
|
|
1185
1269
|
}
|
|
1186
|
-
emit("ad_impression"
|
|
1270
|
+
emit("ad_impression", {
|
|
1271
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
1272
|
+
adTitle: currentAd === null || currentAd === void 0 ? void 0 : currentAd.title,
|
|
1273
|
+
adUrl: currentMediaFile === null || currentMediaFile === void 0 ? void 0 : currentMediaFile.url,
|
|
1274
|
+
mediaType: currentMediaFile === null || currentMediaFile === void 0 ? void 0 : currentMediaFile.type
|
|
1275
|
+
});
|
|
1187
1276
|
emit("content_resume");
|
|
1188
1277
|
}
|
|
1189
1278
|
function handleAdError() {
|
|
@@ -1205,6 +1294,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1205
1294
|
adHls.destroy();
|
|
1206
1295
|
adHls = void 0;
|
|
1207
1296
|
}
|
|
1297
|
+
currentMediaFile = void 0;
|
|
1208
1298
|
if (adVideoElement) {
|
|
1209
1299
|
if (singleElementMode && adVideoElement === contentVideo) {
|
|
1210
1300
|
contentVideo.pause();
|
|
@@ -1369,6 +1459,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1369
1459
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1370
1460
|
adVideoElement.muted = false;
|
|
1371
1461
|
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1462
|
+
currentMediaFile = mediaFile2;
|
|
1372
1463
|
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1373
1464
|
startPlayback(mediaFile2);
|
|
1374
1465
|
return [
|
|
@@ -1415,6 +1506,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1415
1506
|
}
|
|
1416
1507
|
emit("content_pause");
|
|
1417
1508
|
mediaFile = selectBestMediaFile(ad.mediaFiles);
|
|
1509
|
+
currentMediaFile = mediaFile;
|
|
1418
1510
|
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile.url));
|
|
1419
1511
|
startPlayback(mediaFile);
|
|
1420
1512
|
return [
|
|
@@ -1580,6 +1672,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1580
1672
|
];
|
|
1581
1673
|
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1582
1674
|
teardownCurrentPlayback();
|
|
1675
|
+
currentMediaFile = slot.mediaFile;
|
|
1583
1676
|
adVideoElement = contentVideo;
|
|
1584
1677
|
adHls = void 0;
|
|
1585
1678
|
adPlaying = true;
|
|
@@ -1614,6 +1707,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1614
1707
|
case 2:
|
|
1615
1708
|
if (smartTVMode && !slot.videoEl) {
|
|
1616
1709
|
teardownCurrentPlayback();
|
|
1710
|
+
currentMediaFile = slot.mediaFile;
|
|
1617
1711
|
if (adVideoElement) {
|
|
1618
1712
|
adVideoElement.remove();
|
|
1619
1713
|
adVideoElement = void 0;
|
|
@@ -1645,6 +1739,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1645
1739
|
];
|
|
1646
1740
|
}
|
|
1647
1741
|
teardownCurrentPlayback();
|
|
1742
|
+
currentMediaFile = slot.mediaFile;
|
|
1648
1743
|
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1649
1744
|
adVideoElement.remove();
|
|
1650
1745
|
}
|
|
@@ -1776,6 +1871,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1776
1871
|
}
|
|
1777
1872
|
}
|
|
1778
1873
|
currentAd = void 0;
|
|
1874
|
+
currentMediaFile = void 0;
|
|
1779
1875
|
tornDown = false;
|
|
1780
1876
|
return [
|
|
1781
1877
|
2
|
|
@@ -1828,6 +1924,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1828
1924
|
}
|
|
1829
1925
|
adContainerEl = void 0;
|
|
1830
1926
|
currentAd = void 0;
|
|
1927
|
+
currentMediaFile = void 0;
|
|
1831
1928
|
listeners.clear();
|
|
1832
1929
|
},
|
|
1833
1930
|
isAdPlaying: function isAdPlaying() {
|
|
@@ -3069,9 +3166,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3069
3166
|
this.video = config.videoElement;
|
|
3070
3167
|
this.adTransitionGapMs = (_this_config_adTransitionGapMs = this.config.adTransitionGapMs) !== null && _this_config_adTransitionGapMs !== void 0 ? _this_config_adTransitionGapMs : 100;
|
|
3071
3168
|
logBrowserInfo(config.debugAdTiming);
|
|
3072
|
-
this.vastManager = createVastManager(
|
|
3073
|
-
debug: !!config.debugAdTiming
|
|
3074
|
-
}
|
|
3169
|
+
this.vastManager = createVastManager(_object_spread({
|
|
3170
|
+
debug: config.debugAdTiming !== void 0 ? !!config.debugAdTiming : false
|
|
3171
|
+
}, config.licenseKey ? {
|
|
3172
|
+
licenseKey: config.licenseKey
|
|
3173
|
+
} : {}));
|
|
3075
3174
|
var browserForAdLayer = detectBrowser();
|
|
3076
3175
|
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
3077
3176
|
this.adLayer = createVastAdLayer(this.video, {
|
|
@@ -3122,6 +3221,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3122
3221
|
this.attach();
|
|
3123
3222
|
}
|
|
3124
3223
|
this.initializeTracking();
|
|
3224
|
+
if (!this.config.disableAds) {
|
|
3225
|
+
this.vastManager.initialize().catch(function() {});
|
|
3226
|
+
}
|
|
3125
3227
|
if (!this.shouldUseNativeHls()) return [
|
|
3126
3228
|
3,
|
|
3127
3229
|
3
|
|
@@ -3575,13 +3677,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3575
3677
|
key: "attachAdLayerEventListeners",
|
|
3576
3678
|
value: function attachAdLayerEventListeners() {
|
|
3577
3679
|
var _this = this;
|
|
3578
|
-
this.adLayer.on("ad_impression", function() {
|
|
3680
|
+
this.adLayer.on("ad_impression", function(payload) {
|
|
3579
3681
|
if (_this.config.licenseKey) {
|
|
3682
|
+
var _ref;
|
|
3683
|
+
var adUrl = (_ref = payload === null || payload === void 0 ? void 0 : payload.adUrl) !== null && _ref !== void 0 ? _ref : _this.lastServedAdUrl;
|
|
3684
|
+
if (adUrl) {
|
|
3685
|
+
_this.lastServedAdUrl = adUrl;
|
|
3686
|
+
}
|
|
3580
3687
|
sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
|
|
3581
3688
|
source: _this.getAdSource(),
|
|
3582
3689
|
adIndex: _this.currentAdIndex
|
|
3583
|
-
},
|
|
3584
|
-
adUrl:
|
|
3690
|
+
}, adUrl ? {
|
|
3691
|
+
adUrl: adUrl
|
|
3585
3692
|
} : {}), {
|
|
3586
3693
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
3587
3694
|
}), _this.getAnalyticsContext());
|