stormcloud-video-player 0.3.59 → 0.3.60

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.
@@ -1709,6 +1709,16 @@ function createHlsAdPlayer(contentVideo, options) {
1709
1709
  });
1710
1710
  return bestMatch.file;
1711
1711
  }
1712
+ function isHlsMediaFile(mediaFile) {
1713
+ var type = mediaFile.type.toLowerCase();
1714
+ var url = mediaFile.url.toLowerCase();
1715
+ return type === "application/x-mpegurl" || type === "application/vnd.apple.mpegurl" || type.includes("mpegurl") || url.includes(".m3u8");
1716
+ }
1717
+ function isProgressiveMediaFile(mediaFile) {
1718
+ var type = mediaFile.type.toLowerCase();
1719
+ var url = mediaFile.url.toLowerCase();
1720
+ return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
1721
+ }
1712
1722
  function parseVastXml(xmlString) {
1713
1723
  try {
1714
1724
  var _xmlDoc_querySelector, _xmlDoc_querySelector1, _xmlDoc_querySelector_textContent, _xmlDoc_querySelector2;
@@ -1740,30 +1750,32 @@ function createHlsAdPlayer(contentVideo, options) {
1740
1750
  var width = mf.getAttribute("width") || "";
1741
1751
  var height = mf.getAttribute("height") || "";
1742
1752
  console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
1743
- if (type === "application/x-mpegURL" || type.includes("m3u8")) {
1744
- if (!url) {
1745
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has HLS type but empty URL"));
1746
- return;
1747
- }
1748
- var bitrateAttr = mf.getAttribute("bitrate");
1749
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
1750
- mediaFiles.push({
1751
- url: url,
1752
- type: type,
1753
- width: parseInt(width || "1920", 10),
1754
- height: parseInt(height || "1080", 10),
1755
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
1756
- });
1757
- console.log("[HlsAdPlayer] Added HLS MediaFile: ".concat(url));
1753
+ var mediaFile = {
1754
+ url: url,
1755
+ type: type,
1756
+ width: parseInt(width || "1920", 10),
1757
+ height: parseInt(height || "1080", 10),
1758
+ bitrate: void 0
1759
+ };
1760
+ if (!url) {
1761
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
1762
+ return;
1763
+ }
1764
+ var bitrateAttr = mf.getAttribute("bitrate");
1765
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
1766
+ mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
1767
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
1768
+ mediaFiles.push(mediaFile);
1769
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
1758
1770
  } else {
1759
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not HLS)'));
1771
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
1760
1772
  }
1761
1773
  });
1762
1774
  if (mediaFiles.length === 0) {
1763
1775
  if (isNoAdAvailable) {
1764
1776
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
1765
1777
  } else {
1766
- console.warn("[HlsAdPlayer] No HLS media files found in VAST XML");
1778
+ console.warn("[HlsAdPlayer] No supported media files found in VAST XML");
1767
1779
  }
1768
1780
  return null;
1769
1781
  }
@@ -2060,7 +2072,7 @@ function createHlsAdPlayer(contentVideo, options) {
2060
2072
  },
2061
2073
  play: function play() {
2062
2074
  return _async_to_generator(function() {
2063
- var contentVolume, adVolume, mediaFile;
2075
+ var contentVolume, adVolume, mediaFile, isHlsAd;
2064
2076
  return _ts_generator(this, function(_state) {
2065
2077
  if (!currentAd) {
2066
2078
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -2112,8 +2124,9 @@ function createHlsAdPlayer(contentVideo, options) {
2112
2124
  if (!mediaFile) {
2113
2125
  throw new Error("No media file available for ad");
2114
2126
  }
2115
- console.log("[HlsAdPlayer] Loading ad from: ".concat(mediaFile.url));
2116
- if (import_hls.default.isSupported()) {
2127
+ isHlsAd = isHlsMediaFile(mediaFile);
2128
+ console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad from: ").concat(mediaFile.url));
2129
+ if (isHlsAd && import_hls.default.isSupported()) {
2117
2130
  if (adHls) {
2118
2131
  adHls.destroy();
2119
2132
  }
@@ -2136,14 +2149,25 @@ function createHlsAdPlayer(contentVideo, options) {
2136
2149
  handleAdError();
2137
2150
  }
2138
2151
  });
2139
- } else if (adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
2152
+ } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
2140
2153
  adVideoElement.src = mediaFile.url;
2141
2154
  adVideoElement.play().catch(function(error) {
2142
2155
  console.error("[HlsAdPlayer] Error starting ad playback:", error);
2143
2156
  handleAdError();
2144
2157
  });
2158
+ } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
2159
+ if (adHls) {
2160
+ adHls.destroy();
2161
+ adHls = void 0;
2162
+ }
2163
+ adVideoElement.src = mediaFile.url;
2164
+ adVideoElement.load();
2165
+ adVideoElement.play().catch(function(error) {
2166
+ console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
2167
+ handleAdError();
2168
+ });
2145
2169
  } else {
2146
- throw new Error("HLS not supported");
2170
+ throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
2147
2171
  }
2148
2172
  return [
2149
2173
  2,