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.
@@ -1797,6 +1797,16 @@ function createHlsAdPlayer(contentVideo, options) {
1797
1797
  });
1798
1798
  return bestMatch.file;
1799
1799
  }
1800
+ function isHlsMediaFile(mediaFile) {
1801
+ var type = mediaFile.type.toLowerCase();
1802
+ var url = mediaFile.url.toLowerCase();
1803
+ return type === "application/x-mpegurl" || type === "application/vnd.apple.mpegurl" || type.includes("mpegurl") || url.includes(".m3u8");
1804
+ }
1805
+ function isProgressiveMediaFile(mediaFile) {
1806
+ var type = mediaFile.type.toLowerCase();
1807
+ var url = mediaFile.url.toLowerCase();
1808
+ return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
1809
+ }
1800
1810
  function parseVastXml(xmlString) {
1801
1811
  try {
1802
1812
  var _xmlDoc_querySelector, _xmlDoc_querySelector1, _xmlDoc_querySelector_textContent, _xmlDoc_querySelector2;
@@ -1828,30 +1838,32 @@ function createHlsAdPlayer(contentVideo, options) {
1828
1838
  var width = mf.getAttribute("width") || "";
1829
1839
  var height = mf.getAttribute("height") || "";
1830
1840
  console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
1831
- if (type === "application/x-mpegURL" || type.includes("m3u8")) {
1832
- if (!url) {
1833
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has HLS type but empty URL"));
1834
- return;
1835
- }
1836
- var bitrateAttr = mf.getAttribute("bitrate");
1837
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
1838
- mediaFiles.push({
1839
- url: url,
1840
- type: type,
1841
- width: parseInt(width || "1920", 10),
1842
- height: parseInt(height || "1080", 10),
1843
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
1844
- });
1845
- console.log("[HlsAdPlayer] Added HLS MediaFile: ".concat(url));
1841
+ var mediaFile = {
1842
+ url: url,
1843
+ type: type,
1844
+ width: parseInt(width || "1920", 10),
1845
+ height: parseInt(height || "1080", 10),
1846
+ bitrate: void 0
1847
+ };
1848
+ if (!url) {
1849
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
1850
+ return;
1851
+ }
1852
+ var bitrateAttr = mf.getAttribute("bitrate");
1853
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
1854
+ mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
1855
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
1856
+ mediaFiles.push(mediaFile);
1857
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
1846
1858
  } else {
1847
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not HLS)'));
1859
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
1848
1860
  }
1849
1861
  });
1850
1862
  if (mediaFiles.length === 0) {
1851
1863
  if (isNoAdAvailable) {
1852
1864
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
1853
1865
  } else {
1854
- console.warn("[HlsAdPlayer] No HLS media files found in VAST XML");
1866
+ console.warn("[HlsAdPlayer] No supported media files found in VAST XML");
1855
1867
  }
1856
1868
  return null;
1857
1869
  }
@@ -2148,7 +2160,7 @@ function createHlsAdPlayer(contentVideo, options) {
2148
2160
  },
2149
2161
  play: function play() {
2150
2162
  return _async_to_generator(function() {
2151
- var contentVolume, adVolume, mediaFile;
2163
+ var contentVolume, adVolume, mediaFile, isHlsAd;
2152
2164
  return _ts_generator(this, function(_state) {
2153
2165
  if (!currentAd) {
2154
2166
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -2200,8 +2212,9 @@ function createHlsAdPlayer(contentVideo, options) {
2200
2212
  if (!mediaFile) {
2201
2213
  throw new Error("No media file available for ad");
2202
2214
  }
2203
- console.log("[HlsAdPlayer] Loading ad from: ".concat(mediaFile.url));
2204
- if (import_hls.default.isSupported()) {
2215
+ isHlsAd = isHlsMediaFile(mediaFile);
2216
+ console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad from: ").concat(mediaFile.url));
2217
+ if (isHlsAd && import_hls.default.isSupported()) {
2205
2218
  if (adHls) {
2206
2219
  adHls.destroy();
2207
2220
  }
@@ -2224,14 +2237,25 @@ function createHlsAdPlayer(contentVideo, options) {
2224
2237
  handleAdError();
2225
2238
  }
2226
2239
  });
2227
- } else if (adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
2240
+ } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
2228
2241
  adVideoElement.src = mediaFile.url;
2229
2242
  adVideoElement.play().catch(function(error) {
2230
2243
  console.error("[HlsAdPlayer] Error starting ad playback:", error);
2231
2244
  handleAdError();
2232
2245
  });
2246
+ } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
2247
+ if (adHls) {
2248
+ adHls.destroy();
2249
+ adHls = void 0;
2250
+ }
2251
+ adVideoElement.src = mediaFile.url;
2252
+ adVideoElement.load();
2253
+ adVideoElement.play().catch(function(error) {
2254
+ console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
2255
+ handleAdError();
2256
+ });
2233
2257
  } else {
2234
- throw new Error("HLS not supported");
2258
+ throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
2235
2259
  }
2236
2260
  return [
2237
2261
  2,