stormcloud-video-player 0.6.10 → 0.6.12
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 +3 -1
- package/lib/index.cjs +296 -110
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +12 -1
- package/lib/index.d.ts +12 -1
- package/lib/index.js +273 -111
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +262 -108
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +262 -108
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +262 -108
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.d.cts +1 -1
- package/lib/sdk/vastManager.cjs +93 -10
- package/lib/sdk/vastManager.cjs.map +1 -1
- package/lib/sdk/vastManager.d.cts +3 -1
- package/lib/{types-DSKC4ySr.d.cts → types-FjAlGhAL.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +266 -110
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/mqttClient.cjs +174 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +9 -0
- package/lib/utils/tracking.cjs +119 -96
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +3 -2
- package/package.json +2 -1
package/lib/index.cjs
CHANGED
|
@@ -473,6 +473,9 @@ __export(index_exports, {
|
|
|
473
473
|
detectBrowser: function detectBrowser1() {
|
|
474
474
|
return detectBrowser;
|
|
475
475
|
},
|
|
476
|
+
disconnectMQTT: function disconnectMQTT1() {
|
|
477
|
+
return disconnectMQTT;
|
|
478
|
+
},
|
|
476
479
|
getBrowserConfigOverrides: function getBrowserConfigOverrides1() {
|
|
477
480
|
return getBrowserConfigOverrides;
|
|
478
481
|
},
|
|
@@ -482,9 +485,21 @@ __export(index_exports, {
|
|
|
482
485
|
getClientInfo: function getClientInfo1() {
|
|
483
486
|
return getClientInfo;
|
|
484
487
|
},
|
|
488
|
+
getMQTTStatus: function getMQTTStatus1() {
|
|
489
|
+
return getMQTTStatus;
|
|
490
|
+
},
|
|
491
|
+
initMQTTClient: function initMQTTClient1() {
|
|
492
|
+
return initMQTTClient;
|
|
493
|
+
},
|
|
485
494
|
initializePolyfills: function initializePolyfills1() {
|
|
486
495
|
return initializePolyfills;
|
|
487
496
|
},
|
|
497
|
+
isMQTTConfigured: function isMQTTConfigured1() {
|
|
498
|
+
return isMQTTConfigured;
|
|
499
|
+
},
|
|
500
|
+
isMQTTConnected: function isMQTTConnected1() {
|
|
501
|
+
return isMQTTConnected;
|
|
502
|
+
},
|
|
488
503
|
isMediaStream: function isMediaStream1() {
|
|
489
504
|
return isMediaStream;
|
|
490
505
|
},
|
|
@@ -506,6 +521,9 @@ __export(index_exports, {
|
|
|
506
521
|
players: function players() {
|
|
507
522
|
return players_default;
|
|
508
523
|
},
|
|
524
|
+
publishMQTT: function publishMQTT1() {
|
|
525
|
+
return publishMQTT;
|
|
526
|
+
},
|
|
509
527
|
randomString: function randomString1() {
|
|
510
528
|
return randomString;
|
|
511
529
|
},
|
|
@@ -831,7 +849,8 @@ function fireTrackingPixels(urls, sessionId) {
|
|
|
831
849
|
});
|
|
832
850
|
}
|
|
833
851
|
// src/sdk/vastManager.ts
|
|
834
|
-
var
|
|
852
|
+
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";
|
|
853
|
+
var ADSTORM_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
|
|
835
854
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
836
855
|
var MAX_RETRIES = 3;
|
|
837
856
|
var RETRY_BACKOFF_MS = 1500;
|
|
@@ -839,6 +858,7 @@ function createVastManager() {
|
|
|
839
858
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
840
859
|
var _options_debug;
|
|
841
860
|
var initialized = false;
|
|
861
|
+
var vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
842
862
|
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
843
863
|
function log() {
|
|
844
864
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -860,17 +880,97 @@ function createVastManager() {
|
|
|
860
880
|
"[VastManager]"
|
|
861
881
|
].concat(_to_consumable_array(args)));
|
|
862
882
|
}
|
|
883
|
+
function fetchVastUrlFromApi() {
|
|
884
|
+
return _async_to_generator(function() {
|
|
885
|
+
var apiUrl, _data_response_ima_publisherdeskima, _data_response_ima, _data_response, res, data, payload, err;
|
|
886
|
+
return _ts_generator(this, function(_state) {
|
|
887
|
+
switch(_state.label){
|
|
888
|
+
case 0:
|
|
889
|
+
apiUrl = options.adstormApiUrl || ADSTORM_API_URL;
|
|
890
|
+
_state.label = 1;
|
|
891
|
+
case 1:
|
|
892
|
+
_state.trys.push([
|
|
893
|
+
1,
|
|
894
|
+
4,
|
|
895
|
+
,
|
|
896
|
+
5
|
|
897
|
+
]);
|
|
898
|
+
return [
|
|
899
|
+
4,
|
|
900
|
+
fetch(apiUrl, {
|
|
901
|
+
method: "GET",
|
|
902
|
+
headers: {
|
|
903
|
+
Authorization: "Bearer ".concat(options.licenseKey),
|
|
904
|
+
Accept: "application/json"
|
|
905
|
+
}
|
|
906
|
+
})
|
|
907
|
+
];
|
|
908
|
+
case 2:
|
|
909
|
+
res = _state.sent();
|
|
910
|
+
if (!res.ok) {
|
|
911
|
+
warn("Failed to fetch VAST URL from API (HTTP ".concat(res.status, "), using fallback"));
|
|
912
|
+
return [
|
|
913
|
+
2
|
|
914
|
+
];
|
|
915
|
+
}
|
|
916
|
+
return [
|
|
917
|
+
4,
|
|
918
|
+
res.json()
|
|
919
|
+
];
|
|
920
|
+
case 3:
|
|
921
|
+
data = _state.sent();
|
|
922
|
+
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;
|
|
923
|
+
if (payload) {
|
|
924
|
+
vastTagUrl = payload;
|
|
925
|
+
log("VAST tag URL fetched from API:", vastTagUrl.split("?")[0]);
|
|
926
|
+
} else {
|
|
927
|
+
log("API response had no VAST payload, using fallback URL");
|
|
928
|
+
}
|
|
929
|
+
return [
|
|
930
|
+
3,
|
|
931
|
+
5
|
|
932
|
+
];
|
|
933
|
+
case 4:
|
|
934
|
+
err = _state.sent();
|
|
935
|
+
warn("Error fetching VAST URL from API, using fallback:", err);
|
|
936
|
+
return [
|
|
937
|
+
3,
|
|
938
|
+
5
|
|
939
|
+
];
|
|
940
|
+
case 5:
|
|
941
|
+
return [
|
|
942
|
+
2
|
|
943
|
+
];
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
})();
|
|
947
|
+
}
|
|
863
948
|
function initialize() {
|
|
864
949
|
return _async_to_generator(function() {
|
|
865
950
|
return _ts_generator(this, function(_state) {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
951
|
+
switch(_state.label){
|
|
952
|
+
case 0:
|
|
953
|
+
if (initialized) return [
|
|
954
|
+
2
|
|
955
|
+
];
|
|
956
|
+
initialized = true;
|
|
957
|
+
if (!options.licenseKey) return [
|
|
958
|
+
3,
|
|
959
|
+
2
|
|
960
|
+
];
|
|
961
|
+
return [
|
|
962
|
+
4,
|
|
963
|
+
fetchVastUrlFromApi()
|
|
964
|
+
];
|
|
965
|
+
case 1:
|
|
966
|
+
_state.sent();
|
|
967
|
+
_state.label = 2;
|
|
968
|
+
case 2:
|
|
969
|
+
log("Initialized, VAST tag URL:", vastTagUrl.split("?")[0]);
|
|
970
|
+
return [
|
|
971
|
+
2
|
|
972
|
+
];
|
|
973
|
+
}
|
|
874
974
|
});
|
|
875
975
|
})();
|
|
876
976
|
}
|
|
@@ -884,7 +984,7 @@ function createVastManager() {
|
|
|
884
984
|
throw new Error("VastManager not initialized. Call initialize() first.");
|
|
885
985
|
}
|
|
886
986
|
correlator = Math.floor(Math.random() * 1e12).toString();
|
|
887
|
-
url =
|
|
987
|
+
url = vastTagUrl.replace("[placeholder]", correlator);
|
|
888
988
|
log("Fetching VAST tag, correlator:", correlator);
|
|
889
989
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
890
990
|
timeoutId = setTimeout(function() {
|
|
@@ -1078,6 +1178,7 @@ function createVastManager() {
|
|
|
1078
1178
|
}
|
|
1079
1179
|
function destroy() {
|
|
1080
1180
|
initialized = false;
|
|
1181
|
+
vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
1081
1182
|
log("Destroyed");
|
|
1082
1183
|
}
|
|
1083
1184
|
return {
|
|
@@ -2107,6 +2208,85 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2107
2208
|
}
|
|
2108
2209
|
};
|
|
2109
2210
|
}
|
|
2211
|
+
// src/utils/mqttClient.ts
|
|
2212
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2213
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2214
|
+
var client = null;
|
|
2215
|
+
var status = "disconnected";
|
|
2216
|
+
var brokerUrl = "";
|
|
2217
|
+
function getMQTTStatus() {
|
|
2218
|
+
return status;
|
|
2219
|
+
}
|
|
2220
|
+
function isMQTTConnected() {
|
|
2221
|
+
return status === "connected" && client !== null && client.connected;
|
|
2222
|
+
}
|
|
2223
|
+
function isMQTTConfigured() {
|
|
2224
|
+
return client !== null;
|
|
2225
|
+
}
|
|
2226
|
+
function initMQTTClient(url) {
|
|
2227
|
+
var _topicPrefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "adstorm";
|
|
2228
|
+
if (client) return;
|
|
2229
|
+
brokerUrl = url;
|
|
2230
|
+
status = "connecting";
|
|
2231
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2232
|
+
try {
|
|
2233
|
+
client = import_mqtt.default.connect(url, {
|
|
2234
|
+
clientId: clientId,
|
|
2235
|
+
keepalive: 60,
|
|
2236
|
+
clean: true,
|
|
2237
|
+
reconnectPeriod: 5e3,
|
|
2238
|
+
connectTimeout: 1e4,
|
|
2239
|
+
queueQoSZero: false
|
|
2240
|
+
});
|
|
2241
|
+
} catch (err) {
|
|
2242
|
+
status = "error";
|
|
2243
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
client.on("connect", function() {
|
|
2247
|
+
status = "connected";
|
|
2248
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2249
|
+
});
|
|
2250
|
+
client.on("reconnect", function() {
|
|
2251
|
+
status = "connecting";
|
|
2252
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2253
|
+
});
|
|
2254
|
+
client.on("offline", function() {
|
|
2255
|
+
status = "disconnected";
|
|
2256
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2257
|
+
});
|
|
2258
|
+
client.on("error", function(err) {
|
|
2259
|
+
status = "error";
|
|
2260
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2261
|
+
});
|
|
2262
|
+
client.on("close", function() {
|
|
2263
|
+
if (status === "connected") {
|
|
2264
|
+
status = "disconnected";
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
function publishMQTT(topic, payload) {
|
|
2269
|
+
if (!client) {
|
|
2270
|
+
return false;
|
|
2271
|
+
}
|
|
2272
|
+
try {
|
|
2273
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2274
|
+
qos: 1
|
|
2275
|
+
});
|
|
2276
|
+
return true;
|
|
2277
|
+
} catch (err) {
|
|
2278
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
function disconnectMQTT() {
|
|
2283
|
+
if (client) {
|
|
2284
|
+
client.end(true);
|
|
2285
|
+
client = null;
|
|
2286
|
+
status = "disconnected";
|
|
2287
|
+
brokerUrl = "";
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2110
2290
|
// src/utils/tracking.ts
|
|
2111
2291
|
var cachedBrowserId = null;
|
|
2112
2292
|
function getClientInfo() {
|
|
@@ -2138,8 +2318,8 @@ function getClientInfo() {
|
|
|
2138
2318
|
os = "webOS";
|
|
2139
2319
|
isSmartTV = true;
|
|
2140
2320
|
deviceType = "tv";
|
|
2141
|
-
var
|
|
2142
|
-
model =
|
|
2321
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2322
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2143
2323
|
} else if (ua.includes("Tizen")) {
|
|
2144
2324
|
brand = "Samsung";
|
|
2145
2325
|
os = "Tizen";
|
|
@@ -2183,23 +2363,19 @@ function getClientInfo() {
|
|
|
2183
2363
|
isAndroid = true;
|
|
2184
2364
|
os = "Android";
|
|
2185
2365
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2186
|
-
if (
|
|
2366
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2187
2367
|
deviceType = "tv";
|
|
2188
2368
|
isSmartTV = true;
|
|
2189
2369
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2190
2370
|
}
|
|
2191
2371
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2192
|
-
if (androidModelMatch
|
|
2193
|
-
model = androidModelMatch[1];
|
|
2194
|
-
}
|
|
2372
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2195
2373
|
}
|
|
2196
2374
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2197
2375
|
os = "iOS";
|
|
2198
2376
|
deviceType = "mobile";
|
|
2199
2377
|
brand = "Apple";
|
|
2200
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2201
|
-
deviceType = "tablet";
|
|
2202
|
-
}
|
|
2378
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2203
2379
|
}
|
|
2204
2380
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2205
2381
|
if (ua.includes("Windows")) {
|
|
@@ -2220,9 +2396,7 @@ function getClientInfo() {
|
|
|
2220
2396
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2221
2397
|
}
|
|
2222
2398
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2223
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2224
|
-
isWebView = true;
|
|
2225
|
-
}
|
|
2399
|
+
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) isWebView = true;
|
|
2226
2400
|
isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : (_window_screen_orientation = _window_screen.orientation) === null || _window_screen_orientation === void 0 ? void 0 : _window_screen_orientation.angle) !== void 0;
|
|
2227
2401
|
return {
|
|
2228
2402
|
brand: brand,
|
|
@@ -2253,18 +2427,16 @@ function getClientInfo() {
|
|
|
2253
2427
|
}
|
|
2254
2428
|
function getBrowserID(clientInfo) {
|
|
2255
2429
|
return _async_to_generator(function() {
|
|
2256
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2430
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2257
2431
|
return _ts_generator(this, function(_state) {
|
|
2258
2432
|
switch(_state.label){
|
|
2259
2433
|
case 0:
|
|
2260
|
-
if (cachedBrowserId)
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
];
|
|
2265
|
-
}
|
|
2434
|
+
if (cachedBrowserId) return [
|
|
2435
|
+
2,
|
|
2436
|
+
cachedBrowserId
|
|
2437
|
+
];
|
|
2266
2438
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2267
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2439
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2268
2440
|
3,
|
|
2269
2441
|
5
|
|
2270
2442
|
];
|
|
@@ -2291,9 +2463,7 @@ function getBrowserID(clientInfo) {
|
|
|
2291
2463
|
} else {
|
|
2292
2464
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2293
2465
|
buffer = new Uint8Array(utf8.length);
|
|
2294
|
-
for(i = 0; i < utf8.length; i++)
|
|
2295
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2296
|
-
}
|
|
2466
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2297
2467
|
encodedData = buffer;
|
|
2298
2468
|
}
|
|
2299
2469
|
return [
|
|
@@ -2302,8 +2472,7 @@ function getBrowserID(clientInfo) {
|
|
|
2302
2472
|
];
|
|
2303
2473
|
case 3:
|
|
2304
2474
|
hashBuffer = _state.sent();
|
|
2305
|
-
|
|
2306
|
-
hashHex = hashArray.map(function(b) {
|
|
2475
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2307
2476
|
return b.toString(16).padStart(2, "0");
|
|
2308
2477
|
}).join("");
|
|
2309
2478
|
cachedBrowserId = hashHex;
|
|
@@ -2312,8 +2481,8 @@ function getBrowserID(clientInfo) {
|
|
|
2312
2481
|
hashHex
|
|
2313
2482
|
];
|
|
2314
2483
|
case 4:
|
|
2315
|
-
|
|
2316
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2484
|
+
unused = _state.sent();
|
|
2485
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2317
2486
|
return [
|
|
2318
2487
|
3,
|
|
2319
2488
|
5
|
|
@@ -2337,6 +2506,10 @@ function getBrowserID(clientInfo) {
|
|
|
2337
2506
|
});
|
|
2338
2507
|
})();
|
|
2339
2508
|
}
|
|
2509
|
+
var mqttTopicPrefix = "adstorm";
|
|
2510
|
+
function setMQTTTopicPrefix(prefix) {
|
|
2511
|
+
mqttTopicPrefix = prefix || "adstorm";
|
|
2512
|
+
}
|
|
2340
2513
|
var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
|
|
2341
2514
|
var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
|
|
2342
2515
|
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
@@ -2345,43 +2518,9 @@ function buildHeaders(licenseKey) {
|
|
|
2345
2518
|
var headers = {
|
|
2346
2519
|
"Content-Type": "application/json"
|
|
2347
2520
|
};
|
|
2348
|
-
if (licenseKey)
|
|
2349
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2350
|
-
}
|
|
2521
|
+
if (licenseKey) headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2351
2522
|
return headers;
|
|
2352
2523
|
}
|
|
2353
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2354
|
-
return _async_to_generator(function() {
|
|
2355
|
-
var response;
|
|
2356
|
-
return _ts_generator(this, function(_state) {
|
|
2357
|
-
switch(_state.label){
|
|
2358
|
-
case 0:
|
|
2359
|
-
return [
|
|
2360
|
-
4,
|
|
2361
|
-
fetch(TRACK_URL, {
|
|
2362
|
-
method: "POST",
|
|
2363
|
-
headers: buildHeaders(licenseKey),
|
|
2364
|
-
body: JSON.stringify(body)
|
|
2365
|
-
})
|
|
2366
|
-
];
|
|
2367
|
-
case 1:
|
|
2368
|
-
response = _state.sent();
|
|
2369
|
-
if (!response.ok) {
|
|
2370
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2371
|
-
}
|
|
2372
|
-
return [
|
|
2373
|
-
4,
|
|
2374
|
-
response.json()
|
|
2375
|
-
];
|
|
2376
|
-
case 2:
|
|
2377
|
-
_state.sent();
|
|
2378
|
-
return [
|
|
2379
|
-
2
|
|
2380
|
-
];
|
|
2381
|
-
}
|
|
2382
|
-
});
|
|
2383
|
-
})();
|
|
2384
|
-
}
|
|
2385
2524
|
function postJson(url, licenseKey, body) {
|
|
2386
2525
|
return _async_to_generator(function() {
|
|
2387
2526
|
var response;
|
|
@@ -2398,9 +2537,7 @@ function postJson(url, licenseKey, body) {
|
|
|
2398
2537
|
];
|
|
2399
2538
|
case 1:
|
|
2400
2539
|
response = _state.sent();
|
|
2401
|
-
if (!response.ok)
|
|
2402
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2403
|
-
}
|
|
2540
|
+
if (!response.ok) throw new Error("HTTP error! status: ".concat(response.status));
|
|
2404
2541
|
return [
|
|
2405
2542
|
4,
|
|
2406
2543
|
response.json()
|
|
@@ -2450,9 +2587,33 @@ function buildPlayerMetricEvent(_0) {
|
|
|
2450
2587
|
});
|
|
2451
2588
|
}).apply(this, arguments);
|
|
2452
2589
|
}
|
|
2590
|
+
function publishOrPost(mqttTopic, httpUrl, licenseKey, body) {
|
|
2591
|
+
return _async_to_generator(function() {
|
|
2592
|
+
return _ts_generator(this, function(_state) {
|
|
2593
|
+
switch(_state.label){
|
|
2594
|
+
case 0:
|
|
2595
|
+
if (isMQTTConfigured()) {
|
|
2596
|
+
publishMQTT(mqttTopic, body);
|
|
2597
|
+
return [
|
|
2598
|
+
2
|
|
2599
|
+
];
|
|
2600
|
+
}
|
|
2601
|
+
return [
|
|
2602
|
+
4,
|
|
2603
|
+
postJson(httpUrl, licenseKey, body)
|
|
2604
|
+
];
|
|
2605
|
+
case 1:
|
|
2606
|
+
_state.sent();
|
|
2607
|
+
return [
|
|
2608
|
+
2
|
|
2609
|
+
];
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
})();
|
|
2613
|
+
}
|
|
2453
2614
|
function sendInitialTracking(_0) {
|
|
2454
2615
|
return _async_to_generator(function(licenseKey) {
|
|
2455
|
-
var context, clientInfo, browserId, trackingData, error;
|
|
2616
|
+
var context, clientInfo, browserId, captureAt, trackingData, metricsBody, error;
|
|
2456
2617
|
var _arguments = arguments;
|
|
2457
2618
|
return _ts_generator(this, function(_state) {
|
|
2458
2619
|
switch(_state.label){
|
|
@@ -2473,26 +2634,28 @@ function sendInitialTracking(_0) {
|
|
|
2473
2634
|
];
|
|
2474
2635
|
case 2:
|
|
2475
2636
|
browserId = _state.sent();
|
|
2637
|
+
captureAt = /* @__PURE__ */ new Date().toISOString();
|
|
2476
2638
|
trackingData = _object_spread({
|
|
2477
2639
|
browserId: browserId
|
|
2478
2640
|
}, clientInfo);
|
|
2641
|
+
metricsBody = {
|
|
2642
|
+
events: [
|
|
2643
|
+
{
|
|
2644
|
+
player_id: browserId,
|
|
2645
|
+
device_type: clientInfo.deviceType,
|
|
2646
|
+
input_stream_type: context.inputStreamType,
|
|
2647
|
+
os: clientInfo.os,
|
|
2648
|
+
ad_loaded: false,
|
|
2649
|
+
ad_detect: false,
|
|
2650
|
+
license_key: licenseKey,
|
|
2651
|
+
capture_at: captureAt
|
|
2652
|
+
}
|
|
2653
|
+
],
|
|
2654
|
+
trackingData: trackingData
|
|
2655
|
+
};
|
|
2479
2656
|
return [
|
|
2480
2657
|
4,
|
|
2481
|
-
|
|
2482
|
-
events: [
|
|
2483
|
-
{
|
|
2484
|
-
player_id: browserId,
|
|
2485
|
-
device_type: clientInfo.deviceType,
|
|
2486
|
-
input_stream_type: context.inputStreamType,
|
|
2487
|
-
os: clientInfo.os,
|
|
2488
|
-
ad_loaded: false,
|
|
2489
|
-
ad_detect: false,
|
|
2490
|
-
license_key: licenseKey,
|
|
2491
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2492
|
-
}
|
|
2493
|
-
],
|
|
2494
|
-
trackingData: trackingData
|
|
2495
|
-
})
|
|
2658
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/metrics"), TRACK_URL, licenseKey, metricsBody)
|
|
2496
2659
|
];
|
|
2497
2660
|
case 3:
|
|
2498
2661
|
_state.sent();
|
|
@@ -2605,7 +2768,7 @@ function sendAdLoadedTracking(_0, _1) {
|
|
|
2605
2768
|
}
|
|
2606
2769
|
function sendAdImpressionTracking(_0, _1) {
|
|
2607
2770
|
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
2608
|
-
var context, metricEvent, error;
|
|
2771
|
+
var context, metricEvent, heartbeatBody, impressionsBody, error;
|
|
2609
2772
|
var _arguments = arguments;
|
|
2610
2773
|
return _ts_generator(this, function(_state) {
|
|
2611
2774
|
switch(_state.label){
|
|
@@ -2627,21 +2790,23 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2627
2790
|
];
|
|
2628
2791
|
case 2:
|
|
2629
2792
|
metricEvent = _state.sent();
|
|
2793
|
+
heartbeatBody = metricEvent;
|
|
2794
|
+
impressionsBody = {
|
|
2795
|
+
events: [
|
|
2796
|
+
{
|
|
2797
|
+
player_id: metricEvent.player_id,
|
|
2798
|
+
ad_played_count: 1,
|
|
2799
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2800
|
+
license_key: licenseKey,
|
|
2801
|
+
capture_at: adImpressionInfo.timestamp
|
|
2802
|
+
}
|
|
2803
|
+
]
|
|
2804
|
+
};
|
|
2630
2805
|
return [
|
|
2631
2806
|
4,
|
|
2632
2807
|
Promise.all([
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
events: [
|
|
2636
|
-
{
|
|
2637
|
-
player_id: metricEvent.player_id,
|
|
2638
|
-
ad_played_count: 1,
|
|
2639
|
-
ad_url: adImpressionInfo.adUrl,
|
|
2640
|
-
license_key: licenseKey,
|
|
2641
|
-
capture_at: adImpressionInfo.timestamp
|
|
2642
|
-
}
|
|
2643
|
-
]
|
|
2644
|
-
})
|
|
2808
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatBody),
|
|
2809
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/impressions"), IMPRESSIONS_URL, licenseKey, impressionsBody)
|
|
2645
2810
|
])
|
|
2646
2811
|
];
|
|
2647
2812
|
case 3:
|
|
@@ -2689,7 +2854,7 @@ function sendHeartbeat(_0) {
|
|
|
2689
2854
|
heartbeatData = _state.sent();
|
|
2690
2855
|
return [
|
|
2691
2856
|
4,
|
|
2692
|
-
|
|
2857
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2693
2858
|
];
|
|
2694
2859
|
case 3:
|
|
2695
2860
|
_state.sent();
|
|
@@ -3290,9 +3455,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3290
3455
|
this.video = config.videoElement;
|
|
3291
3456
|
this.adTransitionGapMs = (_this_config_adTransitionGapMs = this.config.adTransitionGapMs) !== null && _this_config_adTransitionGapMs !== void 0 ? _this_config_adTransitionGapMs : 100;
|
|
3292
3457
|
logBrowserInfo(config.debugAdTiming);
|
|
3293
|
-
this.vastManager = createVastManager(
|
|
3294
|
-
debug: !!config.debugAdTiming
|
|
3295
|
-
}
|
|
3458
|
+
this.vastManager = createVastManager(_object_spread({
|
|
3459
|
+
debug: config.debugAdTiming !== void 0 ? !!config.debugAdTiming : false
|
|
3460
|
+
}, config.licenseKey ? {
|
|
3461
|
+
licenseKey: config.licenseKey
|
|
3462
|
+
} : {}));
|
|
3296
3463
|
var browserForAdLayer = detectBrowser();
|
|
3297
3464
|
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
3298
3465
|
this.adLayer = createVastAdLayer(this.video, {
|
|
@@ -3343,6 +3510,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3343
3510
|
this.attach();
|
|
3344
3511
|
}
|
|
3345
3512
|
this.initializeTracking();
|
|
3513
|
+
if (!this.config.disableAds) {
|
|
3514
|
+
this.vastManager.initialize().catch(function() {});
|
|
3515
|
+
}
|
|
3346
3516
|
if (!this.shouldUseNativeHls()) return [
|
|
3347
3517
|
3,
|
|
3348
3518
|
3
|
|
@@ -4638,6 +4808,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4638
4808
|
key: "initializeTracking",
|
|
4639
4809
|
value: function initializeTracking() {
|
|
4640
4810
|
var _this = this;
|
|
4811
|
+
if (this.config.mqttBrokerUrl) {
|
|
4812
|
+
var topicPrefix = "adstorm";
|
|
4813
|
+
setMQTTTopicPrefix(topicPrefix);
|
|
4814
|
+
initMQTTClient(this.config.mqttBrokerUrl, topicPrefix);
|
|
4815
|
+
}
|
|
4641
4816
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4642
4817
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4643
4818
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6317,6 +6492,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6317
6492
|
clearInterval(this.heartbeatInterval);
|
|
6318
6493
|
this.heartbeatInterval = void 0;
|
|
6319
6494
|
}
|
|
6495
|
+
if (this.config.mqttBrokerUrl) {
|
|
6496
|
+
disconnectMQTT();
|
|
6497
|
+
}
|
|
6320
6498
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6321
6499
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6322
6500
|
this.consecutiveFailures = 0;
|
|
@@ -6338,7 +6516,7 @@ var CRITICAL_PROPS = [
|
|
|
6338
6516
|
var CONTROLS_HIDE_DELAY = 3e3;
|
|
6339
6517
|
var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
|
|
6340
6518
|
var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
6341
|
-
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, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, restVideoAttrs = _object_without_properties(props, [
|
|
6519
|
+
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, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, mqttBrokerUrl = props.mqttBrokerUrl, restVideoAttrs = _object_without_properties(props, [
|
|
6342
6520
|
"src",
|
|
6343
6521
|
"autoplay",
|
|
6344
6522
|
"muted",
|
|
@@ -6365,7 +6543,8 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
6365
6543
|
"licenseKey",
|
|
6366
6544
|
"minSegmentsBeforePlay",
|
|
6367
6545
|
"disableAds",
|
|
6368
|
-
"disableFiller"
|
|
6546
|
+
"disableFiller",
|
|
6547
|
+
"mqttBrokerUrl"
|
|
6369
6548
|
]);
|
|
6370
6549
|
var videoRef = (0, import_react.useRef)(null);
|
|
6371
6550
|
var playerRef = (0, import_react.useRef)(null);
|
|
@@ -6525,6 +6704,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
6525
6704
|
if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
|
|
6526
6705
|
if (disableAds !== void 0) cfg.disableAds = disableAds;
|
|
6527
6706
|
cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
|
|
6707
|
+
if (mqttBrokerUrl !== void 0) cfg.mqttBrokerUrl = mqttBrokerUrl;
|
|
6528
6708
|
var player = new StormcloudVideoPlayer(cfg);
|
|
6529
6709
|
playerRef.current = player;
|
|
6530
6710
|
player.load().then(function() {
|
|
@@ -8771,10 +8951,15 @@ var StormcloudPlayer_default = StormcloudPlayer;
|
|
|
8771
8951
|
createVastAdLayer: createVastAdLayer,
|
|
8772
8952
|
createVastManager: createVastManager,
|
|
8773
8953
|
detectBrowser: detectBrowser,
|
|
8954
|
+
disconnectMQTT: disconnectMQTT,
|
|
8774
8955
|
getBrowserConfigOverrides: getBrowserConfigOverrides,
|
|
8775
8956
|
getBrowserID: getBrowserID,
|
|
8776
8957
|
getClientInfo: getClientInfo,
|
|
8958
|
+
getMQTTStatus: getMQTTStatus,
|
|
8959
|
+
initMQTTClient: initMQTTClient,
|
|
8777
8960
|
initializePolyfills: initializePolyfills,
|
|
8961
|
+
isMQTTConfigured: isMQTTConfigured,
|
|
8962
|
+
isMQTTConnected: isMQTTConnected,
|
|
8778
8963
|
isMediaStream: isMediaStream,
|
|
8779
8964
|
lazy: lazy,
|
|
8780
8965
|
logBrowserInfo: logBrowserInfo,
|
|
@@ -8782,6 +8967,7 @@ var StormcloudPlayer_default = StormcloudPlayer;
|
|
|
8782
8967
|
omit: omit,
|
|
8783
8968
|
parseQuery: parseQuery,
|
|
8784
8969
|
players: players,
|
|
8970
|
+
publishMQTT: publishMQTT,
|
|
8785
8971
|
randomString: randomString,
|
|
8786
8972
|
sendHeartbeat: sendHeartbeat,
|
|
8787
8973
|
sendInitialTracking: sendInitialTracking,
|