stormcloud-video-player 0.2.14 → 0.2.15
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/README.md +92 -11
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +51 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +51 -17
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +42 -15
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +42 -15
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +42 -15
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +27 -8
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +51 -17
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -917,7 +917,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
917
917
|
const xmlDoc = parser.parseFromString(xmlString, "text/xml");
|
|
918
918
|
const parserError = xmlDoc.querySelector("parsererror");
|
|
919
919
|
if (parserError) {
|
|
920
|
-
console.error("[HlsAdPlayer] XML parsing error:", parserError.textContent);
|
|
920
|
+
console.error("[HlsAdPlayer] XML parsing error (malformed VAST XML):", parserError.textContent);
|
|
921
921
|
return null;
|
|
922
922
|
}
|
|
923
923
|
const adElement = xmlDoc.querySelector("Ad");
|
|
@@ -927,28 +927,45 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
927
927
|
}
|
|
928
928
|
const adId = adElement.getAttribute("id") || "unknown";
|
|
929
929
|
const title = ((_a = xmlDoc.querySelector("AdTitle")) == null ? void 0 : _a.textContent) || "Ad";
|
|
930
|
+
const isNoAdAvailable = adId === "empty" || title.toLowerCase().includes("no ad available") || title.toLowerCase() === "no ad available";
|
|
930
931
|
const durationText = ((_b = xmlDoc.querySelector("Duration")) == null ? void 0 : _b.textContent) || "00:00:30";
|
|
931
932
|
const durationParts = durationText.split(":");
|
|
932
933
|
const duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
933
934
|
const mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
934
935
|
const mediaFiles = [];
|
|
935
|
-
mediaFileElements.
|
|
936
|
+
console.log(`[HlsAdPlayer] Found ${mediaFileElements.length} MediaFile element(s) in VAST XML`);
|
|
937
|
+
mediaFileElements.forEach((mf, index) => {
|
|
936
938
|
var _a2;
|
|
937
939
|
const type = mf.getAttribute("type") || "";
|
|
940
|
+
const url = ((_a2 = mf.textContent) == null ? void 0 : _a2.trim()) || "";
|
|
941
|
+
const width = mf.getAttribute("width") || "";
|
|
942
|
+
const height = mf.getAttribute("height") || "";
|
|
943
|
+
console.log(`[HlsAdPlayer] MediaFile ${index}: type="${type}", url="${url}", width="${width}", height="${height}"`);
|
|
938
944
|
if (type === "application/x-mpegURL" || type.includes("m3u8")) {
|
|
945
|
+
if (!url) {
|
|
946
|
+
console.warn(`[HlsAdPlayer] MediaFile ${index} has HLS type but empty URL`);
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
939
949
|
const bitrateAttr = mf.getAttribute("bitrate");
|
|
940
950
|
const bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
941
951
|
mediaFiles.push({
|
|
942
|
-
url
|
|
952
|
+
url,
|
|
943
953
|
type,
|
|
944
|
-
width: parseInt(
|
|
945
|
-
height: parseInt(
|
|
954
|
+
width: parseInt(width || "1920", 10),
|
|
955
|
+
height: parseInt(height || "1080", 10),
|
|
946
956
|
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
947
957
|
});
|
|
958
|
+
console.log(`[HlsAdPlayer] Added HLS MediaFile: ${url}`);
|
|
959
|
+
} else {
|
|
960
|
+
console.log(`[HlsAdPlayer] MediaFile ${index} ignored (type="${type}" is not HLS)`);
|
|
948
961
|
}
|
|
949
962
|
});
|
|
950
963
|
if (mediaFiles.length === 0) {
|
|
951
|
-
|
|
964
|
+
if (isNoAdAvailable) {
|
|
965
|
+
console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
|
|
966
|
+
} else {
|
|
967
|
+
console.warn("[HlsAdPlayer] No HLS media files found in VAST XML");
|
|
968
|
+
}
|
|
952
969
|
return null;
|
|
953
970
|
}
|
|
954
971
|
const trackingUrls = {
|
|
@@ -1136,9 +1153,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1136
1153
|
}
|
|
1137
1154
|
const vastXml = await response.text();
|
|
1138
1155
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1156
|
+
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1139
1157
|
const ad = parseVastXml(vastXml);
|
|
1140
1158
|
if (!ad) {
|
|
1141
|
-
|
|
1159
|
+
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
1160
|
+
return Promise.resolve();
|
|
1142
1161
|
}
|
|
1143
1162
|
currentAd = ad;
|
|
1144
1163
|
console.log(`[HlsAdPlayer] Ad parsed: ${ad.title}, duration: ${ad.duration}s`);
|
|
@@ -1153,7 +1172,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1153
1172
|
},
|
|
1154
1173
|
async play() {
|
|
1155
1174
|
if (!currentAd) {
|
|
1156
|
-
console.warn("[HlsAdPlayer] Cannot play: No ad loaded");
|
|
1175
|
+
console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
|
|
1157
1176
|
return Promise.reject(new Error("No ad loaded"));
|
|
1158
1177
|
}
|
|
1159
1178
|
console.log("[HlsAdPlayer] Starting ad playback");
|
|
@@ -2505,7 +2524,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2505
2524
|
this.apiVastTagUrl = vastEndpoint;
|
|
2506
2525
|
if (this.config.debugAdTiming) {
|
|
2507
2526
|
console.log(
|
|
2508
|
-
"[StormcloudVideoPlayer] Using AdStorm VAST endpoint:",
|
|
2527
|
+
"[StormcloudVideoPlayer] Using AdStorm VAST endpoint (adstorm mode):",
|
|
2509
2528
|
vastEndpoint
|
|
2510
2529
|
);
|
|
2511
2530
|
}
|
|
@@ -2761,12 +2780,20 @@ var StormcloudVideoPlayer = class {
|
|
|
2761
2780
|
this.startAdFailsafeTimer();
|
|
2762
2781
|
try {
|
|
2763
2782
|
await this.ima.requestAds(vastTagUrl);
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2783
|
+
try {
|
|
2784
|
+
if (this.config.debugAdTiming) {
|
|
2785
|
+
console.log("[StormcloudVideoPlayer] Ad request completed, attempting playback");
|
|
2786
|
+
}
|
|
2787
|
+
await this.ima.play();
|
|
2788
|
+
if (this.config.debugAdTiming) {
|
|
2789
|
+
console.log("[StormcloudVideoPlayer] Ad playback started successfully");
|
|
2790
|
+
}
|
|
2791
|
+
} catch (playError) {
|
|
2792
|
+
if (this.config.debugAdTiming) {
|
|
2793
|
+
console.log("[StormcloudVideoPlayer] No ads available, skipping playback");
|
|
2794
|
+
}
|
|
2795
|
+
this.handleAdFailure();
|
|
2796
|
+
return;
|
|
2770
2797
|
}
|
|
2771
2798
|
} catch (error) {
|
|
2772
2799
|
if (this.config.debugAdTiming) {
|
|
@@ -2983,7 +3010,8 @@ var CRITICAL_PROPS = [
|
|
|
2983
3010
|
"allowNativeHls",
|
|
2984
3011
|
"licenseKey",
|
|
2985
3012
|
"lowLatencyMode",
|
|
2986
|
-
"driftToleranceMs"
|
|
3013
|
+
"driftToleranceMs",
|
|
3014
|
+
"vastMode"
|
|
2987
3015
|
];
|
|
2988
3016
|
var StormcloudVideoPlayerComponent = import_react.default.memo(
|
|
2989
3017
|
(props) => {
|
|
@@ -3011,6 +3039,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(
|
|
|
3011
3039
|
poster,
|
|
3012
3040
|
children,
|
|
3013
3041
|
licenseKey,
|
|
3042
|
+
vastMode,
|
|
3043
|
+
vastTagUrl,
|
|
3044
|
+
adPlayerType,
|
|
3014
3045
|
...restVideoAttrs
|
|
3015
3046
|
} = props;
|
|
3016
3047
|
const videoRef = (0, import_react.useRef)(null);
|
|
@@ -3082,7 +3113,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(
|
|
|
3082
3113
|
const shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
|
|
3083
3114
|
const criticalPropsKey = (0, import_react.useMemo)(() => {
|
|
3084
3115
|
return CRITICAL_PROPS.map((prop) => `${prop}:${props[prop]}`).join("|");
|
|
3085
|
-
}, [src, allowNativeHls, licenseKey, lowLatencyMode, driftToleranceMs]);
|
|
3116
|
+
}, [src, allowNativeHls, licenseKey, lowLatencyMode, driftToleranceMs, vastMode]);
|
|
3086
3117
|
(0, import_react.useEffect)(() => {
|
|
3087
3118
|
if (typeof window === "undefined") return;
|
|
3088
3119
|
const el = videoRef.current;
|
|
@@ -3123,6 +3154,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(
|
|
|
3123
3154
|
cfg.onFullscreenToggle = onFullscreenToggle;
|
|
3124
3155
|
if (onControlClick !== void 0) cfg.onControlClick = onControlClick;
|
|
3125
3156
|
if (licenseKey !== void 0) cfg.licenseKey = licenseKey;
|
|
3157
|
+
if (vastMode !== void 0) cfg.vastMode = vastMode;
|
|
3158
|
+
if (vastTagUrl !== void 0) cfg.vastTagUrl = vastTagUrl;
|
|
3159
|
+
if (adPlayerType !== void 0) cfg.adPlayerType = adPlayerType;
|
|
3126
3160
|
const player = new StormcloudVideoPlayer(cfg);
|
|
3127
3161
|
playerRef.current = player;
|
|
3128
3162
|
player.load().then(() => {
|