stormcloud-video-player 0.2.25 → 0.2.26
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 +2 -2
- package/lib/index.cjs +49 -13
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +49 -13
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +49 -13
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +49 -13
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +49 -13
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +15 -3
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +26 -3
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-9_2sbHCg.d.cts → types-t9jEJXZy.d.cts} +2 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +49 -13
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { S as StormcloudVideoPlayerConfig } from '../types-
|
|
2
|
+
import { S as StormcloudVideoPlayerConfig } from '../types-t9jEJXZy.cjs';
|
|
3
3
|
|
|
4
4
|
interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
|
|
5
5
|
onMount?: (player: any) => void;
|
package/lib/players/index.cjs
CHANGED
|
@@ -241,6 +241,7 @@ function getBrowserConfigOverrides() {
|
|
|
241
241
|
function createImaController(video, options) {
|
|
242
242
|
let adPlaying = false;
|
|
243
243
|
let originalMutedState = false;
|
|
244
|
+
let originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
244
245
|
const listeners = /* @__PURE__ */ new Map();
|
|
245
246
|
const preloadedVast = /* @__PURE__ */ new Map();
|
|
246
247
|
const preloadingVast = /* @__PURE__ */ new Map();
|
|
@@ -349,6 +350,22 @@ function createImaController(video, options) {
|
|
|
349
350
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
350
351
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
351
352
|
adsRequest.nonLinearAdSlotHeight = videoHeight;
|
|
353
|
+
if (typeof adsRequest.setAdWillAutoPlay === "function") {
|
|
354
|
+
try {
|
|
355
|
+
const willAutoPlay = !video.paused || video.autoplay;
|
|
356
|
+
adsRequest.setAdWillAutoPlay(willAutoPlay);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
console.warn("[IMA] Failed to call setAdWillAutoPlay:", error);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (typeof adsRequest.setAdWillPlayMuted === "function") {
|
|
362
|
+
try {
|
|
363
|
+
const willPlayMuted = video.muted || video.volume === 0;
|
|
364
|
+
adsRequest.setAdWillPlayMuted(willPlayMuted);
|
|
365
|
+
} catch (error) {
|
|
366
|
+
console.warn("[IMA] Failed to call setAdWillPlayMuted:", error);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
352
369
|
adsRequest.vastLoadTimeout = 5e3;
|
|
353
370
|
console.log(`[IMA] Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
354
371
|
adsLoader.requestAds(adsRequest);
|
|
@@ -754,7 +771,7 @@ function createImaController(video, options) {
|
|
|
754
771
|
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
755
772
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
756
773
|
adPlaying = true;
|
|
757
|
-
const adVolume = originalMutedState ? 0 :
|
|
774
|
+
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
758
775
|
try {
|
|
759
776
|
adsManager.setVolume(adVolume);
|
|
760
777
|
console.log(`[IMA] Set ad volume to ${adVolume}`);
|
|
@@ -796,6 +813,7 @@ function createImaController(video, options) {
|
|
|
796
813
|
destroyAdsManager();
|
|
797
814
|
adPlaying = false;
|
|
798
815
|
video.muted = originalMutedState;
|
|
816
|
+
video.volume = originalVolume;
|
|
799
817
|
setAdPlayingFlag(false);
|
|
800
818
|
if (adContainerEl) {
|
|
801
819
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -840,15 +858,20 @@ function createImaController(video, options) {
|
|
|
840
858
|
var _a;
|
|
841
859
|
(_a = listeners.get(event)) == null ? void 0 : _a.delete(listener);
|
|
842
860
|
},
|
|
843
|
-
updateOriginalMutedState(muted) {
|
|
861
|
+
updateOriginalMutedState(muted, volume) {
|
|
862
|
+
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
844
863
|
console.log(
|
|
845
|
-
`[IMA] updateOriginalMutedState called: ${originalMutedState} -> ${muted}`
|
|
864
|
+
`[IMA] updateOriginalMutedState called: { muted: ${originalMutedState} -> ${muted}, volume: ${originalVolume} -> ${nextVolume} }`
|
|
846
865
|
);
|
|
847
866
|
originalMutedState = muted;
|
|
867
|
+
originalVolume = nextVolume;
|
|
848
868
|
},
|
|
849
869
|
getOriginalMutedState() {
|
|
850
870
|
return originalMutedState;
|
|
851
871
|
},
|
|
872
|
+
getOriginalVolume() {
|
|
873
|
+
return originalVolume;
|
|
874
|
+
},
|
|
852
875
|
setAdVolume(volume) {
|
|
853
876
|
if (adsManager && adPlaying) {
|
|
854
877
|
try {
|
|
@@ -890,6 +913,7 @@ var import_hls = __toESM(require("hls.js"), 1);
|
|
|
890
913
|
function createHlsAdPlayer(contentVideo, options) {
|
|
891
914
|
let adPlaying = false;
|
|
892
915
|
let originalMutedState = false;
|
|
916
|
+
let originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
893
917
|
const listeners = /* @__PURE__ */ new Map();
|
|
894
918
|
const licenseKey = options == null ? void 0 : options.licenseKey;
|
|
895
919
|
const mainHlsInstance = options == null ? void 0 : options.mainHlsInstance;
|
|
@@ -1247,6 +1271,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1247
1271
|
setAdPlayingFlag(false);
|
|
1248
1272
|
const previousMutedState = contentVideo.muted;
|
|
1249
1273
|
contentVideo.muted = originalMutedState;
|
|
1274
|
+
contentVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
1250
1275
|
console.log(
|
|
1251
1276
|
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1252
1277
|
);
|
|
@@ -1376,6 +1401,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1376
1401
|
complete: false
|
|
1377
1402
|
};
|
|
1378
1403
|
const contentVolume = contentVideo.volume;
|
|
1404
|
+
originalVolume = Math.max(
|
|
1405
|
+
0,
|
|
1406
|
+
Math.min(1, contentVolume || originalVolume)
|
|
1407
|
+
);
|
|
1379
1408
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1380
1409
|
contentVideo.pause();
|
|
1381
1410
|
console.log("[HlsAdPlayer] Content paused (VOD mode)");
|
|
@@ -1388,7 +1417,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1388
1417
|
adPlaying = true;
|
|
1389
1418
|
setAdPlayingFlag(true);
|
|
1390
1419
|
if (adVideoElement) {
|
|
1391
|
-
const adVolume = originalMutedState ? 0 :
|
|
1420
|
+
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
1392
1421
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1393
1422
|
adVideoElement.muted = false;
|
|
1394
1423
|
console.log(
|
|
@@ -1467,6 +1496,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1467
1496
|
adPlaying = false;
|
|
1468
1497
|
setAdPlayingFlag(false);
|
|
1469
1498
|
contentVideo.muted = originalMutedState;
|
|
1499
|
+
contentVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
1470
1500
|
if (adHls) {
|
|
1471
1501
|
adHls.destroy();
|
|
1472
1502
|
adHls = void 0;
|
|
@@ -1508,15 +1538,20 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1508
1538
|
var _a;
|
|
1509
1539
|
(_a = listeners.get(event)) == null ? void 0 : _a.delete(listener);
|
|
1510
1540
|
},
|
|
1511
|
-
updateOriginalMutedState(muted) {
|
|
1541
|
+
updateOriginalMutedState(muted, volume) {
|
|
1542
|
+
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
1512
1543
|
console.log(
|
|
1513
|
-
`[HlsAdPlayer] updateOriginalMutedState called: ${originalMutedState} -> ${muted}`
|
|
1544
|
+
`[HlsAdPlayer] updateOriginalMutedState called: { muted: ${originalMutedState} -> ${muted}, volume: ${originalVolume} -> ${nextVolume} }`
|
|
1514
1545
|
);
|
|
1515
1546
|
originalMutedState = muted;
|
|
1547
|
+
originalVolume = nextVolume;
|
|
1516
1548
|
},
|
|
1517
1549
|
getOriginalMutedState() {
|
|
1518
1550
|
return originalMutedState;
|
|
1519
1551
|
},
|
|
1552
|
+
getOriginalVolume() {
|
|
1553
|
+
return originalVolume;
|
|
1554
|
+
},
|
|
1520
1555
|
setAdVolume(volume) {
|
|
1521
1556
|
if (adVideoElement && adPlaying) {
|
|
1522
1557
|
adVideoElement.volume = Math.max(0, Math.min(1, volume));
|
|
@@ -2297,7 +2332,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2297
2332
|
this.video.autoplay = !!this.config.autoplay;
|
|
2298
2333
|
this.video.muted = !!this.config.muted;
|
|
2299
2334
|
this.ima.initialize();
|
|
2300
|
-
this.ima.updateOriginalMutedState(this.video.muted);
|
|
2335
|
+
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
2301
2336
|
this.ima.on("all_ads_completed", () => {
|
|
2302
2337
|
if (this.config.debugAdTiming) {
|
|
2303
2338
|
console.log(
|
|
@@ -3186,7 +3221,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3186
3221
|
}
|
|
3187
3222
|
);
|
|
3188
3223
|
}
|
|
3189
|
-
this.ima.updateOriginalMutedState(this.video.muted);
|
|
3224
|
+
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3190
3225
|
} else if (this.config.debugAdTiming) {
|
|
3191
3226
|
console.log(
|
|
3192
3227
|
`[StormcloudVideoPlayer] Keeping existing original mute state (currently showing ads)`
|
|
@@ -3248,8 +3283,9 @@ var StormcloudVideoPlayer = class {
|
|
|
3248
3283
|
this.ima.stop().catch(() => {
|
|
3249
3284
|
});
|
|
3250
3285
|
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3286
|
+
const originalVolume = typeof this.ima.getOriginalVolume === "function" ? this.ima.getOriginalVolume() : this.video.volume;
|
|
3251
3287
|
this.video.muted = originalMutedState;
|
|
3252
|
-
this.video.volume =
|
|
3288
|
+
this.video.volume = originalVolume;
|
|
3253
3289
|
if (this.config.debugAdTiming) {
|
|
3254
3290
|
console.log(
|
|
3255
3291
|
`[StormcloudVideoPlayer] Restored main video - muted: ${originalMutedState}, volume: ${this.video.volume}`
|
|
@@ -3400,7 +3436,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3400
3436
|
if (this.ima.isAdPlaying()) {
|
|
3401
3437
|
const currentPerceptualState = this.isMuted();
|
|
3402
3438
|
const newMutedState = !currentPerceptualState;
|
|
3403
|
-
this.ima.updateOriginalMutedState(newMutedState);
|
|
3439
|
+
this.ima.updateOriginalMutedState(newMutedState, this.video.volume);
|
|
3404
3440
|
this.ima.setAdVolume(newMutedState ? 0 : 1);
|
|
3405
3441
|
if (this.config.debugAdTiming) {
|
|
3406
3442
|
console.log(
|
|
@@ -3410,7 +3446,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3410
3446
|
}
|
|
3411
3447
|
} else {
|
|
3412
3448
|
this.video.muted = !this.video.muted;
|
|
3413
|
-
this.ima.updateOriginalMutedState(this.video.muted);
|
|
3449
|
+
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3414
3450
|
if (this.config.debugAdTiming) {
|
|
3415
3451
|
console.log("[StormcloudVideoPlayer] Muted:", this.video.muted);
|
|
3416
3452
|
}
|
|
@@ -3482,7 +3518,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3482
3518
|
}
|
|
3483
3519
|
this.video.muted = muted;
|
|
3484
3520
|
if (adPlaying) {
|
|
3485
|
-
this.ima.updateOriginalMutedState(muted);
|
|
3521
|
+
this.ima.updateOriginalMutedState(muted, this.video.volume);
|
|
3486
3522
|
this.ima.setAdVolume(muted ? 0 : 1);
|
|
3487
3523
|
if (this.config.debugAdTiming) {
|
|
3488
3524
|
console.log("[StormcloudVideoPlayer] setMuted applied during ad", {
|
|
@@ -3491,7 +3527,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3491
3527
|
}
|
|
3492
3528
|
return;
|
|
3493
3529
|
}
|
|
3494
|
-
this.ima.updateOriginalMutedState(muted);
|
|
3530
|
+
this.ima.updateOriginalMutedState(muted, this.video.volume);
|
|
3495
3531
|
if (this.config.debugAdTiming) {
|
|
3496
3532
|
console.log("[StormcloudVideoPlayer] setMuted called:", muted);
|
|
3497
3533
|
}
|