stormcloud-video-player 0.8.51 → 0.8.52

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
@@ -798,6 +798,7 @@ function createHlsAdPlayer(contentVideo, options) {
798
798
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
799
799
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
800
800
  var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
801
+ var RVFC_RELIABLE_PROP = "__stormcloudRvfcReliable";
801
802
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
802
803
  var adHls;
803
804
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -1799,6 +1800,12 @@ function createHlsAdPlayer(contentVideo, options) {
1799
1800
  function markFrameCounterReliable() {
1800
1801
  contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1801
1802
  }
1803
+ function isRvfcReliable() {
1804
+ return contentVideo[RVFC_RELIABLE_PROP] === true;
1805
+ }
1806
+ function markRvfcReliable() {
1807
+ contentVideo[RVFC_RELIABLE_PROP] = true;
1808
+ }
1802
1809
  function cancelVideoFrameProbe() {
1803
1810
  if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1804
1811
  try {
@@ -1818,6 +1825,7 @@ function createHlsAdPlayer(contentVideo, options) {
1818
1825
  videoFrameCallbackHandle = void 0;
1819
1826
  if (!adPlaying) return;
1820
1827
  sawDecodedVideoFrame = true;
1828
+ markRvfcReliable();
1821
1829
  };
1822
1830
  try {
1823
1831
  videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
@@ -1842,18 +1850,19 @@ function createHlsAdPlayer(contentVideo, options) {
1842
1850
  noteAdProgress();
1843
1851
  sawDecodedVideoFrame = false;
1844
1852
  startVideoFrameProbe();
1853
+ var blackFrameDetectionEnabled = !requiresMediaPipelineResetAfterAds();
1845
1854
  stallWatchdogId = window.setInterval(function() {
1846
1855
  if (!adPlaying || !adVideoElement) {
1847
1856
  return;
1848
1857
  }
1849
- if (!sawDecodedVideoFrame && !adVideoElement.paused) {
1858
+ if (blackFrameDetectionEnabled && !sawDecodedVideoFrame && !adVideoElement.paused) {
1850
1859
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1851
1860
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1852
1861
  sawDecodedVideoFrame = true;
1853
1862
  markFrameCounterReliable();
1854
1863
  } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1855
1864
  var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1856
- if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1865
+ if (isRvfcSupported(adVideoElement) && timeAdvancing && isRvfcReliable()) {
1857
1866
  handleVideoDecodeFailure();
1858
1867
  return;
1859
1868
  }
@@ -2254,7 +2263,7 @@ function createHlsAdPlayer(contentVideo, options) {
2254
2263
  }
2255
2264
  },
2256
2265
  hidePlaceholder: function hidePlaceholder() {
2257
- if (adContainerEl) {
2266
+ if (adContainerEl && !adPlaying) {
2258
2267
  adContainerEl.style.display = "none";
2259
2268
  adContainerEl.style.pointerEvents = "none";
2260
2269
  }