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.
@@ -1085,17 +1085,10 @@ function createPrebidAdLayer(contentVideo, options) {
1085
1085
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1086
1086
  adPlaying = false;
1087
1087
  setAdPlayingFlag(false);
1088
- contentVideo.muted = originalMutedState;
1089
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1090
1088
  if (adContainerEl) {
1091
1089
  adContainerEl.style.display = "none";
1092
1090
  adContainerEl.style.pointerEvents = "none";
1093
1091
  }
1094
- contentVideo.style.visibility = "visible";
1095
- contentVideo.style.opacity = "1";
1096
- if (continueLiveStreamDuringAds) {
1097
- contentVideo.play().catch(function() {});
1098
- }
1099
1092
  emit("ad_impression");
1100
1093
  emit("content_resume");
1101
1094
  }
@@ -1104,8 +1097,6 @@ function createPrebidAdLayer(contentVideo, options) {
1104
1097
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1105
1098
  adPlaying = false;
1106
1099
  setAdPlayingFlag(false);
1107
- contentVideo.muted = originalMutedState;
1108
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1109
1100
  if (adContainerEl) {
1110
1101
  adContainerEl.style.display = "none";
1111
1102
  adContainerEl.style.pointerEvents = "none";
@@ -2788,13 +2779,25 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2788
2779
  }
2789
2780
  if (!(this.bufferedSegmentsCount >= minSegments)) return [
2790
2781
  3,
2791
- 2
2782
+ 3
2792
2783
  ];
2793
2784
  this.hasInitialBufferCompleted = true;
2794
2785
  if (!this.shouldAutoplayAfterBuffering) return [
2795
2786
  3,
2796
- 2
2787
+ 3
2788
+ ];
2789
+ if (!(this.inAdBreak || this.adLayer.isAdPlaying())) return [
2790
+ 3,
2791
+ 1
2792
+ ];
2793
+ if (this.config.debugAdTiming) {
2794
+ console.log("[StormcloudVideoPlayer] Initial buffer complete (".concat(this.bufferedSegmentsCount, " segments). Ad break active — deferring play() to handleAdPodComplete()."));
2795
+ }
2796
+ return [
2797
+ 3,
2798
+ 3
2797
2799
  ];
2800
+ case 1:
2798
2801
  if (this.config.debugAdTiming) {
2799
2802
  console.log("[StormcloudVideoPlayer] Initial buffer complete (".concat(this.bufferedSegmentsCount, " segments). Starting playback."));
2800
2803
  }
@@ -2806,10 +2809,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2806
2809
  }
2807
2810
  })
2808
2811
  ];
2809
- case 1:
2810
- _state.sent();
2811
- _state.label = 2;
2812
2812
  case 2:
2813
+ _state.sent();
2814
+ _state.label = 3;
2815
+ case 3:
2813
2816
  return [
2814
2817
  2
2815
2818
  ];
@@ -3034,6 +3037,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3034
3037
  _this.activeAdRequestToken = null;
3035
3038
  _this.showAds = false;
3036
3039
  if (!_this.inAdBreak) {
3040
+ _this.video.style.visibility = "visible";
3041
+ _this.video.style.opacity = "1";
3037
3042
  _this.syncMainContentAudioWhenVisible();
3038
3043
  return;
3039
3044
  }
@@ -4644,11 +4649,28 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4644
4649
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
4645
4650
  this.video.volume = restoredVolume;
4646
4651
  }
4647
- var isTizen = detectBrowser().tizenVersion !== void 0;
4648
- if (isTizen && this.hls) {
4652
+ var browser = detectBrowser();
4653
+ var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0;
4654
+ if (isSmartTV && this.hls) {
4655
+ if (!restoredMuted) {
4656
+ var hlsRef = this.hls;
4657
+ var savedMuted = restoredMuted;
4658
+ var savedVolume = restoredVolume;
4659
+ var onManifestParsedRestore = function onManifestParsedRestore1() {
4660
+ hlsRef.off(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
4661
+ if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
4662
+ if (_this.video.muted !== savedMuted) _this.video.muted = savedMuted;
4663
+ if (Math.abs(_this.video.volume - savedVolume) > 0.01) _this.video.volume = savedVolume;
4664
+ if (_this.config.debugAdTiming) {
4665
+ console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
4666
+ }
4667
+ }
4668
+ };
4669
+ hlsRef.on(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
4670
+ }
4649
4671
  this.hls.attachMedia(this.video);
4650
4672
  if (this.config.debugAdTiming) {
4651
- console.log("[StormcloudVideoPlayer] Tizen: re-attached HLS to video element after ad break to restore audio");
4673
+ console.log("[StormcloudVideoPlayer] Smart TV: re-attached HLS to video element after ad break to restore media pipeline");
4652
4674
  }
4653
4675
  }
4654
4676
  if (this.shouldContinueLiveStreamDuringAds()) {
@@ -4683,6 +4705,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4683
4705
  _this.syncMainContentAudioWhenVisible();
4684
4706
  }, 150);
4685
4707
  }
4708
+ if (isSmartTV && !restoredMuted) {
4709
+ [
4710
+ 500,
4711
+ 1e3,
4712
+ 2e3,
4713
+ 3e3,
4714
+ 5e3
4715
+ ].forEach(function(delay) {
4716
+ setTimeout(function() {
4717
+ if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
4718
+ if (_this.video.muted !== restoredMuted) _this.video.muted = restoredMuted;
4719
+ if (Math.abs(_this.video.volume - restoredVolume) > 0.01) _this.video.volume = restoredVolume;
4720
+ }
4721
+ }, delay);
4722
+ });
4723
+ }
4686
4724
  this.savedMutedStateBeforeScte = null;
4687
4725
  }
4688
4726
  },