stormcloud-video-player 0.8.51 → 0.8.53

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;
@@ -1298,7 +1299,7 @@ function createHlsAdPlayer(contentVideo, options) {
1298
1299
  }
1299
1300
  function fetchAndParsePod(vastTagUrl) {
1300
1301
  return _async_to_generator(function() {
1301
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1302
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1302
1303
  return _ts_generator(this, function(_state) {
1303
1304
  switch(_state.label){
1304
1305
  case 0:
@@ -1308,11 +1309,19 @@ function createHlsAdPlayer(contentVideo, options) {
1308
1309
  ];
1309
1310
  case 1:
1310
1311
  vastXml = _state.sent();
1311
- console.log("[HlsAdPlayer] Pod VAST XML received");
1312
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1313
+ trimmedXml = vastXml.trim();
1314
+ if (trimmedXml.length === 0) {
1315
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1316
+ return [
1317
+ 2,
1318
+ []
1319
+ ];
1320
+ }
1312
1321
  parser = new DOMParser();
1313
1322
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1314
1323
  if (xmlDoc.querySelector("parsererror")) {
1315
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1324
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1316
1325
  return [
1317
1326
  2,
1318
1327
  []
@@ -1320,7 +1329,7 @@ function createHlsAdPlayer(contentVideo, options) {
1320
1329
  }
1321
1330
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1322
1331
  if (adElements.length === 0) {
1323
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1332
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1324
1333
  return [
1325
1334
  2,
1326
1335
  []
@@ -1799,6 +1808,12 @@ function createHlsAdPlayer(contentVideo, options) {
1799
1808
  function markFrameCounterReliable() {
1800
1809
  contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1801
1810
  }
1811
+ function isRvfcReliable() {
1812
+ return contentVideo[RVFC_RELIABLE_PROP] === true;
1813
+ }
1814
+ function markRvfcReliable() {
1815
+ contentVideo[RVFC_RELIABLE_PROP] = true;
1816
+ }
1802
1817
  function cancelVideoFrameProbe() {
1803
1818
  if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1804
1819
  try {
@@ -1818,6 +1833,7 @@ function createHlsAdPlayer(contentVideo, options) {
1818
1833
  videoFrameCallbackHandle = void 0;
1819
1834
  if (!adPlaying) return;
1820
1835
  sawDecodedVideoFrame = true;
1836
+ markRvfcReliable();
1821
1837
  };
1822
1838
  try {
1823
1839
  videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
@@ -1842,18 +1858,19 @@ function createHlsAdPlayer(contentVideo, options) {
1842
1858
  noteAdProgress();
1843
1859
  sawDecodedVideoFrame = false;
1844
1860
  startVideoFrameProbe();
1861
+ var blackFrameDetectionEnabled = !requiresMediaPipelineResetAfterAds();
1845
1862
  stallWatchdogId = window.setInterval(function() {
1846
1863
  if (!adPlaying || !adVideoElement) {
1847
1864
  return;
1848
1865
  }
1849
- if (!sawDecodedVideoFrame && !adVideoElement.paused) {
1866
+ if (blackFrameDetectionEnabled && !sawDecodedVideoFrame && !adVideoElement.paused) {
1850
1867
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1851
1868
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1852
1869
  sawDecodedVideoFrame = true;
1853
1870
  markFrameCounterReliable();
1854
1871
  } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1855
1872
  var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1856
- if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1873
+ if (isRvfcSupported(adVideoElement) && timeAdvancing && isRvfcReliable()) {
1857
1874
  handleVideoDecodeFailure();
1858
1875
  return;
1859
1876
  }
@@ -2254,7 +2271,7 @@ function createHlsAdPlayer(contentVideo, options) {
2254
2271
  }
2255
2272
  },
2256
2273
  hidePlaceholder: function hidePlaceholder() {
2257
- if (adContainerEl) {
2274
+ if (adContainerEl && !adPlaying) {
2258
2275
  adContainerEl.style.display = "none";
2259
2276
  adContainerEl.style.pointerEvents = "none";
2260
2277
  }