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.cjs CHANGED
@@ -1267,17 +1267,10 @@ function createPrebidAdLayer(contentVideo, options) {
1267
1267
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1268
1268
  adPlaying = false;
1269
1269
  setAdPlayingFlag(false);
1270
- contentVideo.muted = originalMutedState;
1271
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1272
1270
  if (adContainerEl) {
1273
1271
  adContainerEl.style.display = "none";
1274
1272
  adContainerEl.style.pointerEvents = "none";
1275
1273
  }
1276
- contentVideo.style.visibility = "visible";
1277
- contentVideo.style.opacity = "1";
1278
- if (continueLiveStreamDuringAds) {
1279
- contentVideo.play().catch(function() {});
1280
- }
1281
1274
  emit("ad_impression");
1282
1275
  emit("content_resume");
1283
1276
  }
@@ -1286,8 +1279,6 @@ function createPrebidAdLayer(contentVideo, options) {
1286
1279
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1287
1280
  adPlaying = false;
1288
1281
  setAdPlayingFlag(false);
1289
- contentVideo.muted = originalMutedState;
1290
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1291
1282
  if (adContainerEl) {
1292
1283
  adContainerEl.style.display = "none";
1293
1284
  adContainerEl.style.pointerEvents = "none";
@@ -2995,13 +2986,25 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2995
2986
  }
2996
2987
  if (!(this.bufferedSegmentsCount >= minSegments)) return [
2997
2988
  3,
2998
- 2
2989
+ 3
2999
2990
  ];
3000
2991
  this.hasInitialBufferCompleted = true;
3001
2992
  if (!this.shouldAutoplayAfterBuffering) return [
3002
2993
  3,
3003
- 2
2994
+ 3
2995
+ ];
2996
+ if (!(this.inAdBreak || this.adLayer.isAdPlaying())) return [
2997
+ 3,
2998
+ 1
2999
+ ];
3000
+ if (this.config.debugAdTiming) {
3001
+ console.log("[StormcloudVideoPlayer] Initial buffer complete (".concat(this.bufferedSegmentsCount, " segments). Ad break active — deferring play() to handleAdPodComplete()."));
3002
+ }
3003
+ return [
3004
+ 3,
3005
+ 3
3004
3006
  ];
3007
+ case 1:
3005
3008
  if (this.config.debugAdTiming) {
3006
3009
  console.log("[StormcloudVideoPlayer] Initial buffer complete (".concat(this.bufferedSegmentsCount, " segments). Starting playback."));
3007
3010
  }
@@ -3013,10 +3016,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3013
3016
  }
3014
3017
  })
3015
3018
  ];
3016
- case 1:
3017
- _state.sent();
3018
- _state.label = 2;
3019
3019
  case 2:
3020
+ _state.sent();
3021
+ _state.label = 3;
3022
+ case 3:
3020
3023
  return [
3021
3024
  2
3022
3025
  ];
@@ -3241,6 +3244,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3241
3244
  _this.activeAdRequestToken = null;
3242
3245
  _this.showAds = false;
3243
3246
  if (!_this.inAdBreak) {
3247
+ _this.video.style.visibility = "visible";
3248
+ _this.video.style.opacity = "1";
3244
3249
  _this.syncMainContentAudioWhenVisible();
3245
3250
  return;
3246
3251
  }
@@ -4851,11 +4856,28 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4851
4856
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
4852
4857
  this.video.volume = restoredVolume;
4853
4858
  }
4854
- var isTizen = detectBrowser().tizenVersion !== void 0;
4855
- if (isTizen && this.hls) {
4859
+ var browser = detectBrowser();
4860
+ var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0;
4861
+ if (isSmartTV && this.hls) {
4862
+ if (!restoredMuted) {
4863
+ var hlsRef = this.hls;
4864
+ var savedMuted = restoredMuted;
4865
+ var savedVolume = restoredVolume;
4866
+ var onManifestParsedRestore = function onManifestParsedRestore1() {
4867
+ hlsRef.off(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
4868
+ if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
4869
+ if (_this.video.muted !== savedMuted) _this.video.muted = savedMuted;
4870
+ if (Math.abs(_this.video.volume - savedVolume) > 0.01) _this.video.volume = savedVolume;
4871
+ if (_this.config.debugAdTiming) {
4872
+ console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
4873
+ }
4874
+ }
4875
+ };
4876
+ hlsRef.on(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
4877
+ }
4856
4878
  this.hls.attachMedia(this.video);
4857
4879
  if (this.config.debugAdTiming) {
4858
- console.log("[StormcloudVideoPlayer] Tizen: re-attached HLS to video element after ad break to restore audio");
4880
+ console.log("[StormcloudVideoPlayer] Smart TV: re-attached HLS to video element after ad break to restore media pipeline");
4859
4881
  }
4860
4882
  }
4861
4883
  if (this.shouldContinueLiveStreamDuringAds()) {
@@ -4890,6 +4912,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4890
4912
  _this.syncMainContentAudioWhenVisible();
4891
4913
  }, 150);
4892
4914
  }
4915
+ if (isSmartTV && !restoredMuted) {
4916
+ [
4917
+ 500,
4918
+ 1e3,
4919
+ 2e3,
4920
+ 3e3,
4921
+ 5e3
4922
+ ].forEach(function(delay) {
4923
+ setTimeout(function() {
4924
+ if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
4925
+ if (_this.video.muted !== restoredMuted) _this.video.muted = restoredMuted;
4926
+ if (Math.abs(_this.video.volume - restoredVolume) > 0.01) _this.video.volume = restoredVolume;
4927
+ }
4928
+ }, delay);
4929
+ });
4930
+ }
4893
4931
  this.savedMutedStateBeforeScte = null;
4894
4932
  }
4895
4933
  },