stormcloud-video-player 0.2.26 → 0.2.27

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/lib/index.d.cts CHANGED
@@ -181,6 +181,7 @@ declare class StormcloudVideoPlayer {
181
181
  toggleFullscreen(): Promise<void>;
182
182
  isMuted(): boolean;
183
183
  setMuted(muted: boolean): void;
184
+ setVolume(volume: number): void;
184
185
  isFullscreen(): boolean;
185
186
  isLive(): boolean;
186
187
  get videoElement(): HTMLVideoElement;
package/lib/index.d.ts CHANGED
@@ -181,6 +181,7 @@ declare class StormcloudVideoPlayer {
181
181
  toggleFullscreen(): Promise<void>;
182
182
  isMuted(): boolean;
183
183
  setMuted(muted: boolean): void;
184
+ setVolume(volume: number): void;
184
185
  isFullscreen(): boolean;
185
186
  isLive(): boolean;
186
187
  get videoElement(): HTMLVideoElement;
package/lib/index.js CHANGED
@@ -3488,6 +3488,26 @@ var StormcloudVideoPlayer = class {
3488
3488
  console.log("[StormcloudVideoPlayer] setMuted called:", muted);
3489
3489
  }
3490
3490
  }
3491
+ setVolume(volume) {
3492
+ const clampedVolume = Math.max(0, Math.min(1, volume));
3493
+ const adPlaying = this.ima.isAdPlaying();
3494
+ if (adPlaying) {
3495
+ this.ima.setAdVolume(clampedVolume);
3496
+ this.ima.updateOriginalMutedState(clampedVolume === 0, clampedVolume);
3497
+ if (this.config.debugAdTiming) {
3498
+ console.log("[StormcloudVideoPlayer] setVolume applied during ad", {
3499
+ volume: clampedVolume
3500
+ });
3501
+ }
3502
+ } else {
3503
+ this.video.volume = clampedVolume;
3504
+ this.video.muted = clampedVolume === 0;
3505
+ this.ima.updateOriginalMutedState(clampedVolume === 0, clampedVolume);
3506
+ if (this.config.debugAdTiming) {
3507
+ console.log("[StormcloudVideoPlayer] setVolume called:", clampedVolume);
3508
+ }
3509
+ }
3510
+ }
3491
3511
  isFullscreen() {
3492
3512
  return !!document.fullscreenElement;
3493
3513
  }
@@ -3668,10 +3688,9 @@ var StormcloudVideoPlayerComponent = React.memo(
3668
3688
  }
3669
3689
  };
3670
3690
  const handleVolumeChange = (newVolume) => {
3671
- if (videoRef.current && isFinite(newVolume)) {
3691
+ if (playerRef.current && isFinite(newVolume)) {
3672
3692
  const clampedVolume = Math.max(0, Math.min(1, newVolume));
3673
- videoRef.current.volume = clampedVolume;
3674
- videoRef.current.muted = clampedVolume === 0;
3693
+ playerRef.current.setVolume(clampedVolume);
3675
3694
  }
3676
3695
  };
3677
3696
  const handlePlaybackRateChange = (rate) => {
@@ -3773,7 +3792,7 @@ var StormcloudVideoPlayerComponent = React.memo(
3773
3792
  if (autoplay !== void 0 && playerRef.current.videoElement) {
3774
3793
  playerRef.current.videoElement.autoplay = autoplay;
3775
3794
  }
3776
- if (muted !== void 0) {
3795
+ if (muted !== void 0 && !playerRef.current.isShowingAds()) {
3777
3796
  playerRef.current.setMuted(muted);
3778
3797
  }
3779
3798
  } catch (error) {