stormcloud-video-player 0.1.13 → 0.2.0
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/README.md +418 -48
- package/dist/stormcloud-vp.min.js +1 -10
- package/lib/index.cjs +951 -28
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +3591 -2
- package/lib/index.d.ts +3591 -2
- package/lib/index.js +925 -18
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +1669 -0
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -0
- package/lib/player/StormcloudVideoPlayer.d.cts +74 -0
- package/lib/players/FilePlayer.cjs +233 -0
- package/lib/players/FilePlayer.cjs.map +1 -0
- package/lib/players/FilePlayer.d.cts +48 -0
- package/lib/players/HlsPlayer.cjs +1847 -0
- package/lib/players/HlsPlayer.cjs.map +1 -0
- package/lib/players/HlsPlayer.d.cts +37 -0
- package/lib/players/index.cjs +2055 -0
- package/lib/players/index.cjs.map +1 -0
- package/lib/players/index.d.cts +10 -0
- package/lib/sdk/ima.cjs +420 -0
- package/lib/sdk/ima.cjs.map +1 -0
- package/lib/sdk/ima.d.cts +10 -0
- package/lib/types-GpA_hKek.d.cts +67 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +2905 -0
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -0
- package/lib/ui/StormcloudVideoPlayer.d.cts +13 -0
- package/lib/utils/tracking.cjs +250 -0
- package/lib/utils/tracking.cjs.map +1 -0
- package/lib/utils/tracking.d.cts +8 -0
- package/package.json +12 -5
- package/rollup.config.js +62 -0
package/lib/sdk/ima.cjs
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/sdk/ima.ts
|
|
21
|
+
var ima_exports = {};
|
|
22
|
+
__export(ima_exports, {
|
|
23
|
+
createImaController: () => createImaController
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ima_exports);
|
|
26
|
+
function createImaController(video) {
|
|
27
|
+
let adPlaying = false;
|
|
28
|
+
let originalMutedState = false;
|
|
29
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
30
|
+
function emit(event, payload) {
|
|
31
|
+
const set = listeners.get(event);
|
|
32
|
+
if (!set) return;
|
|
33
|
+
for (const fn of Array.from(set)) {
|
|
34
|
+
try {
|
|
35
|
+
fn(payload);
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function ensureImaLoaded() {
|
|
41
|
+
try {
|
|
42
|
+
const frameEl = window.frameElement;
|
|
43
|
+
const sandboxAttr = frameEl?.getAttribute?.("sandbox") || "";
|
|
44
|
+
if (sandboxAttr) {
|
|
45
|
+
const tokens = new Set(
|
|
46
|
+
sandboxAttr.split(/\s+/).map((t) => t.trim()).filter((t) => t.length > 0)
|
|
47
|
+
);
|
|
48
|
+
const allowsScripts = tokens.has("allow-scripts");
|
|
49
|
+
if (!allowsScripts) {
|
|
50
|
+
console.error(
|
|
51
|
+
"StormcloudVideoPlayer: The host page is inside a sandboxed iframe without 'allow-scripts'. Google IMA cannot run ads within sandboxed frames. Remove the sandbox attribute or include 'allow-scripts allow-same-origin'."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
if (typeof window !== "undefined" && window.google?.ima)
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
const existing = document.querySelector(
|
|
60
|
+
'script[data-ima="true"]'
|
|
61
|
+
);
|
|
62
|
+
if (existing) {
|
|
63
|
+
return new Promise(
|
|
64
|
+
(resolve) => existing.addEventListener("load", () => resolve())
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
const script = document.createElement("script");
|
|
69
|
+
script.src = "https://imasdk.googleapis.com/js/sdkloader/ima3.js";
|
|
70
|
+
script.async = true;
|
|
71
|
+
script.defer = true;
|
|
72
|
+
script.setAttribute("data-ima", "true");
|
|
73
|
+
script.onload = () => resolve();
|
|
74
|
+
script.onerror = () => reject(new Error("IMA SDK load failed"));
|
|
75
|
+
document.head.appendChild(script);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
let adsManager;
|
|
79
|
+
let adsLoader;
|
|
80
|
+
let adDisplayContainer;
|
|
81
|
+
let adContainerEl;
|
|
82
|
+
let lastAdTagUrl;
|
|
83
|
+
let retryAttempts = 0;
|
|
84
|
+
const maxRetries = 2;
|
|
85
|
+
const backoffBaseMs = 500;
|
|
86
|
+
let adsLoadedPromise;
|
|
87
|
+
let adsLoadedResolve;
|
|
88
|
+
let adsLoadedReject;
|
|
89
|
+
function makeAdsRequest(google, vastTagUrl) {
|
|
90
|
+
const adsRequest = new google.ima.AdsRequest();
|
|
91
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
92
|
+
adsLoader.requestAds(adsRequest);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
initialize() {
|
|
96
|
+
ensureImaLoaded().then(() => {
|
|
97
|
+
const google = window.google;
|
|
98
|
+
if (!adDisplayContainer) {
|
|
99
|
+
const container = document.createElement("div");
|
|
100
|
+
container.style.position = "absolute";
|
|
101
|
+
container.style.left = "0";
|
|
102
|
+
container.style.top = "0";
|
|
103
|
+
container.style.right = "0";
|
|
104
|
+
container.style.bottom = "0";
|
|
105
|
+
container.style.display = "flex";
|
|
106
|
+
container.style.alignItems = "center";
|
|
107
|
+
container.style.justifyContent = "center";
|
|
108
|
+
container.style.pointerEvents = "none";
|
|
109
|
+
container.style.zIndex = "2";
|
|
110
|
+
video.parentElement?.appendChild(container);
|
|
111
|
+
adContainerEl = container;
|
|
112
|
+
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
113
|
+
container,
|
|
114
|
+
video
|
|
115
|
+
);
|
|
116
|
+
try {
|
|
117
|
+
adDisplayContainer.initialize?.();
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}).catch(() => {
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
async requestAds(vastTagUrl) {
|
|
125
|
+
console.log("[IMA] Requesting ads:", vastTagUrl);
|
|
126
|
+
adsLoadedPromise = new Promise((resolve, reject) => {
|
|
127
|
+
adsLoadedResolve = resolve;
|
|
128
|
+
adsLoadedReject = reject;
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
if (adsLoadedReject) {
|
|
131
|
+
adsLoadedReject(new Error("Ad request timeout"));
|
|
132
|
+
adsLoadedReject = void 0;
|
|
133
|
+
adsLoadedResolve = void 0;
|
|
134
|
+
}
|
|
135
|
+
}, 1e4);
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
await ensureImaLoaded();
|
|
139
|
+
const google = window.google;
|
|
140
|
+
lastAdTagUrl = vastTagUrl;
|
|
141
|
+
retryAttempts = 0;
|
|
142
|
+
if (!adDisplayContainer) {
|
|
143
|
+
console.log("[IMA] Creating ad display container");
|
|
144
|
+
const container = document.createElement("div");
|
|
145
|
+
container.style.position = "absolute";
|
|
146
|
+
container.style.left = "0";
|
|
147
|
+
container.style.top = "0";
|
|
148
|
+
container.style.right = "0";
|
|
149
|
+
container.style.bottom = "0";
|
|
150
|
+
container.style.display = "flex";
|
|
151
|
+
container.style.alignItems = "center";
|
|
152
|
+
container.style.justifyContent = "center";
|
|
153
|
+
container.style.pointerEvents = "none";
|
|
154
|
+
container.style.zIndex = "2";
|
|
155
|
+
if (!video.parentElement) {
|
|
156
|
+
throw new Error("Video element has no parent for ad container");
|
|
157
|
+
}
|
|
158
|
+
video.parentElement.appendChild(container);
|
|
159
|
+
adContainerEl = container;
|
|
160
|
+
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
161
|
+
container,
|
|
162
|
+
video
|
|
163
|
+
);
|
|
164
|
+
try {
|
|
165
|
+
adDisplayContainer.initialize();
|
|
166
|
+
console.log("[IMA] Ad display container initialized");
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.warn(
|
|
169
|
+
"[IMA] Failed to initialize ad display container:",
|
|
170
|
+
error
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (!adsLoader) {
|
|
175
|
+
console.log("[IMA] Creating ads loader");
|
|
176
|
+
const adsLoaderCls = new google.ima.AdsLoader(adDisplayContainer);
|
|
177
|
+
adsLoader = adsLoaderCls;
|
|
178
|
+
adsLoader.addEventListener(
|
|
179
|
+
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
180
|
+
(evt) => {
|
|
181
|
+
console.log("[IMA] Ads manager loaded");
|
|
182
|
+
try {
|
|
183
|
+
adsManager = evt.getAdsManager(video);
|
|
184
|
+
const AdEvent = google.ima.AdEvent.Type;
|
|
185
|
+
const AdErrorEvent = google.ima.AdErrorEvent.Type;
|
|
186
|
+
adsManager.addEventListener(
|
|
187
|
+
AdErrorEvent.AD_ERROR,
|
|
188
|
+
(errorEvent) => {
|
|
189
|
+
console.error("[IMA] Ad error:", errorEvent.getError());
|
|
190
|
+
try {
|
|
191
|
+
adsManager?.destroy?.();
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
adPlaying = false;
|
|
195
|
+
video.muted = originalMutedState;
|
|
196
|
+
if (adContainerEl)
|
|
197
|
+
adContainerEl.style.pointerEvents = "none";
|
|
198
|
+
if (adsLoadedReject) {
|
|
199
|
+
adsLoadedReject(new Error("Ad playback error"));
|
|
200
|
+
adsLoadedReject = void 0;
|
|
201
|
+
adsLoadedResolve = void 0;
|
|
202
|
+
}
|
|
203
|
+
if (lastAdTagUrl && retryAttempts < maxRetries) {
|
|
204
|
+
const delay = backoffBaseMs * Math.pow(2, retryAttempts++);
|
|
205
|
+
console.log(
|
|
206
|
+
`[IMA] Retrying ad request in ${delay}ms (attempt ${retryAttempts})`
|
|
207
|
+
);
|
|
208
|
+
window.setTimeout(() => {
|
|
209
|
+
try {
|
|
210
|
+
makeAdsRequest(google, lastAdTagUrl);
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
}, delay);
|
|
214
|
+
} else {
|
|
215
|
+
console.log(
|
|
216
|
+
"[IMA] Max retries reached, emitting ad_error"
|
|
217
|
+
);
|
|
218
|
+
emit("ad_error");
|
|
219
|
+
video.play().catch(() => {
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
adsManager.addEventListener(
|
|
225
|
+
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
226
|
+
() => {
|
|
227
|
+
console.log("[IMA] Content pause requested");
|
|
228
|
+
originalMutedState = video.muted;
|
|
229
|
+
video.muted = true;
|
|
230
|
+
video.pause();
|
|
231
|
+
adPlaying = true;
|
|
232
|
+
if (adContainerEl)
|
|
233
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
234
|
+
emit("content_pause");
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
adsManager.addEventListener(
|
|
238
|
+
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
239
|
+
() => {
|
|
240
|
+
console.log("[IMA] Content resume requested");
|
|
241
|
+
adPlaying = false;
|
|
242
|
+
video.muted = originalMutedState;
|
|
243
|
+
if (adContainerEl)
|
|
244
|
+
adContainerEl.style.pointerEvents = "none";
|
|
245
|
+
video.play().catch(() => {
|
|
246
|
+
});
|
|
247
|
+
emit("content_resume");
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
251
|
+
console.log("[IMA] All ads completed");
|
|
252
|
+
adPlaying = false;
|
|
253
|
+
video.muted = originalMutedState;
|
|
254
|
+
if (adContainerEl) adContainerEl.style.pointerEvents = "none";
|
|
255
|
+
video.play().catch(() => {
|
|
256
|
+
});
|
|
257
|
+
emit("all_ads_completed");
|
|
258
|
+
});
|
|
259
|
+
console.log("[IMA] Ads manager event listeners attached");
|
|
260
|
+
if (adsLoadedResolve) {
|
|
261
|
+
adsLoadedResolve();
|
|
262
|
+
adsLoadedResolve = void 0;
|
|
263
|
+
adsLoadedReject = void 0;
|
|
264
|
+
}
|
|
265
|
+
} catch (e) {
|
|
266
|
+
console.error("[IMA] Error setting up ads manager:", e);
|
|
267
|
+
adPlaying = false;
|
|
268
|
+
video.muted = originalMutedState;
|
|
269
|
+
if (adContainerEl) adContainerEl.style.pointerEvents = "none";
|
|
270
|
+
video.play().catch(() => {
|
|
271
|
+
});
|
|
272
|
+
if (adsLoadedReject) {
|
|
273
|
+
adsLoadedReject(new Error("Failed to setup ads manager"));
|
|
274
|
+
adsLoadedReject = void 0;
|
|
275
|
+
adsLoadedResolve = void 0;
|
|
276
|
+
}
|
|
277
|
+
emit("ad_error");
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
false
|
|
281
|
+
);
|
|
282
|
+
adsLoader.addEventListener(
|
|
283
|
+
google.ima.AdErrorEvent.Type.AD_ERROR,
|
|
284
|
+
(adErrorEvent) => {
|
|
285
|
+
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
286
|
+
if (adsLoadedReject) {
|
|
287
|
+
adsLoadedReject(new Error("Ads loader error"));
|
|
288
|
+
adsLoadedReject = void 0;
|
|
289
|
+
adsLoadedResolve = void 0;
|
|
290
|
+
}
|
|
291
|
+
emit("ad_error");
|
|
292
|
+
},
|
|
293
|
+
false
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
console.log("[IMA] Making ads request");
|
|
297
|
+
makeAdsRequest(google, vastTagUrl);
|
|
298
|
+
return adsLoadedPromise;
|
|
299
|
+
} catch (error) {
|
|
300
|
+
console.error("[IMA] Failed to request ads:", error);
|
|
301
|
+
if (adsLoadedReject) {
|
|
302
|
+
adsLoadedReject(error);
|
|
303
|
+
adsLoadedReject = void 0;
|
|
304
|
+
adsLoadedResolve = void 0;
|
|
305
|
+
}
|
|
306
|
+
return Promise.reject(error);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
async play() {
|
|
310
|
+
if (!window.google?.ima || !adDisplayContainer) {
|
|
311
|
+
console.warn(
|
|
312
|
+
"[IMA] Cannot play ad: IMA SDK or ad container not available"
|
|
313
|
+
);
|
|
314
|
+
return Promise.reject(new Error("IMA SDK not available"));
|
|
315
|
+
}
|
|
316
|
+
if (!adsManager) {
|
|
317
|
+
console.warn("[IMA] Cannot play ad: No ads manager available");
|
|
318
|
+
return Promise.reject(new Error("No ads manager"));
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
const width = video.clientWidth || 640;
|
|
322
|
+
const height = video.clientHeight || 360;
|
|
323
|
+
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
324
|
+
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
325
|
+
console.log("[IMA] Pausing video for ad playback");
|
|
326
|
+
video.pause();
|
|
327
|
+
adPlaying = true;
|
|
328
|
+
console.log("[IMA] Starting ad playback");
|
|
329
|
+
adsManager.start();
|
|
330
|
+
return Promise.resolve();
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error("[IMA] Error starting ad playback:", error);
|
|
333
|
+
adPlaying = false;
|
|
334
|
+
video.play().catch(() => {
|
|
335
|
+
});
|
|
336
|
+
return Promise.reject(error);
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
async stop() {
|
|
340
|
+
adPlaying = false;
|
|
341
|
+
video.muted = originalMutedState;
|
|
342
|
+
try {
|
|
343
|
+
adsManager?.stop?.();
|
|
344
|
+
} catch {
|
|
345
|
+
}
|
|
346
|
+
video.play().catch(() => {
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
destroy() {
|
|
350
|
+
try {
|
|
351
|
+
adsManager?.destroy?.();
|
|
352
|
+
} catch {
|
|
353
|
+
}
|
|
354
|
+
adPlaying = false;
|
|
355
|
+
video.muted = originalMutedState;
|
|
356
|
+
try {
|
|
357
|
+
adsLoader?.destroy?.();
|
|
358
|
+
} catch {
|
|
359
|
+
}
|
|
360
|
+
if (adContainerEl?.parentElement) {
|
|
361
|
+
adContainerEl.parentElement.removeChild(adContainerEl);
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
isAdPlaying() {
|
|
365
|
+
return adPlaying;
|
|
366
|
+
},
|
|
367
|
+
resize(width, height) {
|
|
368
|
+
if (!adsManager || !window.google?.ima) {
|
|
369
|
+
console.warn(
|
|
370
|
+
"[IMA] Cannot resize: No ads manager or IMA SDK available"
|
|
371
|
+
);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
console.log(`[IMA] Resizing ads manager to ${width}x${height}`);
|
|
376
|
+
adsManager.resize(width, height, window.google.ima.ViewMode.NORMAL);
|
|
377
|
+
} catch (error) {
|
|
378
|
+
console.warn("[IMA] Error resizing ads manager:", error);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
on(event, listener) {
|
|
382
|
+
if (!listeners.has(event)) listeners.set(event, /* @__PURE__ */ new Set());
|
|
383
|
+
listeners.get(event).add(listener);
|
|
384
|
+
},
|
|
385
|
+
off(event, listener) {
|
|
386
|
+
listeners.get(event)?.delete(listener);
|
|
387
|
+
},
|
|
388
|
+
updateOriginalMutedState(muted) {
|
|
389
|
+
originalMutedState = muted;
|
|
390
|
+
},
|
|
391
|
+
getOriginalMutedState() {
|
|
392
|
+
return originalMutedState;
|
|
393
|
+
},
|
|
394
|
+
setAdVolume(volume) {
|
|
395
|
+
if (adsManager && adPlaying) {
|
|
396
|
+
try {
|
|
397
|
+
adsManager.setVolume(Math.max(0, Math.min(1, volume)));
|
|
398
|
+
} catch (error) {
|
|
399
|
+
console.warn("[IMA] Failed to set ad volume:", error);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
getAdVolume() {
|
|
404
|
+
if (adsManager && adPlaying) {
|
|
405
|
+
try {
|
|
406
|
+
return adsManager.getVolume();
|
|
407
|
+
} catch (error) {
|
|
408
|
+
console.warn("[IMA] Failed to get ad volume:", error);
|
|
409
|
+
return 1;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return 1;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
417
|
+
0 && (module.exports = {
|
|
418
|
+
createImaController
|
|
419
|
+
});
|
|
420
|
+
//# sourceMappingURL=ima.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/ima.ts"],"sourcesContent":["import type { ImaController } from \"../types\";\n\ndeclare global {\n interface Window {\n google?: any;\n }\n}\n\nexport function createImaController(video: HTMLVideoElement): ImaController {\n let adPlaying = false;\n let originalMutedState = false;\n const listeners = new Map<string, Set<(payload?: any) => void>>();\n\n function emit(event: string, payload?: any): void {\n const set = listeners.get(event);\n if (!set) return;\n for (const fn of Array.from(set)) {\n try {\n fn(payload);\n } catch {}\n }\n }\n\n function ensureImaLoaded(): Promise<void> {\n try {\n const frameEl = window.frameElement as HTMLIFrameElement | null;\n const sandboxAttr = frameEl?.getAttribute?.(\"sandbox\") || \"\";\n if (sandboxAttr) {\n const tokens = new Set(\n sandboxAttr\n .split(/\\s+/)\n .map((t) => t.trim())\n .filter((t) => t.length > 0)\n );\n const allowsScripts = tokens.has(\"allow-scripts\");\n if (!allowsScripts) {\n // eslint-disable-next-line no-console\n console.error(\n \"StormcloudVideoPlayer: The host page is inside a sandboxed iframe without 'allow-scripts'. Google IMA cannot run ads within sandboxed frames. Remove the sandbox attribute or include 'allow-scripts allow-same-origin'.\"\n );\n }\n }\n } catch {}\n\n if (typeof window !== \"undefined\" && window.google?.ima)\n return Promise.resolve();\n const existing = document.querySelector(\n 'script[data-ima=\"true\"]'\n ) as HTMLScriptElement | null;\n if (existing) {\n return new Promise((resolve) =>\n existing.addEventListener(\"load\", () => resolve())\n );\n }\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://imasdk.googleapis.com/js/sdkloader/ima3.js\";\n script.async = true;\n script.defer = true;\n script.setAttribute(\"data-ima\", \"true\");\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(\"IMA SDK load failed\"));\n document.head.appendChild(script);\n });\n }\n\n let adsManager: any | undefined;\n let adsLoader: any | undefined;\n let adDisplayContainer: any | undefined;\n let adContainerEl: HTMLDivElement | undefined;\n let lastAdTagUrl: string | undefined;\n let retryAttempts = 0;\n const maxRetries = 2;\n const backoffBaseMs = 500;\n let adsLoadedPromise: Promise<void> | undefined;\n let adsLoadedResolve: (() => void) | undefined;\n let adsLoadedReject: ((error: Error) => void) | undefined;\n\n function makeAdsRequest(google: any, vastTagUrl: string) {\n const adsRequest = new google.ima.AdsRequest();\n adsRequest.adTagUrl = vastTagUrl;\n adsLoader.requestAds(adsRequest);\n }\n\n return {\n initialize() {\n ensureImaLoaded()\n .then(() => {\n const google = window.google;\n if (!adDisplayContainer) {\n const container = document.createElement(\"div\");\n container.style.position = \"absolute\";\n container.style.left = \"0\";\n container.style.top = \"0\";\n container.style.right = \"0\";\n container.style.bottom = \"0\";\n container.style.display = \"flex\";\n container.style.alignItems = \"center\";\n container.style.justifyContent = \"center\";\n container.style.pointerEvents = \"none\";\n container.style.zIndex = \"2\";\n video.parentElement?.appendChild(container);\n adContainerEl = container;\n adDisplayContainer = new google.ima.AdDisplayContainer(\n container,\n video\n );\n try {\n adDisplayContainer.initialize?.();\n } catch {}\n }\n })\n .catch(() => {});\n },\n async requestAds(vastTagUrl: string) {\n console.log(\"[IMA] Requesting ads:\", vastTagUrl);\n\n adsLoadedPromise = new Promise<void>((resolve, reject) => {\n adsLoadedResolve = resolve;\n adsLoadedReject = reject;\n\n setTimeout(() => {\n if (adsLoadedReject) {\n adsLoadedReject(new Error(\"Ad request timeout\"));\n adsLoadedReject = undefined;\n adsLoadedResolve = undefined;\n }\n }, 10000);\n });\n\n try {\n await ensureImaLoaded();\n const google = window.google;\n lastAdTagUrl = vastTagUrl;\n retryAttempts = 0;\n\n if (!adDisplayContainer) {\n console.log(\"[IMA] Creating ad display container\");\n const container = document.createElement(\"div\");\n container.style.position = \"absolute\";\n container.style.left = \"0\";\n container.style.top = \"0\";\n container.style.right = \"0\";\n container.style.bottom = \"0\";\n container.style.display = \"flex\";\n container.style.alignItems = \"center\";\n container.style.justifyContent = \"center\";\n container.style.pointerEvents = \"none\";\n container.style.zIndex = \"2\";\n\n if (!video.parentElement) {\n throw new Error(\"Video element has no parent for ad container\");\n }\n\n video.parentElement.appendChild(container);\n adContainerEl = container;\n adDisplayContainer = new google.ima.AdDisplayContainer(\n container,\n video\n );\n\n try {\n adDisplayContainer.initialize();\n console.log(\"[IMA] Ad display container initialized\");\n } catch (error) {\n console.warn(\n \"[IMA] Failed to initialize ad display container:\",\n error\n );\n }\n }\n\n if (!adsLoader) {\n console.log(\"[IMA] Creating ads loader\");\n const adsLoaderCls = new google.ima.AdsLoader(adDisplayContainer);\n adsLoader = adsLoaderCls;\n\n adsLoader.addEventListener(\n google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,\n (evt: any) => {\n console.log(\"[IMA] Ads manager loaded\");\n try {\n adsManager = evt.getAdsManager(video);\n const AdEvent = google.ima.AdEvent.Type;\n const AdErrorEvent = google.ima.AdErrorEvent.Type;\n\n adsManager.addEventListener(\n AdErrorEvent.AD_ERROR,\n (errorEvent: any) => {\n console.error(\"[IMA] Ad error:\", errorEvent.getError());\n try {\n adsManager?.destroy?.();\n } catch {}\n adPlaying = false;\n video.muted = originalMutedState;\n if (adContainerEl)\n adContainerEl.style.pointerEvents = \"none\";\n\n if (adsLoadedReject) {\n adsLoadedReject(new Error(\"Ad playback error\"));\n adsLoadedReject = undefined;\n adsLoadedResolve = undefined;\n }\n\n if (lastAdTagUrl && retryAttempts < maxRetries) {\n const delay =\n backoffBaseMs * Math.pow(2, retryAttempts++);\n console.log(\n `[IMA] Retrying ad request in ${delay}ms (attempt ${retryAttempts})`\n );\n window.setTimeout(() => {\n try {\n makeAdsRequest(google, lastAdTagUrl!);\n } catch {}\n }, delay);\n } else {\n console.log(\n \"[IMA] Max retries reached, emitting ad_error\"\n );\n emit(\"ad_error\");\n video.play().catch(() => {});\n }\n }\n );\n\n adsManager.addEventListener(\n AdEvent.CONTENT_PAUSE_REQUESTED,\n () => {\n console.log(\"[IMA] Content pause requested\");\n originalMutedState = video.muted;\n video.muted = true;\n video.pause();\n adPlaying = true;\n if (adContainerEl)\n adContainerEl.style.pointerEvents = \"auto\";\n emit(\"content_pause\");\n }\n );\n\n adsManager.addEventListener(\n AdEvent.CONTENT_RESUME_REQUESTED,\n () => {\n console.log(\"[IMA] Content resume requested\");\n adPlaying = false;\n video.muted = originalMutedState;\n if (adContainerEl)\n adContainerEl.style.pointerEvents = \"none\";\n video.play().catch(() => {});\n emit(\"content_resume\");\n }\n );\n\n adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {\n console.log(\"[IMA] All ads completed\");\n adPlaying = false;\n video.muted = originalMutedState;\n if (adContainerEl) adContainerEl.style.pointerEvents = \"none\";\n video.play().catch(() => {});\n emit(\"all_ads_completed\");\n });\n\n console.log(\"[IMA] Ads manager event listeners attached\");\n\n if (adsLoadedResolve) {\n adsLoadedResolve();\n adsLoadedResolve = undefined;\n adsLoadedReject = undefined;\n }\n } catch (e) {\n console.error(\"[IMA] Error setting up ads manager:\", e);\n adPlaying = false;\n video.muted = originalMutedState;\n if (adContainerEl) adContainerEl.style.pointerEvents = \"none\";\n video.play().catch(() => {});\n\n if (adsLoadedReject) {\n adsLoadedReject(new Error(\"Failed to setup ads manager\"));\n adsLoadedReject = undefined;\n adsLoadedResolve = undefined;\n }\n emit(\"ad_error\");\n }\n },\n false\n );\n\n adsLoader.addEventListener(\n google.ima.AdErrorEvent.Type.AD_ERROR,\n (adErrorEvent: any) => {\n console.error(\"[IMA] Ads loader error:\", adErrorEvent.getError());\n\n if (adsLoadedReject) {\n adsLoadedReject(new Error(\"Ads loader error\"));\n adsLoadedReject = undefined;\n adsLoadedResolve = undefined;\n }\n emit(\"ad_error\");\n },\n false\n );\n }\n\n console.log(\"[IMA] Making ads request\");\n makeAdsRequest(google, vastTagUrl);\n\n return adsLoadedPromise;\n } catch (error) {\n console.error(\"[IMA] Failed to request ads:\", error);\n if (adsLoadedReject) {\n adsLoadedReject(error as Error);\n adsLoadedReject = undefined;\n adsLoadedResolve = undefined;\n }\n return Promise.reject(error);\n }\n },\n async play() {\n if (!window.google?.ima || !adDisplayContainer) {\n console.warn(\n \"[IMA] Cannot play ad: IMA SDK or ad container not available\"\n );\n return Promise.reject(new Error(\"IMA SDK not available\"));\n }\n\n if (!adsManager) {\n console.warn(\"[IMA] Cannot play ad: No ads manager available\");\n return Promise.reject(new Error(\"No ads manager\"));\n }\n\n try {\n const width = video.clientWidth || 640;\n const height = video.clientHeight || 360;\n\n console.log(`[IMA] Initializing ads manager (${width}x${height})`);\n adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);\n\n console.log(\"[IMA] Pausing video for ad playback\");\n video.pause();\n adPlaying = true;\n\n console.log(\"[IMA] Starting ad playback\");\n adsManager.start();\n\n return Promise.resolve();\n } catch (error) {\n console.error(\"[IMA] Error starting ad playback:\", error);\n adPlaying = false;\n video.play().catch(() => {});\n return Promise.reject(error);\n }\n },\n async stop() {\n adPlaying = false;\n video.muted = originalMutedState;\n try {\n adsManager?.stop?.();\n } catch {}\n video.play().catch(() => {});\n },\n destroy() {\n try {\n adsManager?.destroy?.();\n } catch {}\n adPlaying = false;\n video.muted = originalMutedState;\n try {\n adsLoader?.destroy?.();\n } catch {}\n if (adContainerEl?.parentElement) {\n adContainerEl.parentElement.removeChild(adContainerEl);\n }\n },\n isAdPlaying() {\n return adPlaying;\n },\n resize(width: number, height: number) {\n if (!adsManager || !window.google?.ima) {\n console.warn(\n \"[IMA] Cannot resize: No ads manager or IMA SDK available\"\n );\n return;\n }\n\n try {\n console.log(`[IMA] Resizing ads manager to ${width}x${height}`);\n adsManager.resize(width, height, window.google.ima.ViewMode.NORMAL);\n } catch (error) {\n console.warn(\"[IMA] Error resizing ads manager:\", error);\n }\n },\n on(event: string, listener: (payload?: any) => void) {\n if (!listeners.has(event)) listeners.set(event, new Set());\n listeners.get(event)!.add(listener);\n },\n off(event: string, listener: (payload?: any) => void) {\n listeners.get(event)?.delete(listener);\n },\n updateOriginalMutedState(muted: boolean) {\n originalMutedState = muted;\n },\n getOriginalMutedState() {\n return originalMutedState;\n },\n setAdVolume(volume: number) {\n if (adsManager && adPlaying) {\n try {\n adsManager.setVolume(Math.max(0, Math.min(1, volume)));\n } catch (error) {\n console.warn(\"[IMA] Failed to set ad volume:\", error);\n }\n }\n },\n getAdVolume(): number {\n if (adsManager && adPlaying) {\n try {\n return adsManager.getVolume();\n } catch (error) {\n console.warn(\"[IMA] Failed to get ad volume:\", error);\n return 1;\n }\n }\n return 1;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,oBAAoB,OAA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ig {
|
|
2
|
+
videoElement: HTMLVideoElement;
|
|
3
|
+
src: string;
|
|
4
|
+
autoplay?: boolean;
|
|
5
|
+
muted?: boolean;
|
|
6
|
+
allowNativeHls?: boolean;
|
|
7
|
+
lowLatencyMode?: boolean;
|
|
8
|
+
driftToleranceMs?: number;
|
|
9
|
+
immediateManifestAds?: boolean;
|
|
10
|
+
debugAdTiming?: boolean;
|
|
11
|
+
adFailsafeTimeoutMs?: number;
|
|
12
|
+
showCustomControls?: boolean;
|
|
13
|
+
onVolumeToggle?: () => void;
|
|
14
|
+
onFullscreenToggle?: () => void;
|
|
15
|
+
onControlClick?: () => void;
|
|
16
|
+
licenseKey?: string;
|
|
17
|
+
}
|
|
18
|
+
interface ImaController {
|
|
19
|
+
initialize: () => void;
|
|
20
|
+
requestAds: (vastTagUrl: string) => Promise<void>;
|
|
21
|
+
play: () => Promise<void>;
|
|
22
|
+
stop: () => Promise<void>;
|
|
23
|
+
destroy: () => void;
|
|
24
|
+
isAdPlaying: () => boolean;
|
|
25
|
+
resize: (width: number, height: number) => void;
|
|
26
|
+
on: (event: string, listener: (payload?: any) => void) => void;
|
|
27
|
+
off: (event: string, listener: (payload?: any) => void) => void;
|
|
28
|
+
updateOriginalMutedState: (muted: boolean) => void;
|
|
29
|
+
getOriginalMutedState: () => boolean;
|
|
30
|
+
setAdVolume: (volume: number) => void;
|
|
31
|
+
getAdVolume: () => number;
|
|
32
|
+
}
|
|
33
|
+
interface ClientInfo {
|
|
34
|
+
brand: string;
|
|
35
|
+
os: string;
|
|
36
|
+
model: string;
|
|
37
|
+
deviceType: "tv" | "mobile" | "tablet" | "desktop";
|
|
38
|
+
isSmartTV: boolean;
|
|
39
|
+
isAndroid: boolean;
|
|
40
|
+
isWebView: boolean;
|
|
41
|
+
isWebApp: boolean;
|
|
42
|
+
domain: string;
|
|
43
|
+
origin: string;
|
|
44
|
+
path: string;
|
|
45
|
+
userAgent: string;
|
|
46
|
+
vendor: string;
|
|
47
|
+
platform: string;
|
|
48
|
+
screen: {
|
|
49
|
+
width?: number;
|
|
50
|
+
height?: number;
|
|
51
|
+
availWidth?: number;
|
|
52
|
+
availHeight?: number;
|
|
53
|
+
orientation?: string;
|
|
54
|
+
pixelDepth?: number;
|
|
55
|
+
};
|
|
56
|
+
hardwareConcurrency: number;
|
|
57
|
+
deviceMemory: number | null;
|
|
58
|
+
maxTouchPoints: number;
|
|
59
|
+
language: string;
|
|
60
|
+
languages: string;
|
|
61
|
+
cookieEnabled: boolean;
|
|
62
|
+
doNotTrack: string;
|
|
63
|
+
referrer: string;
|
|
64
|
+
visibilityState: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type { ClientInfo as C, ImaController as I, StormcloudVideoPlayerConfig as S };
|