@xiboplayer/renderer 0.7.5 → 0.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiboplayer/renderer",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "RendererLite - Fast, efficient XLF layout rendering engine",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -12,9 +12,9 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "pdfjs-dist": "^4.10.38",
15
- "@xiboplayer/cache": "0.7.5",
16
- "@xiboplayer/schedule": "0.7.5",
17
- "@xiboplayer/utils": "0.7.5"
15
+ "@xiboplayer/cache": "0.7.6",
16
+ "@xiboplayer/utils": "0.7.6",
17
+ "@xiboplayer/schedule": "0.7.6"
18
18
  },
19
19
  "devDependencies": {
20
20
  "jsdom": "^25.0.1",
@@ -714,6 +714,7 @@ export class RendererLite {
714
714
  if (maxRegionDuration > 0 && maxRegionDuration !== this.currentLayout.duration) {
715
715
  const oldDuration = this.currentLayout.duration;
716
716
  this.currentLayout.duration = maxRegionDuration;
717
+ this.currentLayout._durationFromMetadata = true;
717
718
 
718
719
  this.log.info(`Layout duration updated: ${oldDuration}s → ${maxRegionDuration}s (based on video metadata)`);
719
720
  const final_ = !this._hasUnprobedVideos();
@@ -1639,7 +1640,9 @@ export class RendererLite {
1639
1640
  // Dynamic layouts (useDuration=0 videos): defer timer until video metadata
1640
1641
  // provides real durations. Safety timeout ensures corrupt/missing videos
1641
1642
  // don't freeze the display forever.
1642
- if (layout.isDynamic && this._hasUnprobedVideos()) {
1643
+ // Skip deferral if updateLayoutDuration() already set the duration from
1644
+ // video metadata (e.g. during preload or a previous play of this layout).
1645
+ if (layout.isDynamic && !layout._durationFromMetadata && this._hasUnprobedVideos()) {
1643
1646
  this._deferredTimerLayoutId = layoutId;
1644
1647
  this._layoutTimerStartedAt = Date.now();
1645
1648
  this.log.info(`Layout ${layoutId} has unprobed videos — deferring timer until metadata loads`);
@@ -1662,14 +1665,30 @@ export class RendererLite {
1662
1665
  }
1663
1666
 
1664
1667
  /**
1665
- * Check if any video widget has useDuration=0 ("play to end") and hasn't
1666
- * been corrected by video metadata yet. The XLF always provides a non-zero
1667
- * duration attribute (typically 60s), so we check the _probed flag instead.
1668
+ * Check if any region's longest-running video widget (useDuration=0) hasn't
1669
+ * been probed yet. Used to decide whether to defer the layout timer.
1670
+ *
1671
+ * Only checks widgets that have had <video> elements created (during preload
1672
+ * or show). Widgets that haven't been displayed yet can never be probed —
1673
+ * checking them would always force a 30s timeout on layouts with multiple
1674
+ * video widgets per region.
1675
+ *
1676
+ * Returns false if the layout duration has already been updated from video
1677
+ * metadata (meaning at least one probe succeeded and updateLayoutDuration
1678
+ * computed a real duration), since the timer can start with that value.
1668
1679
  */
1669
1680
  _hasUnprobedVideos() {
1681
+ // If any video was probed and updateLayoutDuration ran, the layout duration
1682
+ // is already based on real metadata — no need to defer further.
1683
+ for (const [, region] of this.regions) {
1684
+ for (const widget of region.widgets) {
1685
+ if (widget.type === 'video' && widget.useDuration === 0 && widget._probed) return false;
1686
+ }
1687
+ }
1688
+ // No videos probed at all — check if there are any that need probing
1670
1689
  for (const [, region] of this.regions) {
1671
1690
  for (const widget of region.widgets) {
1672
- if (widget.useDuration === 0 && !widget._probed) return true;
1691
+ if (widget.type === 'video' && widget.useDuration === 0) return true;
1673
1692
  }
1674
1693
  }
1675
1694
  return false;