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.
@@ -1,4 +1,4 @@
1
- import { A as AdController } from '../types-iDjS8f_7.cjs';
1
+ import { A as AdController } from '../types-cTqIKw_D.cjs';
2
2
  import Hls from 'hls.js';
3
3
 
4
4
  declare function createHlsAdPlayer(contentVideo: HTMLVideoElement, options?: {
@@ -397,6 +397,7 @@ function createHlsAdPlayer(contentVideo, options) {
397
397
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
398
398
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
399
399
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
400
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
400
401
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
401
402
  var adHls;
402
403
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -416,6 +417,7 @@ function createHlsAdPlayer(contentVideo, options) {
416
417
  var lastAdProgressTime = 0;
417
418
  var lastAdProgressPosition = 0;
418
419
  var sawDecodedVideoFrame = false;
420
+ var videoFrameCallbackHandle;
419
421
  var trackingFired = {
420
422
  impression: false,
421
423
  start: false,
@@ -1302,6 +1304,7 @@ function createHlsAdPlayer(contentVideo, options) {
1302
1304
  clearInterval(stallWatchdogId);
1303
1305
  stallWatchdogId = void 0;
1304
1306
  }
1307
+ cancelVideoFrameProbe();
1305
1308
  }
1306
1309
  function noteAdProgress() {
1307
1310
  lastAdProgressTime = Date.now();
@@ -1337,6 +1340,39 @@ function createHlsAdPlayer(contentVideo, options) {
1337
1340
  }
1338
1341
  return void 0;
1339
1342
  }
1343
+ function isFrameCounterReliable() {
1344
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1345
+ }
1346
+ function markFrameCounterReliable() {
1347
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1348
+ }
1349
+ function cancelVideoFrameProbe() {
1350
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1351
+ try {
1352
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1353
+ } catch (error) {
1354
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1355
+ }
1356
+ }
1357
+ videoFrameCallbackHandle = void 0;
1358
+ }
1359
+ function startVideoFrameProbe() {
1360
+ cancelVideoFrameProbe();
1361
+ if (!adVideoElement) return;
1362
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1363
+ if (typeof rvfc !== "function") return;
1364
+ var onPresentedFrame = function onPresentedFrame() {
1365
+ videoFrameCallbackHandle = void 0;
1366
+ if (!adPlaying) return;
1367
+ sawDecodedVideoFrame = true;
1368
+ };
1369
+ try {
1370
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1371
+ } catch (error) {
1372
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1373
+ videoFrameCallbackHandle = void 0;
1374
+ }
1375
+ }
1340
1376
  function handleVideoDecodeFailure() {
1341
1377
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1342
1378
  clearStallWatchdog();
@@ -1352,6 +1388,7 @@ function createHlsAdPlayer(contentVideo, options) {
1352
1388
  clearStallWatchdog();
1353
1389
  noteAdProgress();
1354
1390
  sawDecodedVideoFrame = false;
1391
+ startVideoFrameProbe();
1355
1392
  stallWatchdogId = window.setInterval(function() {
1356
1393
  if (!adPlaying || !adVideoElement) {
1357
1394
  return;
@@ -1360,7 +1397,8 @@ function createHlsAdPlayer(contentVideo, options) {
1360
1397
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1361
1398
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1362
1399
  sawDecodedVideoFrame = true;
1363
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1400
+ markFrameCounterReliable();
1401
+ } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S && isFrameCounterReliable()) {
1364
1402
  handleVideoDecodeFailure();
1365
1403
  return;
1366
1404
  }
@@ -6205,17 +6243,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6205
6243
  {
6206
6244
  key: "logAdState",
6207
6245
  value: function logAdState(event) {
6208
- var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, adPlayer = arguments.length > 2 ? arguments[2] : void 0, inAdBreak = arguments.length > 3 ? arguments[3] : void 0, showAds = arguments.length > 4 ? arguments[4] : void 0;
6209
- var _ref;
6246
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6210
6247
  if (!this.debug) {
6211
6248
  return;
6212
6249
  }
6250
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6213
6251
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6214
6252
  event: event,
6215
6253
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6216
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6217
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6218
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6254
+ showAds: showAds,
6255
+ adPlaying: adPlaying,
6256
+ inAdBreak: inAdBreak,
6219
6257
  activeAdRequestToken: this.activeAdRequestToken
6220
6258
  }, extra));
6221
6259
  }
@@ -8565,6 +8603,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8565
8603
  },
8566
8604
  onFailsafeTimeout: function onFailsafeTimeout() {
8567
8605
  return _this.adBreak.handleAdFailure();
8606
+ },
8607
+ getAdState: function getAdState() {
8608
+ return {
8609
+ inAdBreak: _this.adBreak.inAdBreak,
8610
+ showAds: _this.adBreak.showAds,
8611
+ adPlaying: _this.adPlayer.isAdPlaying()
8612
+ };
8568
8613
  }
8569
8614
  });
8570
8615
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);