stormcloud-video-player 0.8.49 → 0.8.50

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.
@@ -209,6 +209,7 @@ function createHlsAdPlayer(contentVideo, options) {
209
209
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
210
210
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
211
211
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
212
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
212
213
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
213
214
  var adHls;
214
215
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -228,6 +229,7 @@ function createHlsAdPlayer(contentVideo, options) {
228
229
  var lastAdProgressTime = 0;
229
230
  var lastAdProgressPosition = 0;
230
231
  var sawDecodedVideoFrame = false;
232
+ var videoFrameCallbackHandle;
231
233
  var trackingFired = {
232
234
  impression: false,
233
235
  start: false,
@@ -1114,6 +1116,7 @@ function createHlsAdPlayer(contentVideo, options) {
1114
1116
  clearInterval(stallWatchdogId);
1115
1117
  stallWatchdogId = void 0;
1116
1118
  }
1119
+ cancelVideoFrameProbe();
1117
1120
  }
1118
1121
  function noteAdProgress() {
1119
1122
  lastAdProgressTime = Date.now();
@@ -1149,6 +1152,39 @@ function createHlsAdPlayer(contentVideo, options) {
1149
1152
  }
1150
1153
  return void 0;
1151
1154
  }
1155
+ function isFrameCounterReliable() {
1156
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1157
+ }
1158
+ function markFrameCounterReliable() {
1159
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1160
+ }
1161
+ function cancelVideoFrameProbe() {
1162
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1163
+ try {
1164
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1165
+ } catch (error) {
1166
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1167
+ }
1168
+ }
1169
+ videoFrameCallbackHandle = void 0;
1170
+ }
1171
+ function startVideoFrameProbe() {
1172
+ cancelVideoFrameProbe();
1173
+ if (!adVideoElement) return;
1174
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1175
+ if (typeof rvfc !== "function") return;
1176
+ var onPresentedFrame = function onPresentedFrame() {
1177
+ videoFrameCallbackHandle = void 0;
1178
+ if (!adPlaying) return;
1179
+ sawDecodedVideoFrame = true;
1180
+ };
1181
+ try {
1182
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1183
+ } catch (error) {
1184
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1185
+ videoFrameCallbackHandle = void 0;
1186
+ }
1187
+ }
1152
1188
  function handleVideoDecodeFailure() {
1153
1189
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1154
1190
  clearStallWatchdog();
@@ -1164,6 +1200,7 @@ function createHlsAdPlayer(contentVideo, options) {
1164
1200
  clearStallWatchdog();
1165
1201
  noteAdProgress();
1166
1202
  sawDecodedVideoFrame = false;
1203
+ startVideoFrameProbe();
1167
1204
  stallWatchdogId = window.setInterval(function() {
1168
1205
  if (!adPlaying || !adVideoElement) {
1169
1206
  return;
@@ -1172,7 +1209,8 @@ function createHlsAdPlayer(contentVideo, options) {
1172
1209
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1173
1210
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1174
1211
  sawDecodedVideoFrame = true;
1175
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1212
+ markFrameCounterReliable();
1213
+ } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S && isFrameCounterReliable()) {
1176
1214
  handleVideoDecodeFailure();
1177
1215
  return;
1178
1216
  }