stormcloud-video-player 0.6.10 → 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 +101 -13
- 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 +101 -13
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +101 -13
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +101 -13
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +101 -13
- package/lib/players/index.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 +101 -13
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -701,7 +701,8 @@ function fireTrackingPixels(urls, sessionId) {
|
|
|
701
701
|
});
|
|
702
702
|
}
|
|
703
703
|
// src/sdk/vastManager.ts
|
|
704
|
-
var
|
|
704
|
+
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";
|
|
705
|
+
var ADSTORM_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
|
|
705
706
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
706
707
|
var MAX_RETRIES = 3;
|
|
707
708
|
var RETRY_BACKOFF_MS = 1500;
|
|
@@ -709,6 +710,7 @@ function createVastManager() {
|
|
|
709
710
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
710
711
|
var _options_debug;
|
|
711
712
|
var initialized = false;
|
|
713
|
+
var vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
712
714
|
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
713
715
|
function log() {
|
|
714
716
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -730,17 +732,97 @@ function createVastManager() {
|
|
|
730
732
|
"[VastManager]"
|
|
731
733
|
].concat(_to_consumable_array(args)));
|
|
732
734
|
}
|
|
735
|
+
function fetchVastUrlFromApi() {
|
|
736
|
+
return _async_to_generator(function() {
|
|
737
|
+
var apiUrl, _data_response_ima_publisherdeskima, _data_response_ima, _data_response, res, data, payload, err;
|
|
738
|
+
return _ts_generator(this, function(_state) {
|
|
739
|
+
switch(_state.label){
|
|
740
|
+
case 0:
|
|
741
|
+
apiUrl = options.adstormApiUrl || ADSTORM_API_URL;
|
|
742
|
+
_state.label = 1;
|
|
743
|
+
case 1:
|
|
744
|
+
_state.trys.push([
|
|
745
|
+
1,
|
|
746
|
+
4,
|
|
747
|
+
,
|
|
748
|
+
5
|
|
749
|
+
]);
|
|
750
|
+
return [
|
|
751
|
+
4,
|
|
752
|
+
fetch(apiUrl, {
|
|
753
|
+
method: "GET",
|
|
754
|
+
headers: {
|
|
755
|
+
Authorization: "Bearer ".concat(options.licenseKey),
|
|
756
|
+
Accept: "application/json"
|
|
757
|
+
}
|
|
758
|
+
})
|
|
759
|
+
];
|
|
760
|
+
case 2:
|
|
761
|
+
res = _state.sent();
|
|
762
|
+
if (!res.ok) {
|
|
763
|
+
warn("Failed to fetch VAST URL from API (HTTP ".concat(res.status, "), using fallback"));
|
|
764
|
+
return [
|
|
765
|
+
2
|
|
766
|
+
];
|
|
767
|
+
}
|
|
768
|
+
return [
|
|
769
|
+
4,
|
|
770
|
+
res.json()
|
|
771
|
+
];
|
|
772
|
+
case 3:
|
|
773
|
+
data = _state.sent();
|
|
774
|
+
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;
|
|
775
|
+
if (payload) {
|
|
776
|
+
vastTagUrl = payload;
|
|
777
|
+
log("VAST tag URL fetched from API:", vastTagUrl.split("?")[0]);
|
|
778
|
+
} else {
|
|
779
|
+
log("API response had no VAST payload, using fallback URL");
|
|
780
|
+
}
|
|
781
|
+
return [
|
|
782
|
+
3,
|
|
783
|
+
5
|
|
784
|
+
];
|
|
785
|
+
case 4:
|
|
786
|
+
err = _state.sent();
|
|
787
|
+
warn("Error fetching VAST URL from API, using fallback:", err);
|
|
788
|
+
return [
|
|
789
|
+
3,
|
|
790
|
+
5
|
|
791
|
+
];
|
|
792
|
+
case 5:
|
|
793
|
+
return [
|
|
794
|
+
2
|
|
795
|
+
];
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
})();
|
|
799
|
+
}
|
|
733
800
|
function initialize() {
|
|
734
801
|
return _async_to_generator(function() {
|
|
735
802
|
return _ts_generator(this, function(_state) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
803
|
+
switch(_state.label){
|
|
804
|
+
case 0:
|
|
805
|
+
if (initialized) return [
|
|
806
|
+
2
|
|
807
|
+
];
|
|
808
|
+
initialized = true;
|
|
809
|
+
if (!options.licenseKey) return [
|
|
810
|
+
3,
|
|
811
|
+
2
|
|
812
|
+
];
|
|
813
|
+
return [
|
|
814
|
+
4,
|
|
815
|
+
fetchVastUrlFromApi()
|
|
816
|
+
];
|
|
817
|
+
case 1:
|
|
818
|
+
_state.sent();
|
|
819
|
+
_state.label = 2;
|
|
820
|
+
case 2:
|
|
821
|
+
log("Initialized, VAST tag URL:", vastTagUrl.split("?")[0]);
|
|
822
|
+
return [
|
|
823
|
+
2
|
|
824
|
+
];
|
|
825
|
+
}
|
|
744
826
|
});
|
|
745
827
|
})();
|
|
746
828
|
}
|
|
@@ -754,7 +836,7 @@ function createVastManager() {
|
|
|
754
836
|
throw new Error("VastManager not initialized. Call initialize() first.");
|
|
755
837
|
}
|
|
756
838
|
correlator = Math.floor(Math.random() * 1e12).toString();
|
|
757
|
-
url =
|
|
839
|
+
url = vastTagUrl.replace("[placeholder]", correlator);
|
|
758
840
|
log("Fetching VAST tag, correlator:", correlator);
|
|
759
841
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
760
842
|
timeoutId = setTimeout(function() {
|
|
@@ -948,6 +1030,7 @@ function createVastManager() {
|
|
|
948
1030
|
}
|
|
949
1031
|
function destroy() {
|
|
950
1032
|
initialized = false;
|
|
1033
|
+
vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
951
1034
|
log("Destroyed");
|
|
952
1035
|
}
|
|
953
1036
|
return {
|
|
@@ -3135,9 +3218,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3135
3218
|
this.video = config.videoElement;
|
|
3136
3219
|
this.adTransitionGapMs = (_this_config_adTransitionGapMs = this.config.adTransitionGapMs) !== null && _this_config_adTransitionGapMs !== void 0 ? _this_config_adTransitionGapMs : 100;
|
|
3137
3220
|
logBrowserInfo(config.debugAdTiming);
|
|
3138
|
-
this.vastManager = createVastManager(
|
|
3139
|
-
debug: !!config.debugAdTiming
|
|
3140
|
-
}
|
|
3221
|
+
this.vastManager = createVastManager(_object_spread({
|
|
3222
|
+
debug: config.debugAdTiming !== void 0 ? !!config.debugAdTiming : false
|
|
3223
|
+
}, config.licenseKey ? {
|
|
3224
|
+
licenseKey: config.licenseKey
|
|
3225
|
+
} : {}));
|
|
3141
3226
|
var browserForAdLayer = detectBrowser();
|
|
3142
3227
|
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
3143
3228
|
this.adLayer = createVastAdLayer(this.video, {
|
|
@@ -3188,6 +3273,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3188
3273
|
this.attach();
|
|
3189
3274
|
}
|
|
3190
3275
|
this.initializeTracking();
|
|
3276
|
+
if (!this.config.disableAds) {
|
|
3277
|
+
this.vastManager.initialize().catch(function() {});
|
|
3278
|
+
}
|
|
3191
3279
|
if (!this.shouldUseNativeHls()) return [
|
|
3192
3280
|
3,
|
|
3193
3281
|
3
|