stormcloud-video-player 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +30 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +30 -14
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +30 -14
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +30 -14
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +30 -14
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +3 -9
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +30 -14
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/tracking.cjs +7 -1
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -268,7 +268,9 @@ function createImaController(video, options) {
|
|
|
268
268
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
269
269
|
() => {
|
|
270
270
|
console.log("[IMA] Content pause requested");
|
|
271
|
-
|
|
271
|
+
if (!adPlaying) {
|
|
272
|
+
originalMutedState = video.muted;
|
|
273
|
+
}
|
|
272
274
|
video.muted = true;
|
|
273
275
|
if (!options?.continueLiveStreamDuringAds) {
|
|
274
276
|
video.pause();
|
|
@@ -390,14 +392,6 @@ function createImaController(video, options) {
|
|
|
390
392
|
const height = video.clientHeight || 360;
|
|
391
393
|
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
392
394
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
393
|
-
if (!options?.continueLiveStreamDuringAds) {
|
|
394
|
-
console.log("[IMA] Pausing video for ad playback (VOD mode)");
|
|
395
|
-
video.pause();
|
|
396
|
-
} else {
|
|
397
|
-
console.log(
|
|
398
|
-
"[IMA] Keeping video playing but muted for ad playback (Live mode)"
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
395
|
adPlaying = true;
|
|
402
396
|
console.log("[IMA] Starting ad playback");
|
|
403
397
|
adsManager.start();
|
|
@@ -496,6 +490,7 @@ function createImaController(video, options) {
|
|
|
496
490
|
}
|
|
497
491
|
|
|
498
492
|
// src/utils/tracking.ts
|
|
493
|
+
var cachedBrowserId = null;
|
|
499
494
|
function getClientInfo() {
|
|
500
495
|
const ua = navigator.userAgent;
|
|
501
496
|
const platform = navigator.platform;
|
|
@@ -638,6 +633,9 @@ function getClientInfo() {
|
|
|
638
633
|
};
|
|
639
634
|
}
|
|
640
635
|
async function getBrowserID(clientInfo) {
|
|
636
|
+
if (cachedBrowserId) {
|
|
637
|
+
return cachedBrowserId;
|
|
638
|
+
}
|
|
641
639
|
const fingerprintString = JSON.stringify(clientInfo);
|
|
642
640
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
643
641
|
try {
|
|
@@ -648,6 +646,7 @@ async function getBrowserID(clientInfo) {
|
|
|
648
646
|
);
|
|
649
647
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
650
648
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
649
|
+
cachedBrowserId = hashHex;
|
|
651
650
|
return hashHex;
|
|
652
651
|
} catch (error) {
|
|
653
652
|
console.warn(
|
|
@@ -664,7 +663,8 @@ async function getBrowserID(clientInfo) {
|
|
|
664
663
|
const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
|
|
665
664
|
const timestamp = Date.now().toString(16).padStart(12, "0");
|
|
666
665
|
const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
|
|
667
|
-
|
|
666
|
+
cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
|
|
667
|
+
return cachedBrowserId;
|
|
668
668
|
}
|
|
669
669
|
async function sendInitialTracking(licenseKey) {
|
|
670
670
|
try {
|
|
@@ -1353,17 +1353,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1353
1353
|
return void 0;
|
|
1354
1354
|
}
|
|
1355
1355
|
initializeTracking() {
|
|
1356
|
-
sendInitialTracking(this.config.licenseKey).
|
|
1356
|
+
sendInitialTracking(this.config.licenseKey).then(() => {
|
|
1357
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1358
|
+
this.sendHeartbeatIfNeeded();
|
|
1359
|
+
}, 5e3);
|
|
1360
|
+
}).catch((error) => {
|
|
1357
1361
|
if (this.config.debugAdTiming) {
|
|
1358
1362
|
console.warn(
|
|
1359
1363
|
"[StormcloudVideoPlayer] Failed to send initial tracking:",
|
|
1360
1364
|
error
|
|
1361
1365
|
);
|
|
1362
1366
|
}
|
|
1367
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1368
|
+
this.sendHeartbeatIfNeeded();
|
|
1369
|
+
}, 5e3);
|
|
1363
1370
|
});
|
|
1364
|
-
this.heartbeatInterval = window.setInterval(() => {
|
|
1365
|
-
this.sendHeartbeatIfNeeded();
|
|
1366
|
-
}, 5e3);
|
|
1367
1371
|
}
|
|
1368
1372
|
sendHeartbeatIfNeeded() {
|
|
1369
1373
|
const now = Date.now();
|
|
@@ -1598,6 +1602,18 @@ var StormcloudVideoPlayer = class {
|
|
|
1598
1602
|
if (this.config.debugAdTiming) {
|
|
1599
1603
|
console.log("[StormcloudVideoPlayer] Attempting to play ad:", vastTagUrl);
|
|
1600
1604
|
}
|
|
1605
|
+
this.ima.updateOriginalMutedState(this.video.muted);
|
|
1606
|
+
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
1607
|
+
if (this.config.debugAdTiming) {
|
|
1608
|
+
console.log("[StormcloudVideoPlayer] Pausing video immediately for ad (VOD mode)");
|
|
1609
|
+
}
|
|
1610
|
+
this.video.pause();
|
|
1611
|
+
} else {
|
|
1612
|
+
if (this.config.debugAdTiming) {
|
|
1613
|
+
console.log("[StormcloudVideoPlayer] Muting video for ad (Live mode)");
|
|
1614
|
+
}
|
|
1615
|
+
this.video.muted = true;
|
|
1616
|
+
}
|
|
1601
1617
|
this.startAdFailsafeTimer();
|
|
1602
1618
|
try {
|
|
1603
1619
|
await this.ima.requestAds(vastTagUrl);
|