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 { S as StormcloudVideoPlayerConfig } from '../types-iDjS8f_7.cjs';
1
+ import { a as StormcloudVideoPlayerConfig } from '../types-cTqIKw_D.cjs';
2
2
 
3
3
  declare class StormcloudVideoPlayer {
4
4
  private readonly video;
@@ -1,4 +1,4 @@
1
- import { a as Scte35Marker } from '../types-iDjS8f_7.cjs';
1
+ import { S as Scte35Marker } from '../types-cTqIKw_D.cjs';
2
2
 
3
3
  type Scte35CueSource = "manifest" | "id3" | "ts";
4
4
  type Scte35CueReadiness = "early" | "playback";
@@ -411,6 +411,7 @@ function createHlsAdPlayer(contentVideo, options) {
411
411
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
412
412
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
413
413
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
414
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
414
415
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
415
416
  var adHls;
416
417
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -430,6 +431,7 @@ function createHlsAdPlayer(contentVideo, options) {
430
431
  var lastAdProgressTime = 0;
431
432
  var lastAdProgressPosition = 0;
432
433
  var sawDecodedVideoFrame = false;
434
+ var videoFrameCallbackHandle;
433
435
  var trackingFired = {
434
436
  impression: false,
435
437
  start: false,
@@ -1316,6 +1318,7 @@ function createHlsAdPlayer(contentVideo, options) {
1316
1318
  clearInterval(stallWatchdogId);
1317
1319
  stallWatchdogId = void 0;
1318
1320
  }
1321
+ cancelVideoFrameProbe();
1319
1322
  }
1320
1323
  function noteAdProgress() {
1321
1324
  lastAdProgressTime = Date.now();
@@ -1351,6 +1354,39 @@ function createHlsAdPlayer(contentVideo, options) {
1351
1354
  }
1352
1355
  return void 0;
1353
1356
  }
1357
+ function isFrameCounterReliable() {
1358
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1359
+ }
1360
+ function markFrameCounterReliable() {
1361
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1362
+ }
1363
+ function cancelVideoFrameProbe() {
1364
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1365
+ try {
1366
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1367
+ } catch (error) {
1368
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1369
+ }
1370
+ }
1371
+ videoFrameCallbackHandle = void 0;
1372
+ }
1373
+ function startVideoFrameProbe() {
1374
+ cancelVideoFrameProbe();
1375
+ if (!adVideoElement) return;
1376
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1377
+ if (typeof rvfc !== "function") return;
1378
+ var onPresentedFrame = function onPresentedFrame() {
1379
+ videoFrameCallbackHandle = void 0;
1380
+ if (!adPlaying) return;
1381
+ sawDecodedVideoFrame = true;
1382
+ };
1383
+ try {
1384
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1385
+ } catch (error) {
1386
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1387
+ videoFrameCallbackHandle = void 0;
1388
+ }
1389
+ }
1354
1390
  function handleVideoDecodeFailure() {
1355
1391
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1356
1392
  clearStallWatchdog();
@@ -1366,6 +1402,7 @@ function createHlsAdPlayer(contentVideo, options) {
1366
1402
  clearStallWatchdog();
1367
1403
  noteAdProgress();
1368
1404
  sawDecodedVideoFrame = false;
1405
+ startVideoFrameProbe();
1369
1406
  stallWatchdogId = window.setInterval(function() {
1370
1407
  if (!adPlaying || !adVideoElement) {
1371
1408
  return;
@@ -1374,7 +1411,8 @@ function createHlsAdPlayer(contentVideo, options) {
1374
1411
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1375
1412
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1376
1413
  sawDecodedVideoFrame = true;
1377
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1414
+ markFrameCounterReliable();
1415
+ } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S && isFrameCounterReliable()) {
1378
1416
  handleVideoDecodeFailure();
1379
1417
  return;
1380
1418
  }
@@ -6219,17 +6257,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6219
6257
  {
6220
6258
  key: "logAdState",
6221
6259
  value: function logAdState(event) {
6222
- 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;
6223
- var _ref;
6260
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6224
6261
  if (!this.debug) {
6225
6262
  return;
6226
6263
  }
6264
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6227
6265
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6228
6266
  event: event,
6229
6267
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6230
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6231
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6232
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6268
+ showAds: showAds,
6269
+ adPlaying: adPlaying,
6270
+ inAdBreak: inAdBreak,
6233
6271
  activeAdRequestToken: this.activeAdRequestToken
6234
6272
  }, extra));
6235
6273
  }
@@ -8579,6 +8617,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8579
8617
  },
8580
8618
  onFailsafeTimeout: function onFailsafeTimeout() {
8581
8619
  return _this.adBreak.handleAdFailure();
8620
+ },
8621
+ getAdState: function getAdState() {
8622
+ return {
8623
+ inAdBreak: _this.adBreak.inAdBreak,
8624
+ showAds: _this.adBreak.showAds,
8625
+ adPlaying: _this.adPlayer.isAdPlaying()
8626
+ };
8582
8627
  }
8583
8628
  });
8584
8629
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);