stormcloud-video-player 0.7.49 → 0.7.51
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 +429 -173
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +73 -3
- package/lib/index.d.ts +73 -3
- package/lib/index.js +358 -174
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +246 -156
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +3 -1
- package/lib/players/HlsPlayer.cjs +246 -156
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +2 -1
- package/lib/players/index.cjs +246 -156
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/adstormPlayer.d.cts +2 -1
- package/lib/{types-CIHDHY7A.d.cts → types-Dobqa8vR.d.cts} +8 -1
- package/lib/ui/OverlayRenderer.cjs +24 -18
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +308 -178
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +2 -1
- package/lib/utils/mqttClient.cjs +247 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +13 -0
- package/lib/utils/mqttConfig.cjs +141 -0
- package/lib/utils/mqttConfig.cjs.map +1 -0
- package/lib/utils/mqttConfig.d.cts +20 -0
- package/lib/utils/tracking.cjs +237 -192
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +12 -6
- package/package.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { S as StormcloudVideoPlayerConfig } from '../types-
|
|
1
|
+
import { S as StormcloudVideoPlayerConfig } from '../types-Dobqa8vR.cjs';
|
|
2
|
+
import '../utils/mqttConfig.cjs';
|
|
2
3
|
|
|
3
4
|
type DebugLogLevel = "info" | "warn" | "error";
|
|
4
5
|
declare class StormcloudVideoPlayer {
|
|
@@ -86,6 +87,7 @@ declare class StormcloudVideoPlayer {
|
|
|
86
87
|
setDisableAds(disabled: boolean): void;
|
|
87
88
|
private syncMainContentAudioWhenVisible;
|
|
88
89
|
getStreamType(): "hls" | "other";
|
|
90
|
+
private getPlayerAnalyticsContext;
|
|
89
91
|
shouldShowNativeControls(): boolean;
|
|
90
92
|
private shouldContinueLiveStreamDuringAds;
|
|
91
93
|
private startAdPrefetch;
|
|
@@ -1729,6 +1729,116 @@ function createAdStormPlayer(contentVideo, options) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
};
|
|
1731
1731
|
}
|
|
1732
|
+
// src/utils/mqttClient.ts
|
|
1733
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
1734
|
+
// src/utils/mqttConfig.ts
|
|
1735
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
1736
|
+
enabled: true,
|
|
1737
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
1738
|
+
brokerPort: 8883,
|
|
1739
|
+
wsPort: 8084,
|
|
1740
|
+
username: "for-sonifi",
|
|
1741
|
+
password: "sonifi-mqtt",
|
|
1742
|
+
topicPrefix: "adstorm/players",
|
|
1743
|
+
qos: 1
|
|
1744
|
+
};
|
|
1745
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
1746
|
+
function applyMQTTConfig(overrides) {
|
|
1747
|
+
Object.assign(mqttConfig, overrides);
|
|
1748
|
+
}
|
|
1749
|
+
function isMQTTEnabled() {
|
|
1750
|
+
return mqttConfig.enabled;
|
|
1751
|
+
}
|
|
1752
|
+
function buildMQTTBrokerUrl() {
|
|
1753
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
1754
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
1755
|
+
}
|
|
1756
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
1757
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
1758
|
+
}
|
|
1759
|
+
// src/utils/mqttClient.ts
|
|
1760
|
+
var LOG = "[StormcloudVideoPlayer][MQTT]";
|
|
1761
|
+
var client = null;
|
|
1762
|
+
var status = "disconnected";
|
|
1763
|
+
function configureMQTT(overrides) {
|
|
1764
|
+
applyMQTTConfig(overrides);
|
|
1765
|
+
disconnectMQTT();
|
|
1766
|
+
}
|
|
1767
|
+
function initMQTTClient() {
|
|
1768
|
+
if (client || !isMQTTEnabled()) return;
|
|
1769
|
+
var url = buildMQTTBrokerUrl();
|
|
1770
|
+
status = "connecting";
|
|
1771
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
1772
|
+
try {
|
|
1773
|
+
client = import_mqtt.default.connect(url, {
|
|
1774
|
+
clientId: clientId,
|
|
1775
|
+
username: mqttConfig.username,
|
|
1776
|
+
password: mqttConfig.password,
|
|
1777
|
+
keepalive: 60,
|
|
1778
|
+
clean: true,
|
|
1779
|
+
reconnectPeriod: 5e3,
|
|
1780
|
+
connectTimeout: 1e4,
|
|
1781
|
+
queueQoSZero: false
|
|
1782
|
+
});
|
|
1783
|
+
} catch (err) {
|
|
1784
|
+
status = "error";
|
|
1785
|
+
console.warn("".concat(LOG, " connect() threw:"), err);
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
client.on("connect", function() {
|
|
1789
|
+
status = "connected";
|
|
1790
|
+
console.info("".concat(LOG, " connected to ").concat(url));
|
|
1791
|
+
});
|
|
1792
|
+
client.on("reconnect", function() {
|
|
1793
|
+
status = "connecting";
|
|
1794
|
+
console.info("".concat(LOG, " reconnecting..."));
|
|
1795
|
+
});
|
|
1796
|
+
client.on("offline", function() {
|
|
1797
|
+
if (status !== "error") {
|
|
1798
|
+
status = "disconnected";
|
|
1799
|
+
}
|
|
1800
|
+
console.warn("".concat(LOG, " offline"));
|
|
1801
|
+
});
|
|
1802
|
+
client.on("error", function(err) {
|
|
1803
|
+
status = "error";
|
|
1804
|
+
console.warn("".concat(LOG, " error:"), err.message);
|
|
1805
|
+
});
|
|
1806
|
+
client.on("close", function() {
|
|
1807
|
+
if (status === "connected" || status === "connecting") {
|
|
1808
|
+
status = "disconnected";
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
function ensureMQTTClient() {
|
|
1813
|
+
if (isMQTTEnabled() && !client) {
|
|
1814
|
+
initMQTTClient();
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
function publishMQTT(topic, payload) {
|
|
1818
|
+
if (!isMQTTEnabled()) {
|
|
1819
|
+
return false;
|
|
1820
|
+
}
|
|
1821
|
+
ensureMQTTClient();
|
|
1822
|
+
if (!client) {
|
|
1823
|
+
return false;
|
|
1824
|
+
}
|
|
1825
|
+
try {
|
|
1826
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
1827
|
+
qos: mqttConfig.qos
|
|
1828
|
+
});
|
|
1829
|
+
return true;
|
|
1830
|
+
} catch (err) {
|
|
1831
|
+
console.warn("".concat(LOG, " publish failed on ").concat(topic, ":"), err);
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
function disconnectMQTT() {
|
|
1836
|
+
if (client) {
|
|
1837
|
+
client.end(true);
|
|
1838
|
+
client = null;
|
|
1839
|
+
status = "disconnected";
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1732
1842
|
// src/utils/tracking.ts
|
|
1733
1843
|
var cachedBrowserId = null;
|
|
1734
1844
|
function getClientInfo() {
|
|
@@ -1959,139 +2069,120 @@ function getBrowserID(clientInfo) {
|
|
|
1959
2069
|
});
|
|
1960
2070
|
})();
|
|
1961
2071
|
}
|
|
1962
|
-
|
|
1963
|
-
|
|
2072
|
+
function canPublish(licenseKey) {
|
|
2073
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2074
|
+
}
|
|
2075
|
+
function buildPlayerMetricEvent() {
|
|
1964
2076
|
return _async_to_generator(function() {
|
|
1965
|
-
var
|
|
2077
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2078
|
+
var _arguments = arguments;
|
|
1966
2079
|
return _ts_generator(this, function(_state) {
|
|
1967
2080
|
switch(_state.label){
|
|
1968
2081
|
case 0:
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
};
|
|
1972
|
-
if (licenseKey) {
|
|
1973
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
1974
|
-
}
|
|
2082
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2083
|
+
clientInfo = getClientInfo();
|
|
1975
2084
|
return [
|
|
1976
2085
|
4,
|
|
1977
|
-
|
|
1978
|
-
method: "POST",
|
|
1979
|
-
headers: headers,
|
|
1980
|
-
body: JSON.stringify(body)
|
|
1981
|
-
})
|
|
2086
|
+
getBrowserID(clientInfo)
|
|
1982
2087
|
];
|
|
1983
2088
|
case 1:
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
1987
|
-
}
|
|
1988
|
-
return [
|
|
1989
|
-
4,
|
|
1990
|
-
response.json()
|
|
1991
|
-
];
|
|
1992
|
-
case 2:
|
|
1993
|
-
_state.sent();
|
|
2089
|
+
playerId = _state.sent();
|
|
2090
|
+
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
1994
2091
|
return [
|
|
1995
|
-
2
|
|
2092
|
+
2,
|
|
2093
|
+
_object_spread({
|
|
2094
|
+
player_id: playerId,
|
|
2095
|
+
device_type: clientInfo.deviceType,
|
|
2096
|
+
os: clientInfo.os.toLowerCase(),
|
|
2097
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2098
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2099
|
+
capture_at: captureAt
|
|
2100
|
+
}, context.inputStreamType ? {
|
|
2101
|
+
input_stream_type: context.inputStreamType
|
|
2102
|
+
} : {})
|
|
1996
2103
|
];
|
|
1997
2104
|
}
|
|
1998
2105
|
});
|
|
1999
|
-
})();
|
|
2106
|
+
}).apply(this, arguments);
|
|
2000
2107
|
}
|
|
2001
|
-
function
|
|
2002
|
-
|
|
2003
|
-
|
|
2108
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2109
|
+
ensureMQTTClient();
|
|
2110
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2111
|
+
}
|
|
2112
|
+
function sendInitialTracking(_0) {
|
|
2113
|
+
return _async_to_generator(function(licenseKey) {
|
|
2114
|
+
var context, metricEvent, error;
|
|
2115
|
+
var _arguments = arguments;
|
|
2004
2116
|
return _ts_generator(this, function(_state) {
|
|
2005
2117
|
switch(_state.label){
|
|
2006
2118
|
case 0:
|
|
2119
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2120
|
+
if (!canPublish(licenseKey)) return [
|
|
2121
|
+
2
|
|
2122
|
+
];
|
|
2123
|
+
_state.label = 1;
|
|
2124
|
+
case 1:
|
|
2007
2125
|
_state.trys.push([
|
|
2008
|
-
|
|
2009
|
-
|
|
2126
|
+
1,
|
|
2127
|
+
3,
|
|
2010
2128
|
,
|
|
2011
|
-
|
|
2129
|
+
4
|
|
2012
2130
|
]);
|
|
2013
|
-
clientInfo = getClientInfo();
|
|
2014
|
-
return [
|
|
2015
|
-
4,
|
|
2016
|
-
getBrowserID(clientInfo)
|
|
2017
|
-
];
|
|
2018
|
-
case 1:
|
|
2019
|
-
browserId = _state.sent();
|
|
2020
|
-
trackingData = _object_spread({
|
|
2021
|
-
browserId: browserId
|
|
2022
|
-
}, clientInfo);
|
|
2023
|
-
headers = {
|
|
2024
|
-
"Content-Type": "application/json"
|
|
2025
|
-
};
|
|
2026
|
-
if (licenseKey) {
|
|
2027
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2028
|
-
}
|
|
2029
2131
|
return [
|
|
2030
2132
|
4,
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
body: JSON.stringify(trackingData)
|
|
2133
|
+
buildPlayerMetricEvent(context, {
|
|
2134
|
+
adLoaded: false,
|
|
2135
|
+
adDetect: false
|
|
2035
2136
|
})
|
|
2036
2137
|
];
|
|
2037
2138
|
case 2:
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
response.json()
|
|
2045
|
-
];
|
|
2046
|
-
case 3:
|
|
2047
|
-
_state.sent();
|
|
2139
|
+
metricEvent = _state.sent();
|
|
2140
|
+
publishTracking(licenseKey, "metrics", {
|
|
2141
|
+
events: [
|
|
2142
|
+
metricEvent
|
|
2143
|
+
]
|
|
2144
|
+
});
|
|
2048
2145
|
return [
|
|
2049
2146
|
3,
|
|
2050
|
-
|
|
2147
|
+
4
|
|
2051
2148
|
];
|
|
2052
|
-
case
|
|
2149
|
+
case 3:
|
|
2053
2150
|
error = _state.sent();
|
|
2054
2151
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2055
2152
|
return [
|
|
2056
2153
|
3,
|
|
2057
|
-
|
|
2154
|
+
4
|
|
2058
2155
|
];
|
|
2059
|
-
case
|
|
2156
|
+
case 4:
|
|
2060
2157
|
return [
|
|
2061
2158
|
2
|
|
2062
2159
|
];
|
|
2063
2160
|
}
|
|
2064
2161
|
});
|
|
2065
|
-
})();
|
|
2162
|
+
}).apply(this, arguments);
|
|
2066
2163
|
}
|
|
2067
|
-
function sendAdLoadedTracking(
|
|
2068
|
-
return _async_to_generator(function() {
|
|
2069
|
-
var
|
|
2164
|
+
function sendAdLoadedTracking(_0, _1) {
|
|
2165
|
+
return _async_to_generator(function(licenseKey, adLoadedInfo) {
|
|
2166
|
+
var context, error;
|
|
2167
|
+
var _arguments = arguments;
|
|
2070
2168
|
return _ts_generator(this, function(_state) {
|
|
2071
2169
|
switch(_state.label){
|
|
2072
2170
|
case 0:
|
|
2171
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2172
|
+
_state.label = 1;
|
|
2173
|
+
case 1:
|
|
2073
2174
|
_state.trys.push([
|
|
2074
|
-
|
|
2175
|
+
1,
|
|
2075
2176
|
3,
|
|
2076
2177
|
,
|
|
2077
2178
|
4
|
|
2078
2179
|
]);
|
|
2079
|
-
clientInfo = getClientInfo();
|
|
2080
2180
|
return [
|
|
2081
2181
|
4,
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
trackingData = _object_spread({
|
|
2087
|
-
browserId: browserId
|
|
2088
|
-
}, clientInfo);
|
|
2089
|
-
return [
|
|
2090
|
-
4,
|
|
2091
|
-
sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
|
|
2092
|
-
licenseKey: licenseKey,
|
|
2093
|
-
adLoadedInfo: adLoadedInfo
|
|
2094
|
-
}))
|
|
2182
|
+
sendHeartbeat(licenseKey, context, {
|
|
2183
|
+
adLoaded: true,
|
|
2184
|
+
captureAt: adLoadedInfo.timestamp
|
|
2185
|
+
})
|
|
2095
2186
|
];
|
|
2096
2187
|
case 2:
|
|
2097
2188
|
_state.sent();
|
|
@@ -2112,39 +2203,46 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
|
|
|
2112
2203
|
];
|
|
2113
2204
|
}
|
|
2114
2205
|
});
|
|
2115
|
-
})();
|
|
2206
|
+
}).apply(this, arguments);
|
|
2116
2207
|
}
|
|
2117
|
-
function sendAdImpressionTracking(
|
|
2118
|
-
return _async_to_generator(function() {
|
|
2119
|
-
var
|
|
2208
|
+
function sendAdImpressionTracking(_0, _1) {
|
|
2209
|
+
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
2210
|
+
var context, metricEvent, error;
|
|
2211
|
+
var _arguments = arguments;
|
|
2120
2212
|
return _ts_generator(this, function(_state) {
|
|
2121
2213
|
switch(_state.label){
|
|
2122
2214
|
case 0:
|
|
2215
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2216
|
+
if (!canPublish(licenseKey)) return [
|
|
2217
|
+
2
|
|
2218
|
+
];
|
|
2219
|
+
_state.label = 1;
|
|
2220
|
+
case 1:
|
|
2123
2221
|
_state.trys.push([
|
|
2124
|
-
|
|
2222
|
+
1,
|
|
2125
2223
|
3,
|
|
2126
2224
|
,
|
|
2127
2225
|
4
|
|
2128
2226
|
]);
|
|
2129
|
-
clientInfo = getClientInfo();
|
|
2130
|
-
return [
|
|
2131
|
-
4,
|
|
2132
|
-
getBrowserID(clientInfo)
|
|
2133
|
-
];
|
|
2134
|
-
case 1:
|
|
2135
|
-
browserId = _state.sent();
|
|
2136
|
-
trackingData = _object_spread({
|
|
2137
|
-
browserId: browserId
|
|
2138
|
-
}, clientInfo);
|
|
2139
2227
|
return [
|
|
2140
2228
|
4,
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
}))
|
|
2229
|
+
buildPlayerMetricEvent(context, {
|
|
2230
|
+
captureAt: adImpressionInfo.timestamp
|
|
2231
|
+
})
|
|
2145
2232
|
];
|
|
2146
2233
|
case 2:
|
|
2147
|
-
_state.sent();
|
|
2234
|
+
metricEvent = _state.sent();
|
|
2235
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2236
|
+
publishTracking(licenseKey, "impressions", {
|
|
2237
|
+
events: [
|
|
2238
|
+
{
|
|
2239
|
+
player_id: metricEvent.player_id,
|
|
2240
|
+
ad_played_count: 1,
|
|
2241
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2242
|
+
capture_at: adImpressionInfo.timestamp
|
|
2243
|
+
}
|
|
2244
|
+
]
|
|
2245
|
+
});
|
|
2148
2246
|
return [
|
|
2149
2247
|
3,
|
|
2150
2248
|
4
|
|
@@ -2162,74 +2260,52 @@ function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
|
|
|
2162
2260
|
];
|
|
2163
2261
|
}
|
|
2164
2262
|
});
|
|
2165
|
-
})();
|
|
2263
|
+
}).apply(this, arguments);
|
|
2166
2264
|
}
|
|
2167
|
-
function sendHeartbeat(
|
|
2168
|
-
return _async_to_generator(function() {
|
|
2169
|
-
var
|
|
2265
|
+
function sendHeartbeat(_0) {
|
|
2266
|
+
return _async_to_generator(function(licenseKey) {
|
|
2267
|
+
var context, flags, heartbeatData, error;
|
|
2268
|
+
var _arguments = arguments;
|
|
2170
2269
|
return _ts_generator(this, function(_state) {
|
|
2171
2270
|
switch(_state.label){
|
|
2172
2271
|
case 0:
|
|
2272
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2273
|
+
if (!canPublish(licenseKey)) return [
|
|
2274
|
+
2
|
|
2275
|
+
];
|
|
2276
|
+
_state.label = 1;
|
|
2277
|
+
case 1:
|
|
2173
2278
|
_state.trys.push([
|
|
2174
|
-
|
|
2175
|
-
|
|
2279
|
+
1,
|
|
2280
|
+
3,
|
|
2176
2281
|
,
|
|
2177
|
-
|
|
2282
|
+
4
|
|
2178
2283
|
]);
|
|
2179
|
-
clientInfo = getClientInfo();
|
|
2180
|
-
return [
|
|
2181
|
-
4,
|
|
2182
|
-
getBrowserID(clientInfo)
|
|
2183
|
-
];
|
|
2184
|
-
case 1:
|
|
2185
|
-
browserId = _state.sent();
|
|
2186
|
-
heartbeatData = {
|
|
2187
|
-
browserId: browserId,
|
|
2188
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2189
|
-
};
|
|
2190
|
-
headers = {
|
|
2191
|
-
"Content-Type": "application/json"
|
|
2192
|
-
};
|
|
2193
|
-
if (licenseKey) {
|
|
2194
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2195
|
-
}
|
|
2196
2284
|
return [
|
|
2197
2285
|
4,
|
|
2198
|
-
|
|
2199
|
-
method: "POST",
|
|
2200
|
-
headers: headers,
|
|
2201
|
-
body: JSON.stringify(heartbeatData)
|
|
2202
|
-
})
|
|
2286
|
+
buildPlayerMetricEvent(context, flags)
|
|
2203
2287
|
];
|
|
2204
2288
|
case 2:
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2208
|
-
}
|
|
2209
|
-
return [
|
|
2210
|
-
4,
|
|
2211
|
-
response.json()
|
|
2212
|
-
];
|
|
2213
|
-
case 3:
|
|
2214
|
-
_state.sent();
|
|
2289
|
+
heartbeatData = _state.sent();
|
|
2290
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2215
2291
|
return [
|
|
2216
2292
|
3,
|
|
2217
|
-
|
|
2293
|
+
4
|
|
2218
2294
|
];
|
|
2219
|
-
case
|
|
2295
|
+
case 3:
|
|
2220
2296
|
error = _state.sent();
|
|
2221
2297
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2222
2298
|
return [
|
|
2223
2299
|
3,
|
|
2224
|
-
|
|
2300
|
+
4
|
|
2225
2301
|
];
|
|
2226
|
-
case
|
|
2302
|
+
case 4:
|
|
2227
2303
|
return [
|
|
2228
2304
|
2
|
|
2229
2305
|
];
|
|
2230
2306
|
}
|
|
2231
2307
|
});
|
|
2232
|
-
})();
|
|
2308
|
+
}).apply(this, arguments);
|
|
2233
2309
|
}
|
|
2234
2310
|
// src/utils/polyfills.ts
|
|
2235
2311
|
function polyfillURLSearchParams() {
|
|
@@ -2791,6 +2867,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2791
2867
|
this.config = _object_spread({}, browserOverrides, config);
|
|
2792
2868
|
this.video = config.videoElement;
|
|
2793
2869
|
this.adTransitionGapMs = (_this_config_adTransitionGapMs = this.config.adTransitionGapMs) !== null && _this_config_adTransitionGapMs !== void 0 ? _this_config_adTransitionGapMs : 100;
|
|
2870
|
+
if (this.config.mqttConfig) {
|
|
2871
|
+
configureMQTT(this.config.mqttConfig);
|
|
2872
|
+
}
|
|
2794
2873
|
logBrowserInfo(config.debugAdTiming);
|
|
2795
2874
|
var browserForAdLayer = detectBrowser();
|
|
2796
2875
|
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
@@ -3158,7 +3237,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3158
3237
|
source: _this.getAdSource(),
|
|
3159
3238
|
adIndex: _this.currentAdIndex,
|
|
3160
3239
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
3161
|
-
});
|
|
3240
|
+
}, _this.getPlayerAnalyticsContext());
|
|
3162
3241
|
}
|
|
3163
3242
|
});
|
|
3164
3243
|
this.adLayer.on("ad_error", function(errorPayload) {
|
|
@@ -3463,7 +3542,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3463
3542
|
key: "initializeTracking",
|
|
3464
3543
|
value: function initializeTracking() {
|
|
3465
3544
|
var _this = this;
|
|
3466
|
-
sendInitialTracking(this.config.licenseKey).then(function() {
|
|
3545
|
+
sendInitialTracking(this.config.licenseKey, this.getPlayerAnalyticsContext()).then(function() {
|
|
3467
3546
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
3468
3547
|
_this.sendHeartbeatIfNeeded();
|
|
3469
3548
|
}, 5e3);
|
|
@@ -3484,7 +3563,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3484
3563
|
var now = Date.now();
|
|
3485
3564
|
if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
|
|
3486
3565
|
this.lastHeartbeatTime = now;
|
|
3487
|
-
sendHeartbeat(this.config.licenseKey).catch(function(error) {
|
|
3566
|
+
sendHeartbeat(this.config.licenseKey, this.getPlayerAnalyticsContext()).catch(function(error) {
|
|
3488
3567
|
if (_this.config.debugAdTiming) {
|
|
3489
3568
|
console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
|
|
3490
3569
|
}
|
|
@@ -3578,6 +3657,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3578
3657
|
return "other";
|
|
3579
3658
|
}
|
|
3580
3659
|
},
|
|
3660
|
+
{
|
|
3661
|
+
key: "getPlayerAnalyticsContext",
|
|
3662
|
+
value: function getPlayerAnalyticsContext() {
|
|
3663
|
+
return {
|
|
3664
|
+
inputStreamType: this.getStreamType()
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3667
|
+
},
|
|
3581
3668
|
{
|
|
3582
3669
|
key: "shouldShowNativeControls",
|
|
3583
3670
|
value: function shouldShowNativeControls() {
|
|
@@ -4232,7 +4319,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4232
4319
|
sendAdLoadedTracking(_this.config.licenseKey, {
|
|
4233
4320
|
source: _this.getAdSource(),
|
|
4234
4321
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
4235
|
-
});
|
|
4322
|
+
}, _this.getPlayerAnalyticsContext());
|
|
4236
4323
|
}
|
|
4237
4324
|
return [
|
|
4238
4325
|
4,
|
|
@@ -4342,7 +4429,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4342
4429
|
sendAdLoadedTracking(_this.config.licenseKey, {
|
|
4343
4430
|
source: _this.getAdSource(),
|
|
4344
4431
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
4345
|
-
});
|
|
4432
|
+
}, _this.getPlayerAnalyticsContext());
|
|
4346
4433
|
}
|
|
4347
4434
|
return [
|
|
4348
4435
|
4,
|
|
@@ -4509,7 +4596,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4509
4596
|
sendAdLoadedTracking(this.config.licenseKey, {
|
|
4510
4597
|
source: this.getAdSource(),
|
|
4511
4598
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
4512
|
-
});
|
|
4599
|
+
}, this.getPlayerAnalyticsContext());
|
|
4513
4600
|
}
|
|
4514
4601
|
_state.label = 1;
|
|
4515
4602
|
case 1:
|
|
@@ -4708,7 +4795,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4708
4795
|
sendAdLoadedTracking(this.config.licenseKey, {
|
|
4709
4796
|
source: this.getAdSource(),
|
|
4710
4797
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
4711
|
-
});
|
|
4798
|
+
}, this.getPlayerAnalyticsContext());
|
|
4712
4799
|
}
|
|
4713
4800
|
return [
|
|
4714
4801
|
4,
|
|
@@ -5653,6 +5740,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5653
5740
|
clearInterval(this.heartbeatInterval);
|
|
5654
5741
|
this.heartbeatInterval = void 0;
|
|
5655
5742
|
}
|
|
5743
|
+
if (isMQTTEnabled()) {
|
|
5744
|
+
disconnectMQTT();
|
|
5745
|
+
}
|
|
5656
5746
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5657
5747
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
5658
5748
|
this.consecutiveFailures = 0;
|