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.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +46 -22
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +46 -22
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +46 -22
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +46 -22
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +46 -22
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +46 -22
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +46 -22
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -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
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
2204
|
-
|
|
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("
|
|
2258
|
+
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2235
2259
|
}
|
|
2236
2260
|
return [
|
|
2237
2261
|
2,
|