stormcloud-video-player 0.5.19 → 0.5.21

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.js CHANGED
@@ -1107,17 +1107,10 @@ function createPrebidAdLayer(contentVideo, options) {
1107
1107
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1108
1108
  adPlaying = false;
1109
1109
  setAdPlayingFlag(false);
1110
- contentVideo.muted = originalMutedState;
1111
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1112
1110
  if (adContainerEl) {
1113
1111
  adContainerEl.style.display = "none";
1114
1112
  adContainerEl.style.pointerEvents = "none";
1115
1113
  }
1116
- contentVideo.style.visibility = "visible";
1117
- contentVideo.style.opacity = "1";
1118
- if (continueLiveStreamDuringAds) {
1119
- contentVideo.play().catch(function() {});
1120
- }
1121
1114
  emit("ad_impression");
1122
1115
  emit("content_resume");
1123
1116
  }
@@ -1126,8 +1119,6 @@ function createPrebidAdLayer(contentVideo, options) {
1126
1119
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1127
1120
  adPlaying = false;
1128
1121
  setAdPlayingFlag(false);
1129
- contentVideo.muted = originalMutedState;
1130
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1131
1122
  if (adContainerEl) {
1132
1123
  adContainerEl.style.display = "none";
1133
1124
  adContainerEl.style.pointerEvents = "none";
@@ -2838,13 +2829,25 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2838
2829
  }
2839
2830
  if (!(this.bufferedSegmentsCount >= minSegments)) return [
2840
2831
  3,
2841
- 2
2832
+ 3
2842
2833
  ];
2843
2834
  this.hasInitialBufferCompleted = true;
2844
2835
  if (!this.shouldAutoplayAfterBuffering) return [
2845
2836
  3,
2846
- 2
2837
+ 3
2838
+ ];
2839
+ if (!(this.inAdBreak || this.adLayer.isAdPlaying())) return [
2840
+ 3,
2841
+ 1
2842
+ ];
2843
+ if (this.config.debugAdTiming) {
2844
+ console.log("[StormcloudVideoPlayer] Initial buffer complete (".concat(this.bufferedSegmentsCount, " segments). Ad break active — deferring play() to handleAdPodComplete()."));
2845
+ }
2846
+ return [
2847
+ 3,
2848
+ 3
2847
2849
  ];
2850
+ case 1:
2848
2851
  if (this.config.debugAdTiming) {
2849
2852
  console.log("[StormcloudVideoPlayer] Initial buffer complete (".concat(this.bufferedSegmentsCount, " segments). Starting playback."));
2850
2853
  }
@@ -2856,10 +2859,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2856
2859
  }
2857
2860
  })
2858
2861
  ];
2859
- case 1:
2860
- _state.sent();
2861
- _state.label = 2;
2862
2862
  case 2:
2863
+ _state.sent();
2864
+ _state.label = 3;
2865
+ case 3:
2863
2866
  return [
2864
2867
  2
2865
2868
  ];
@@ -3084,6 +3087,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3084
3087
  _this.activeAdRequestToken = null;
3085
3088
  _this.showAds = false;
3086
3089
  if (!_this.inAdBreak) {
3090
+ _this.video.style.visibility = "visible";
3091
+ _this.video.style.opacity = "1";
3087
3092
  _this.syncMainContentAudioWhenVisible();
3088
3093
  return;
3089
3094
  }
@@ -4694,11 +4699,28 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4694
4699
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
4695
4700
  this.video.volume = restoredVolume;
4696
4701
  }
4697
- var isTizen = detectBrowser().tizenVersion !== void 0;
4698
- if (isTizen && this.hls) {
4702
+ var browser = detectBrowser();
4703
+ var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0;
4704
+ if (isSmartTV && this.hls) {
4705
+ if (!restoredMuted) {
4706
+ var hlsRef = this.hls;
4707
+ var savedMuted = restoredMuted;
4708
+ var savedVolume = restoredVolume;
4709
+ var onManifestParsedRestore = function onManifestParsedRestore1() {
4710
+ hlsRef.off(Hls2.Events.MANIFEST_PARSED, onManifestParsedRestore);
4711
+ if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
4712
+ if (_this.video.muted !== savedMuted) _this.video.muted = savedMuted;
4713
+ if (Math.abs(_this.video.volume - savedVolume) > 0.01) _this.video.volume = savedVolume;
4714
+ if (_this.config.debugAdTiming) {
4715
+ console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
4716
+ }
4717
+ }
4718
+ };
4719
+ hlsRef.on(Hls2.Events.MANIFEST_PARSED, onManifestParsedRestore);
4720
+ }
4699
4721
  this.hls.attachMedia(this.video);
4700
4722
  if (this.config.debugAdTiming) {
4701
- console.log("[StormcloudVideoPlayer] Tizen: re-attached HLS to video element after ad break to restore audio");
4723
+ console.log("[StormcloudVideoPlayer] Smart TV: re-attached HLS to video element after ad break to restore media pipeline");
4702
4724
  }
4703
4725
  }
4704
4726
  if (this.shouldContinueLiveStreamDuringAds()) {
@@ -4733,6 +4755,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4733
4755
  _this.syncMainContentAudioWhenVisible();
4734
4756
  }, 150);
4735
4757
  }
4758
+ if (isSmartTV && !restoredMuted) {
4759
+ [
4760
+ 500,
4761
+ 1e3,
4762
+ 2e3,
4763
+ 3e3,
4764
+ 5e3
4765
+ ].forEach(function(delay) {
4766
+ setTimeout(function() {
4767
+ if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
4768
+ if (_this.video.muted !== restoredMuted) _this.video.muted = restoredMuted;
4769
+ if (Math.abs(_this.video.volume - restoredVolume) > 0.01) _this.video.volume = restoredVolume;
4770
+ }
4771
+ }, delay);
4772
+ });
4773
+ }
4736
4774
  this.savedMutedStateBeforeScte = null;
4737
4775
  }
4738
4776
  },