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.js CHANGED
@@ -578,6 +578,7 @@ function createHlsAdPlayer(contentVideo, options) {
578
578
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
579
579
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
580
580
  var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
581
+ var RVFC_RELIABLE_PROP = "__stormcloudRvfcReliable";
581
582
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
582
583
  var adHls;
583
584
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -1078,7 +1079,7 @@ function createHlsAdPlayer(contentVideo, options) {
1078
1079
  }
1079
1080
  function fetchAndParsePod(vastTagUrl) {
1080
1081
  return _async_to_generator(function() {
1081
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1082
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1082
1083
  return _ts_generator(this, function(_state) {
1083
1084
  switch(_state.label){
1084
1085
  case 0:
@@ -1088,11 +1089,19 @@ function createHlsAdPlayer(contentVideo, options) {
1088
1089
  ];
1089
1090
  case 1:
1090
1091
  vastXml = _state.sent();
1091
- console.log("[HlsAdPlayer] Pod VAST XML received");
1092
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1093
+ trimmedXml = vastXml.trim();
1094
+ if (trimmedXml.length === 0) {
1095
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1096
+ return [
1097
+ 2,
1098
+ []
1099
+ ];
1100
+ }
1092
1101
  parser = new DOMParser();
1093
1102
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1094
1103
  if (xmlDoc.querySelector("parsererror")) {
1095
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1104
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1096
1105
  return [
1097
1106
  2,
1098
1107
  []
@@ -1100,7 +1109,7 @@ function createHlsAdPlayer(contentVideo, options) {
1100
1109
  }
1101
1110
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1102
1111
  if (adElements.length === 0) {
1103
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1112
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1104
1113
  return [
1105
1114
  2,
1106
1115
  []
@@ -1579,6 +1588,12 @@ function createHlsAdPlayer(contentVideo, options) {
1579
1588
  function markFrameCounterReliable() {
1580
1589
  contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1581
1590
  }
1591
+ function isRvfcReliable() {
1592
+ return contentVideo[RVFC_RELIABLE_PROP] === true;
1593
+ }
1594
+ function markRvfcReliable() {
1595
+ contentVideo[RVFC_RELIABLE_PROP] = true;
1596
+ }
1582
1597
  function cancelVideoFrameProbe() {
1583
1598
  if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1584
1599
  try {
@@ -1598,6 +1613,7 @@ function createHlsAdPlayer(contentVideo, options) {
1598
1613
  videoFrameCallbackHandle = void 0;
1599
1614
  if (!adPlaying) return;
1600
1615
  sawDecodedVideoFrame = true;
1616
+ markRvfcReliable();
1601
1617
  };
1602
1618
  try {
1603
1619
  videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
@@ -1622,18 +1638,19 @@ function createHlsAdPlayer(contentVideo, options) {
1622
1638
  noteAdProgress();
1623
1639
  sawDecodedVideoFrame = false;
1624
1640
  startVideoFrameProbe();
1641
+ var blackFrameDetectionEnabled = !requiresMediaPipelineResetAfterAds();
1625
1642
  stallWatchdogId = window.setInterval(function() {
1626
1643
  if (!adPlaying || !adVideoElement) {
1627
1644
  return;
1628
1645
  }
1629
- if (!sawDecodedVideoFrame && !adVideoElement.paused) {
1646
+ if (blackFrameDetectionEnabled && !sawDecodedVideoFrame && !adVideoElement.paused) {
1630
1647
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1631
1648
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1632
1649
  sawDecodedVideoFrame = true;
1633
1650
  markFrameCounterReliable();
1634
1651
  } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1635
1652
  var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1636
- if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1653
+ if (isRvfcSupported(adVideoElement) && timeAdvancing && isRvfcReliable()) {
1637
1654
  handleVideoDecodeFailure();
1638
1655
  return;
1639
1656
  }
@@ -2034,7 +2051,7 @@ function createHlsAdPlayer(contentVideo, options) {
2034
2051
  }
2035
2052
  },
2036
2053
  hidePlaceholder: function hidePlaceholder() {
2037
- if (adContainerEl) {
2054
+ if (adContainerEl && !adPlaying) {
2038
2055
  adContainerEl.style.display = "none";
2039
2056
  adContainerEl.style.pointerEvents = "none";
2040
2057
  }