stormcloud-video-player 0.6.11 → 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 +195 -97
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +10 -1
- package/lib/index.d.ts +10 -1
- package/lib/index.js +172 -98
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +161 -95
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +161 -95
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +161 -95
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.d.cts +1 -1
- package/lib/sdk/vastManager.d.cts +1 -1
- package/lib/{types-DSKC4ySr.d.cts → types-FjAlGhAL.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +165 -97
- 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.d.cts
CHANGED
|
@@ -36,6 +36,7 @@ interface StormcloudVideoPlayerConfig {
|
|
|
36
36
|
disableFiller?: boolean;
|
|
37
37
|
adTransitionGapMs?: number;
|
|
38
38
|
singlePipelineMode?: boolean;
|
|
39
|
+
mqttBrokerUrl?: string;
|
|
39
40
|
}
|
|
40
41
|
interface ClientInfo {
|
|
41
42
|
brand: string;
|
|
@@ -3983,6 +3984,14 @@ type PlayerMetricFlags = {
|
|
|
3983
3984
|
declare function sendInitialTracking(licenseKey?: string, context?: PlayerAnalyticsContext): Promise<void>;
|
|
3984
3985
|
declare function sendHeartbeat(licenseKey?: string, context?: PlayerAnalyticsContext, flags?: PlayerMetricFlags): Promise<void>;
|
|
3985
3986
|
|
|
3987
|
+
type MQTTStatus = "disconnected" | "connecting" | "connected" | "error";
|
|
3988
|
+
declare function getMQTTStatus(): MQTTStatus;
|
|
3989
|
+
declare function isMQTTConnected(): boolean;
|
|
3990
|
+
declare function isMQTTConfigured(): boolean;
|
|
3991
|
+
declare function initMQTTClient(url: string, _topicPrefix?: string): void;
|
|
3992
|
+
declare function publishMQTT(topic: string, payload: Record<string, unknown>): boolean;
|
|
3993
|
+
declare function disconnectMQTT(): void;
|
|
3994
|
+
|
|
3986
3995
|
declare function initializePolyfills(): void;
|
|
3987
3996
|
|
|
3988
3997
|
interface NavigatorUAData {
|
|
@@ -4065,4 +4074,4 @@ interface VastAdLayer {
|
|
|
4065
4074
|
}
|
|
4066
4075
|
declare function createVastAdLayer(contentVideo: HTMLVideoElement, options?: VastAdLayerOptions): VastAdLayer;
|
|
4067
4076
|
|
|
4068
|
-
export { type AdBreak, type AdSchedule, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, type OnProgressProps, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type TrackingData, type VastAdLayer, type VastAdLayerOptions, type VastAdLayerOptionsUpdate, type VastBidResponse, type VastManager, type VastManagerOptions, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, getBrowserConfigOverrides, getBrowserID, getClientInfo, initializePolyfills, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
|
4077
|
+
export { type AdBreak, type AdSchedule, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, type MQTTStatus, type OnProgressProps, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type TrackingData, type VastAdLayer, type VastAdLayerOptions, type VastAdLayerOptionsUpdate, type VastBidResponse, type VastManager, type VastManagerOptions, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players, publishMQTT, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
package/lib/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ interface StormcloudVideoPlayerConfig {
|
|
|
36
36
|
disableFiller?: boolean;
|
|
37
37
|
adTransitionGapMs?: number;
|
|
38
38
|
singlePipelineMode?: boolean;
|
|
39
|
+
mqttBrokerUrl?: string;
|
|
39
40
|
}
|
|
40
41
|
interface ClientInfo {
|
|
41
42
|
brand: string;
|
|
@@ -3983,6 +3984,14 @@ type PlayerMetricFlags = {
|
|
|
3983
3984
|
declare function sendInitialTracking(licenseKey?: string, context?: PlayerAnalyticsContext): Promise<void>;
|
|
3984
3985
|
declare function sendHeartbeat(licenseKey?: string, context?: PlayerAnalyticsContext, flags?: PlayerMetricFlags): Promise<void>;
|
|
3985
3986
|
|
|
3987
|
+
type MQTTStatus = "disconnected" | "connecting" | "connected" | "error";
|
|
3988
|
+
declare function getMQTTStatus(): MQTTStatus;
|
|
3989
|
+
declare function isMQTTConnected(): boolean;
|
|
3990
|
+
declare function isMQTTConfigured(): boolean;
|
|
3991
|
+
declare function initMQTTClient(url: string, _topicPrefix?: string): void;
|
|
3992
|
+
declare function publishMQTT(topic: string, payload: Record<string, unknown>): boolean;
|
|
3993
|
+
declare function disconnectMQTT(): void;
|
|
3994
|
+
|
|
3986
3995
|
declare function initializePolyfills(): void;
|
|
3987
3996
|
|
|
3988
3997
|
interface NavigatorUAData {
|
|
@@ -4065,4 +4074,4 @@ interface VastAdLayer {
|
|
|
4065
4074
|
}
|
|
4066
4075
|
declare function createVastAdLayer(contentVideo: HTMLVideoElement, options?: VastAdLayerOptions): VastAdLayer;
|
|
4067
4076
|
|
|
4068
|
-
export { type AdBreak, type AdSchedule, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, type OnProgressProps, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type TrackingData, type VastAdLayer, type VastAdLayerOptions, type VastAdLayerOptionsUpdate, type VastBidResponse, type VastManager, type VastManagerOptions, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, getBrowserConfigOverrides, getBrowserID, getClientInfo, initializePolyfills, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
|
4077
|
+
export { type AdBreak, type AdSchedule, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, type MQTTStatus, type OnProgressProps, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type TrackingData, type VastAdLayer, type VastAdLayerOptions, type VastAdLayerOptionsUpdate, type VastBidResponse, type VastManager, type VastManagerOptions, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players, publishMQTT, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
package/lib/index.js
CHANGED
|
@@ -2030,6 +2030,85 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
};
|
|
2032
2032
|
}
|
|
2033
|
+
// src/utils/mqttClient.ts
|
|
2034
|
+
import mqtt from "mqtt";
|
|
2035
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2036
|
+
var client = null;
|
|
2037
|
+
var status = "disconnected";
|
|
2038
|
+
var brokerUrl = "";
|
|
2039
|
+
function getMQTTStatus() {
|
|
2040
|
+
return status;
|
|
2041
|
+
}
|
|
2042
|
+
function isMQTTConnected() {
|
|
2043
|
+
return status === "connected" && client !== null && client.connected;
|
|
2044
|
+
}
|
|
2045
|
+
function isMQTTConfigured() {
|
|
2046
|
+
return client !== null;
|
|
2047
|
+
}
|
|
2048
|
+
function initMQTTClient(url) {
|
|
2049
|
+
var _topicPrefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "adstorm";
|
|
2050
|
+
if (client) return;
|
|
2051
|
+
brokerUrl = url;
|
|
2052
|
+
status = "connecting";
|
|
2053
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2054
|
+
try {
|
|
2055
|
+
client = mqtt.connect(url, {
|
|
2056
|
+
clientId: clientId,
|
|
2057
|
+
keepalive: 60,
|
|
2058
|
+
clean: true,
|
|
2059
|
+
reconnectPeriod: 5e3,
|
|
2060
|
+
connectTimeout: 1e4,
|
|
2061
|
+
queueQoSZero: false
|
|
2062
|
+
});
|
|
2063
|
+
} catch (err) {
|
|
2064
|
+
status = "error";
|
|
2065
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
client.on("connect", function() {
|
|
2069
|
+
status = "connected";
|
|
2070
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2071
|
+
});
|
|
2072
|
+
client.on("reconnect", function() {
|
|
2073
|
+
status = "connecting";
|
|
2074
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2075
|
+
});
|
|
2076
|
+
client.on("offline", function() {
|
|
2077
|
+
status = "disconnected";
|
|
2078
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2079
|
+
});
|
|
2080
|
+
client.on("error", function(err) {
|
|
2081
|
+
status = "error";
|
|
2082
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2083
|
+
});
|
|
2084
|
+
client.on("close", function() {
|
|
2085
|
+
if (status === "connected") {
|
|
2086
|
+
status = "disconnected";
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
function publishMQTT(topic, payload) {
|
|
2091
|
+
if (!client) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
try {
|
|
2095
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2096
|
+
qos: 1
|
|
2097
|
+
});
|
|
2098
|
+
return true;
|
|
2099
|
+
} catch (err) {
|
|
2100
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
function disconnectMQTT() {
|
|
2105
|
+
if (client) {
|
|
2106
|
+
client.end(true);
|
|
2107
|
+
client = null;
|
|
2108
|
+
status = "disconnected";
|
|
2109
|
+
brokerUrl = "";
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2033
2112
|
// src/utils/tracking.ts
|
|
2034
2113
|
var cachedBrowserId = null;
|
|
2035
2114
|
function getClientInfo() {
|
|
@@ -2061,8 +2140,8 @@ function getClientInfo() {
|
|
|
2061
2140
|
os = "webOS";
|
|
2062
2141
|
isSmartTV = true;
|
|
2063
2142
|
deviceType = "tv";
|
|
2064
|
-
var
|
|
2065
|
-
model =
|
|
2143
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2144
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2066
2145
|
} else if (ua.includes("Tizen")) {
|
|
2067
2146
|
brand = "Samsung";
|
|
2068
2147
|
os = "Tizen";
|
|
@@ -2106,23 +2185,19 @@ function getClientInfo() {
|
|
|
2106
2185
|
isAndroid = true;
|
|
2107
2186
|
os = "Android";
|
|
2108
2187
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2109
|
-
if (
|
|
2188
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2110
2189
|
deviceType = "tv";
|
|
2111
2190
|
isSmartTV = true;
|
|
2112
2191
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2113
2192
|
}
|
|
2114
2193
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2115
|
-
if (androidModelMatch
|
|
2116
|
-
model = androidModelMatch[1];
|
|
2117
|
-
}
|
|
2194
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2118
2195
|
}
|
|
2119
2196
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2120
2197
|
os = "iOS";
|
|
2121
2198
|
deviceType = "mobile";
|
|
2122
2199
|
brand = "Apple";
|
|
2123
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2124
|
-
deviceType = "tablet";
|
|
2125
|
-
}
|
|
2200
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2126
2201
|
}
|
|
2127
2202
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2128
2203
|
if (ua.includes("Windows")) {
|
|
@@ -2143,9 +2218,7 @@ function getClientInfo() {
|
|
|
2143
2218
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2144
2219
|
}
|
|
2145
2220
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2146
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2147
|
-
isWebView = true;
|
|
2148
|
-
}
|
|
2221
|
+
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;
|
|
2149
2222
|
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;
|
|
2150
2223
|
return {
|
|
2151
2224
|
brand: brand,
|
|
@@ -2176,18 +2249,16 @@ function getClientInfo() {
|
|
|
2176
2249
|
}
|
|
2177
2250
|
function getBrowserID(clientInfo) {
|
|
2178
2251
|
return _async_to_generator(function() {
|
|
2179
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2252
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2180
2253
|
return _ts_generator(this, function(_state) {
|
|
2181
2254
|
switch(_state.label){
|
|
2182
2255
|
case 0:
|
|
2183
|
-
if (cachedBrowserId)
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
];
|
|
2188
|
-
}
|
|
2256
|
+
if (cachedBrowserId) return [
|
|
2257
|
+
2,
|
|
2258
|
+
cachedBrowserId
|
|
2259
|
+
];
|
|
2189
2260
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2190
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2261
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2191
2262
|
3,
|
|
2192
2263
|
5
|
|
2193
2264
|
];
|
|
@@ -2214,9 +2285,7 @@ function getBrowserID(clientInfo) {
|
|
|
2214
2285
|
} else {
|
|
2215
2286
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2216
2287
|
buffer = new Uint8Array(utf8.length);
|
|
2217
|
-
for(i = 0; i < utf8.length; i++)
|
|
2218
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2219
|
-
}
|
|
2288
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2220
2289
|
encodedData = buffer;
|
|
2221
2290
|
}
|
|
2222
2291
|
return [
|
|
@@ -2225,8 +2294,7 @@ function getBrowserID(clientInfo) {
|
|
|
2225
2294
|
];
|
|
2226
2295
|
case 3:
|
|
2227
2296
|
hashBuffer = _state.sent();
|
|
2228
|
-
|
|
2229
|
-
hashHex = hashArray.map(function(b) {
|
|
2297
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2230
2298
|
return b.toString(16).padStart(2, "0");
|
|
2231
2299
|
}).join("");
|
|
2232
2300
|
cachedBrowserId = hashHex;
|
|
@@ -2235,8 +2303,8 @@ function getBrowserID(clientInfo) {
|
|
|
2235
2303
|
hashHex
|
|
2236
2304
|
];
|
|
2237
2305
|
case 4:
|
|
2238
|
-
|
|
2239
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2306
|
+
unused = _state.sent();
|
|
2307
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2240
2308
|
return [
|
|
2241
2309
|
3,
|
|
2242
2310
|
5
|
|
@@ -2260,6 +2328,10 @@ function getBrowserID(clientInfo) {
|
|
|
2260
2328
|
});
|
|
2261
2329
|
})();
|
|
2262
2330
|
}
|
|
2331
|
+
var mqttTopicPrefix = "adstorm";
|
|
2332
|
+
function setMQTTTopicPrefix(prefix) {
|
|
2333
|
+
mqttTopicPrefix = prefix || "adstorm";
|
|
2334
|
+
}
|
|
2263
2335
|
var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
|
|
2264
2336
|
var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
|
|
2265
2337
|
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
@@ -2268,43 +2340,9 @@ function buildHeaders(licenseKey) {
|
|
|
2268
2340
|
var headers = {
|
|
2269
2341
|
"Content-Type": "application/json"
|
|
2270
2342
|
};
|
|
2271
|
-
if (licenseKey)
|
|
2272
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2273
|
-
}
|
|
2343
|
+
if (licenseKey) headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2274
2344
|
return headers;
|
|
2275
2345
|
}
|
|
2276
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2277
|
-
return _async_to_generator(function() {
|
|
2278
|
-
var response;
|
|
2279
|
-
return _ts_generator(this, function(_state) {
|
|
2280
|
-
switch(_state.label){
|
|
2281
|
-
case 0:
|
|
2282
|
-
return [
|
|
2283
|
-
4,
|
|
2284
|
-
fetch(TRACK_URL, {
|
|
2285
|
-
method: "POST",
|
|
2286
|
-
headers: buildHeaders(licenseKey),
|
|
2287
|
-
body: JSON.stringify(body)
|
|
2288
|
-
})
|
|
2289
|
-
];
|
|
2290
|
-
case 1:
|
|
2291
|
-
response = _state.sent();
|
|
2292
|
-
if (!response.ok) {
|
|
2293
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2294
|
-
}
|
|
2295
|
-
return [
|
|
2296
|
-
4,
|
|
2297
|
-
response.json()
|
|
2298
|
-
];
|
|
2299
|
-
case 2:
|
|
2300
|
-
_state.sent();
|
|
2301
|
-
return [
|
|
2302
|
-
2
|
|
2303
|
-
];
|
|
2304
|
-
}
|
|
2305
|
-
});
|
|
2306
|
-
})();
|
|
2307
|
-
}
|
|
2308
2346
|
function postJson(url, licenseKey, body) {
|
|
2309
2347
|
return _async_to_generator(function() {
|
|
2310
2348
|
var response;
|
|
@@ -2321,9 +2359,7 @@ function postJson(url, licenseKey, body) {
|
|
|
2321
2359
|
];
|
|
2322
2360
|
case 1:
|
|
2323
2361
|
response = _state.sent();
|
|
2324
|
-
if (!response.ok)
|
|
2325
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2326
|
-
}
|
|
2362
|
+
if (!response.ok) throw new Error("HTTP error! status: ".concat(response.status));
|
|
2327
2363
|
return [
|
|
2328
2364
|
4,
|
|
2329
2365
|
response.json()
|
|
@@ -2373,9 +2409,33 @@ function buildPlayerMetricEvent(_0) {
|
|
|
2373
2409
|
});
|
|
2374
2410
|
}).apply(this, arguments);
|
|
2375
2411
|
}
|
|
2412
|
+
function publishOrPost(mqttTopic, httpUrl, licenseKey, body) {
|
|
2413
|
+
return _async_to_generator(function() {
|
|
2414
|
+
return _ts_generator(this, function(_state) {
|
|
2415
|
+
switch(_state.label){
|
|
2416
|
+
case 0:
|
|
2417
|
+
if (isMQTTConfigured()) {
|
|
2418
|
+
publishMQTT(mqttTopic, body);
|
|
2419
|
+
return [
|
|
2420
|
+
2
|
|
2421
|
+
];
|
|
2422
|
+
}
|
|
2423
|
+
return [
|
|
2424
|
+
4,
|
|
2425
|
+
postJson(httpUrl, licenseKey, body)
|
|
2426
|
+
];
|
|
2427
|
+
case 1:
|
|
2428
|
+
_state.sent();
|
|
2429
|
+
return [
|
|
2430
|
+
2
|
|
2431
|
+
];
|
|
2432
|
+
}
|
|
2433
|
+
});
|
|
2434
|
+
})();
|
|
2435
|
+
}
|
|
2376
2436
|
function sendInitialTracking(_0) {
|
|
2377
2437
|
return _async_to_generator(function(licenseKey) {
|
|
2378
|
-
var context, clientInfo, browserId, trackingData, error;
|
|
2438
|
+
var context, clientInfo, browserId, captureAt, trackingData, metricsBody, error;
|
|
2379
2439
|
var _arguments = arguments;
|
|
2380
2440
|
return _ts_generator(this, function(_state) {
|
|
2381
2441
|
switch(_state.label){
|
|
@@ -2396,26 +2456,28 @@ function sendInitialTracking(_0) {
|
|
|
2396
2456
|
];
|
|
2397
2457
|
case 2:
|
|
2398
2458
|
browserId = _state.sent();
|
|
2459
|
+
captureAt = /* @__PURE__ */ new Date().toISOString();
|
|
2399
2460
|
trackingData = _object_spread({
|
|
2400
2461
|
browserId: browserId
|
|
2401
2462
|
}, clientInfo);
|
|
2463
|
+
metricsBody = {
|
|
2464
|
+
events: [
|
|
2465
|
+
{
|
|
2466
|
+
player_id: browserId,
|
|
2467
|
+
device_type: clientInfo.deviceType,
|
|
2468
|
+
input_stream_type: context.inputStreamType,
|
|
2469
|
+
os: clientInfo.os,
|
|
2470
|
+
ad_loaded: false,
|
|
2471
|
+
ad_detect: false,
|
|
2472
|
+
license_key: licenseKey,
|
|
2473
|
+
capture_at: captureAt
|
|
2474
|
+
}
|
|
2475
|
+
],
|
|
2476
|
+
trackingData: trackingData
|
|
2477
|
+
};
|
|
2402
2478
|
return [
|
|
2403
2479
|
4,
|
|
2404
|
-
|
|
2405
|
-
events: [
|
|
2406
|
-
{
|
|
2407
|
-
player_id: browserId,
|
|
2408
|
-
device_type: clientInfo.deviceType,
|
|
2409
|
-
input_stream_type: context.inputStreamType,
|
|
2410
|
-
os: clientInfo.os,
|
|
2411
|
-
ad_loaded: false,
|
|
2412
|
-
ad_detect: false,
|
|
2413
|
-
license_key: licenseKey,
|
|
2414
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2415
|
-
}
|
|
2416
|
-
],
|
|
2417
|
-
trackingData: trackingData
|
|
2418
|
-
})
|
|
2480
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/metrics"), TRACK_URL, licenseKey, metricsBody)
|
|
2419
2481
|
];
|
|
2420
2482
|
case 3:
|
|
2421
2483
|
_state.sent();
|
|
@@ -2528,7 +2590,7 @@ function sendAdLoadedTracking(_0, _1) {
|
|
|
2528
2590
|
}
|
|
2529
2591
|
function sendAdImpressionTracking(_0, _1) {
|
|
2530
2592
|
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
2531
|
-
var context, metricEvent, error;
|
|
2593
|
+
var context, metricEvent, heartbeatBody, impressionsBody, error;
|
|
2532
2594
|
var _arguments = arguments;
|
|
2533
2595
|
return _ts_generator(this, function(_state) {
|
|
2534
2596
|
switch(_state.label){
|
|
@@ -2550,21 +2612,23 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2550
2612
|
];
|
|
2551
2613
|
case 2:
|
|
2552
2614
|
metricEvent = _state.sent();
|
|
2615
|
+
heartbeatBody = metricEvent;
|
|
2616
|
+
impressionsBody = {
|
|
2617
|
+
events: [
|
|
2618
|
+
{
|
|
2619
|
+
player_id: metricEvent.player_id,
|
|
2620
|
+
ad_played_count: 1,
|
|
2621
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2622
|
+
license_key: licenseKey,
|
|
2623
|
+
capture_at: adImpressionInfo.timestamp
|
|
2624
|
+
}
|
|
2625
|
+
]
|
|
2626
|
+
};
|
|
2553
2627
|
return [
|
|
2554
2628
|
4,
|
|
2555
2629
|
Promise.all([
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
events: [
|
|
2559
|
-
{
|
|
2560
|
-
player_id: metricEvent.player_id,
|
|
2561
|
-
ad_played_count: 1,
|
|
2562
|
-
ad_url: adImpressionInfo.adUrl,
|
|
2563
|
-
license_key: licenseKey,
|
|
2564
|
-
capture_at: adImpressionInfo.timestamp
|
|
2565
|
-
}
|
|
2566
|
-
]
|
|
2567
|
-
})
|
|
2630
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatBody),
|
|
2631
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/impressions"), IMPRESSIONS_URL, licenseKey, impressionsBody)
|
|
2568
2632
|
])
|
|
2569
2633
|
];
|
|
2570
2634
|
case 3:
|
|
@@ -2612,7 +2676,7 @@ function sendHeartbeat(_0) {
|
|
|
2612
2676
|
heartbeatData = _state.sent();
|
|
2613
2677
|
return [
|
|
2614
2678
|
4,
|
|
2615
|
-
|
|
2679
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2616
2680
|
];
|
|
2617
2681
|
case 3:
|
|
2618
2682
|
_state.sent();
|
|
@@ -4569,6 +4633,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4569
4633
|
key: "initializeTracking",
|
|
4570
4634
|
value: function initializeTracking() {
|
|
4571
4635
|
var _this = this;
|
|
4636
|
+
if (this.config.mqttBrokerUrl) {
|
|
4637
|
+
var topicPrefix = "adstorm";
|
|
4638
|
+
setMQTTTopicPrefix(topicPrefix);
|
|
4639
|
+
initMQTTClient(this.config.mqttBrokerUrl, topicPrefix);
|
|
4640
|
+
}
|
|
4572
4641
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4573
4642
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4574
4643
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6248,6 +6317,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6248
6317
|
clearInterval(this.heartbeatInterval);
|
|
6249
6318
|
this.heartbeatInterval = void 0;
|
|
6250
6319
|
}
|
|
6320
|
+
if (this.config.mqttBrokerUrl) {
|
|
6321
|
+
disconnectMQTT();
|
|
6322
|
+
}
|
|
6251
6323
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6252
6324
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6253
6325
|
this.consecutiveFailures = 0;
|
|
@@ -6269,7 +6341,7 @@ var CRITICAL_PROPS = [
|
|
|
6269
6341
|
var CONTROLS_HIDE_DELAY = 3e3;
|
|
6270
6342
|
var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
|
|
6271
6343
|
var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
6272
|
-
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, [
|
|
6344
|
+
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, [
|
|
6273
6345
|
"src",
|
|
6274
6346
|
"autoplay",
|
|
6275
6347
|
"muted",
|
|
@@ -6296,7 +6368,8 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
|
6296
6368
|
"licenseKey",
|
|
6297
6369
|
"minSegmentsBeforePlay",
|
|
6298
6370
|
"disableAds",
|
|
6299
|
-
"disableFiller"
|
|
6371
|
+
"disableFiller",
|
|
6372
|
+
"mqttBrokerUrl"
|
|
6300
6373
|
]);
|
|
6301
6374
|
var videoRef = useRef(null);
|
|
6302
6375
|
var playerRef = useRef(null);
|
|
@@ -6456,6 +6529,7 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
|
|
|
6456
6529
|
if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
|
|
6457
6530
|
if (disableAds !== void 0) cfg.disableAds = disableAds;
|
|
6458
6531
|
cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
|
|
6532
|
+
if (mqttBrokerUrl !== void 0) cfg.mqttBrokerUrl = mqttBrokerUrl;
|
|
6459
6533
|
var player = new StormcloudVideoPlayer(cfg);
|
|
6460
6534
|
playerRef.current = player;
|
|
6461
6535
|
player.load().then(function() {
|
|
@@ -8690,5 +8764,5 @@ var createStormcloudPlayer = function createStormcloudPlayer(playerList, fallbac
|
|
|
8690
8764
|
};
|
|
8691
8765
|
var StormcloudPlayer = createStormcloudPlayer(players_default, players_default[players_default.length - 1]);
|
|
8692
8766
|
var StormcloudPlayer_default = StormcloudPlayer;
|
|
8693
|
-
export { IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer_default as StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, getBrowserConfigOverrides, getBrowserID, getClientInfo, initializePolyfills, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players_default as players, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
|
8767
|
+
export { IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer_default as StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players_default as players, publishMQTT, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
|
8694
8768
|
//# sourceMappingURL=index.js.map
|