eb-player 2.0.0 → 2.0.1

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.
@@ -1347,7 +1347,6 @@
1347
1347
  if (this.snapshotTake !== null) {
1348
1348
  this.snapshotTake(this.tooltipTime);
1349
1349
  }
1350
- // Preview video element is set via 'snapshot-handler-ready' event — no creation needed here
1351
1350
  this.render();
1352
1351
  }
1353
1352
  // ---- Chapter helpers ----
@@ -5725,6 +5724,10 @@
5725
5724
  /**
5726
5725
  * Initialize the snapshot Hls instance using the CDN-loaded Hls constructor.
5727
5726
  * Creates a separate Hls instance with minimal buffering for thumbnail generation.
5727
+ *
5728
+ * Returns a promise that resolves once the manifest is loaded and the snapshot
5729
+ * handler is ready to serve seek thumbnails — matching the legacy Vue 2 behaviour
5730
+ * where the handler only resolved after MANIFEST_LOADED.
5728
5731
  */
5729
5732
  init(HlsConstructor) {
5730
5733
  // Create an off-screen video element for the snapshot player
@@ -5775,6 +5778,16 @@
5775
5778
  if (this.config.src) {
5776
5779
  driver.loadSource(this.config.src);
5777
5780
  }
5781
+ // Wait for the manifest to load before resolving — the snapshot handler is only
5782
+ // useful once hls.js knows about the available levels and can seek to segments.
5783
+ // This matches the legacy Vue 2 code which resolved after MANIFEST_LOADED and
5784
+ // forced loadLevel = 0 to pin the lowest quality for thumbnails.
5785
+ return new Promise((resolve) => {
5786
+ driver.once(HlsConstructor.Events.MANIFEST_LOADED, () => {
5787
+ driver['loadLevel'] = 0;
5788
+ resolve();
5789
+ });
5790
+ });
5778
5791
  }
5779
5792
  /**
5780
5793
  * Seek the snapshot player to the specified time.
@@ -6066,8 +6079,8 @@
6066
6079
  activeSnapshotDestroy = null;
6067
6080
  }
6068
6081
  const isDash = src.includes('.mpd') && mergedConfig.dashjs !== false;
6069
- // Defer init until CDN script is loaded (engine's onAttach loads CDN script async)
6070
- setTimeout(() => {
6082
+ // Wait for engine driver to be ready (CDN script loaded) before initializing snapshot
6083
+ engine.driverReady.then(() => {
6071
6084
  if (isDash) {
6072
6085
  const win = window;
6073
6086
  if (win.dashjs) {
@@ -6086,15 +6099,25 @@
6086
6099
  const win = window;
6087
6100
  if (win.Hls) {
6088
6101
  const handler = new HlsSnapshotHandler({ src, engineSettings: mergedConfig.engineSettings }, null);
6089
- handler.init(win.Hls);
6090
- activeSnapshotDestroy = () => handler.destroy();
6091
- const snapshotVideo = handler.getVideo();
6092
- if (snapshotVideo !== null) {
6093
- controller.bus.emit('snapshot-handler-ready', { take: (time) => handler.take(time), video: snapshotVideo });
6094
- }
6102
+ handler.init(win.Hls)
6103
+ .then(() => {
6104
+ activeSnapshotDestroy = () => handler.destroy();
6105
+ const snapshotVideo = handler.getVideo();
6106
+ if (snapshotVideo !== null) {
6107
+ controller.bus.emit('snapshot-handler-ready', { take: (time) => handler.take(time), video: snapshotVideo });
6108
+ }
6109
+ })
6110
+ .catch((error) => {
6111
+ console.warn('EBPlayer: HlsSnapshotHandler init failed:', error);
6112
+ });
6113
+ }
6114
+ else {
6115
+ console.warn('EBPlayer: window.Hls not available after driverReady — snapshot preview disabled');
6095
6116
  }
6096
6117
  }
6097
- }, 500);
6118
+ }).catch((error) => {
6119
+ console.warn('EBPlayer: Snapshot handler init failed:', error);
6120
+ });
6098
6121
  }
6099
6122
  },
6100
6123
  close() {