eb-player 2.0.8 → 2.0.9

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.
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.EBPlayer = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- var __EB_PLAYER_VERSION__ = "2.0.7";
7
+ var __EB_PLAYER_VERSION__ = "2.0.9";
8
8
 
9
9
  /**
10
10
  * Finite State Machine for player playback state transitions.
@@ -5244,7 +5244,9 @@
5244
5244
  if (!hlsjsUrl) {
5245
5245
  throw new Error('HlsEngine: config.hlsjs URL is required');
5246
5246
  }
5247
- // Create token manager if a token URL is configured
5247
+ // Create token manager if a token URL is configured.
5248
+ // No initial fetchToken() here — updateUrlWithTokenParams() below handles it
5249
+ // and populates lastTokenResponse (used lazily by DRM licenseXhrSetup).
5248
5250
  if (config.token) {
5249
5251
  this.tokenManager = new CDNTokenManager({
5250
5252
  token: config.token,
@@ -5253,13 +5255,6 @@
5253
5255
  extraParamsCallback: (config.engineSettings.extraParamsCallback ?? config.extraParamsCallback),
5254
5256
  onCDNTokenError: config.engineSettings.onCDNTokenError
5255
5257
  });
5256
- // Fetch initial token
5257
- if (config.src) {
5258
- await this.tokenManager.fetchToken({ src: config.src });
5259
- }
5260
- // Guard: abort if detached during token fetch
5261
- if (this.detached)
5262
- return;
5263
5258
  }
5264
5259
  // console.info('HlsEngine: loading hls.js from', hlsjsUrl)
5265
5260
  const Hls = await loadScript(hlsjsUrl, 'Hls');
@@ -5342,7 +5337,6 @@
5342
5337
  // Create the driver (NEVER stored in state)
5343
5338
  const driver = new Hls(driverConfig);
5344
5339
  this.driver = driver;
5345
- this.resolveDriverReady();
5346
5340
  // Pitfall 4: apply discontinuity workaround BEFORE attachMedia/loadSource
5347
5341
  applyDiscontinuityWorkaround(driver, Hls.Events);
5348
5342
  // Wire retry handler
@@ -5365,8 +5359,27 @@
5365
5359
  }
5366
5360
  }
5367
5361
  driver.loadSource(src);
5362
+ // Resolve driverReady AFTER loadSource so consumers (P2P, snapshot handler)
5363
+ // don't start making token requests before the main engine's initial token
5364
+ // fetch completes and populates the cache.
5365
+ this.resolveDriverReady();
5368
5366
  // Register driver event handlers
5369
5367
  this.registerDriverEvents(Hls, state);
5368
+ // Pause/resume loading on video pause/play to stop manifest refreshes
5369
+ // (and thus CDN token requests) while the player is paused.
5370
+ // Only applies to live streams where hls.js continuously refreshes the manifest.
5371
+ const driverRef = driver;
5372
+ video.addEventListener('pause', () => {
5373
+ if (this.state?.isLive) {
5374
+ driverRef.stopLoad();
5375
+ }
5376
+ }, { signal });
5377
+ video.addEventListener('play', () => {
5378
+ if (this.state?.isLive) {
5379
+ // Defer startLoad to avoid re-entrancy (Pitfall 3)
5380
+ setTimeout(() => driverRef.startLoad(-1), 0);
5381
+ }
5382
+ }, { signal });
5370
5383
  // Start stall watchdog
5371
5384
  this.startWatchdog();
5372
5385
  }