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,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { S as StormcloudVideoPlayerConfig } from '../types-iDjS8f_7.cjs';
2
+ import { a as StormcloudVideoPlayerConfig } from '../types-cTqIKw_D.cjs';
3
3
 
4
4
  interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
5
5
  onMount?: (player: any) => void;
@@ -447,6 +447,7 @@ function createHlsAdPlayer(contentVideo, options) {
447
447
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
448
448
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
449
449
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
450
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
450
451
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
451
452
  var adHls;
452
453
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -466,6 +467,7 @@ function createHlsAdPlayer(contentVideo, options) {
466
467
  var lastAdProgressTime = 0;
467
468
  var lastAdProgressPosition = 0;
468
469
  var sawDecodedVideoFrame = false;
470
+ var videoFrameCallbackHandle;
469
471
  var trackingFired = {
470
472
  impression: false,
471
473
  start: false,
@@ -1352,6 +1354,7 @@ function createHlsAdPlayer(contentVideo, options) {
1352
1354
  clearInterval(stallWatchdogId);
1353
1355
  stallWatchdogId = void 0;
1354
1356
  }
1357
+ cancelVideoFrameProbe();
1355
1358
  }
1356
1359
  function noteAdProgress() {
1357
1360
  lastAdProgressTime = Date.now();
@@ -1387,6 +1390,39 @@ function createHlsAdPlayer(contentVideo, options) {
1387
1390
  }
1388
1391
  return void 0;
1389
1392
  }
1393
+ function isFrameCounterReliable() {
1394
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1395
+ }
1396
+ function markFrameCounterReliable() {
1397
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1398
+ }
1399
+ function cancelVideoFrameProbe() {
1400
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1401
+ try {
1402
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1403
+ } catch (error) {
1404
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1405
+ }
1406
+ }
1407
+ videoFrameCallbackHandle = void 0;
1408
+ }
1409
+ function startVideoFrameProbe() {
1410
+ cancelVideoFrameProbe();
1411
+ if (!adVideoElement) return;
1412
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1413
+ if (typeof rvfc !== "function") return;
1414
+ var onPresentedFrame = function onPresentedFrame() {
1415
+ videoFrameCallbackHandle = void 0;
1416
+ if (!adPlaying) return;
1417
+ sawDecodedVideoFrame = true;
1418
+ };
1419
+ try {
1420
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1421
+ } catch (error) {
1422
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1423
+ videoFrameCallbackHandle = void 0;
1424
+ }
1425
+ }
1390
1426
  function handleVideoDecodeFailure() {
1391
1427
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1392
1428
  clearStallWatchdog();
@@ -1402,6 +1438,7 @@ function createHlsAdPlayer(contentVideo, options) {
1402
1438
  clearStallWatchdog();
1403
1439
  noteAdProgress();
1404
1440
  sawDecodedVideoFrame = false;
1441
+ startVideoFrameProbe();
1405
1442
  stallWatchdogId = window.setInterval(function() {
1406
1443
  if (!adPlaying || !adVideoElement) {
1407
1444
  return;
@@ -1410,7 +1447,8 @@ function createHlsAdPlayer(contentVideo, options) {
1410
1447
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1411
1448
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1412
1449
  sawDecodedVideoFrame = true;
1413
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1450
+ markFrameCounterReliable();
1451
+ } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S && isFrameCounterReliable()) {
1414
1452
  handleVideoDecodeFailure();
1415
1453
  return;
1416
1454
  }
@@ -6255,17 +6293,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6255
6293
  {
6256
6294
  key: "logAdState",
6257
6295
  value: function logAdState(event) {
6258
- 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;
6259
- var _ref;
6296
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6260
6297
  if (!this.debug) {
6261
6298
  return;
6262
6299
  }
6300
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6263
6301
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6264
6302
  event: event,
6265
6303
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6266
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6267
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6268
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6304
+ showAds: showAds,
6305
+ adPlaying: adPlaying,
6306
+ inAdBreak: inAdBreak,
6269
6307
  activeAdRequestToken: this.activeAdRequestToken
6270
6308
  }, extra));
6271
6309
  }
@@ -8615,6 +8653,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8615
8653
  },
8616
8654
  onFailsafeTimeout: function onFailsafeTimeout() {
8617
8655
  return _this.adBreak.handleAdFailure();
8656
+ },
8657
+ getAdState: function getAdState() {
8658
+ return {
8659
+ inAdBreak: _this.adBreak.inAdBreak,
8660
+ showAds: _this.adBreak.showAds,
8661
+ adPlaying: _this.adPlayer.isAdPlaying()
8662
+ };
8618
8663
  }
8619
8664
  });
8620
8665
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);