hls.js 1.6.3-0.canary.11262 → 1.6.3

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/dist/hls.mjs CHANGED
@@ -523,7 +523,7 @@ function enableLogs(debugConfig, context, id) {
523
523
  // Some browsers don't allow to use bind on console object anyway
524
524
  // fallback to default if needed
525
525
  try {
526
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3-0.canary.11262"}`);
526
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3"}`);
527
527
  } catch (e) {
528
528
  /* log fn threw an exception. All logger methods are no-ops. */
529
529
  return createLogger();
@@ -10234,7 +10234,7 @@ function requireEventemitter3 () {
10234
10234
  var eventemitter3Exports = requireEventemitter3();
10235
10235
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
10236
10236
 
10237
- const version = "1.6.3-0.canary.11262";
10237
+ const version = "1.6.3";
10238
10238
 
10239
10239
  // ensure the worker ends up in the bundle
10240
10240
  // If the worker should not be included this gets aliased to empty.js
@@ -21550,6 +21550,14 @@ function performUriReplacement(uri, stableId, perOptionKey, uriReplacement) {
21550
21550
  return url.href;
21551
21551
  }
21552
21552
 
21553
+ function addEventListener(el, type, listener) {
21554
+ removeEventListener(el, type, listener);
21555
+ el.addEventListener(type, listener);
21556
+ }
21557
+ function removeEventListener(el, type, listener) {
21558
+ el.removeEventListener(type, listener);
21559
+ }
21560
+
21553
21561
  /**
21554
21562
  * Controller to deal with encrypted media extensions (EME)
21555
21563
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Encrypted_Media_Extensions_API
@@ -21712,10 +21720,8 @@ class EMEController extends Logger {
21712
21720
  this.registerListeners();
21713
21721
  }
21714
21722
  destroy() {
21715
- const media = this.media;
21716
- this.unregisterListeners();
21723
+ this.onDestroying();
21717
21724
  this.onMediaDetached();
21718
- this._clear(media);
21719
21725
  // Remove any references that could be held in config options or callbacks
21720
21726
  const config = this.config;
21721
21727
  config.requestMediaKeySystemAccessFunc = null;
@@ -21731,12 +21737,14 @@ class EMEController extends Logger {
21731
21737
  this.hls.on(Events.MEDIA_DETACHED, this.onMediaDetached, this);
21732
21738
  this.hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this);
21733
21739
  this.hls.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this);
21740
+ this.hls.on(Events.DESTROYING, this.onDestroying, this);
21734
21741
  }
21735
21742
  unregisterListeners() {
21736
21743
  this.hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
21737
21744
  this.hls.off(Events.MEDIA_DETACHED, this.onMediaDetached, this);
21738
21745
  this.hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this);
21739
21746
  this.hls.off(Events.MANIFEST_LOADED, this.onManifestLoaded, this);
21747
+ this.hls.off(Events.DESTROYING, this.onDestroying, this);
21740
21748
  }
21741
21749
  getLicenseServerUrl(keySystem) {
21742
21750
  const {
@@ -22111,8 +22119,8 @@ class EMEController extends Logger {
22111
22119
  this.renewKeySession(context);
22112
22120
  }
22113
22121
  };
22114
- context.mediaKeysSession.addEventListener('message', onmessage);
22115
- context.mediaKeysSession.addEventListener('keystatuseschange', onkeystatuseschange);
22122
+ addEventListener(context.mediaKeysSession, 'message', onmessage);
22123
+ addEventListener(context.mediaKeysSession, 'keystatuseschange', onkeystatuseschange);
22116
22124
  const keyUsablePromise = new Promise((resolve, reject) => {
22117
22125
  licenseStatus.on('error', reject);
22118
22126
  licenseStatus.on('keyStatus', keyStatus => {
@@ -22389,6 +22397,10 @@ class EMEController extends Logger {
22389
22397
  });
22390
22398
  });
22391
22399
  }
22400
+ onDestroying() {
22401
+ this.unregisterListeners();
22402
+ this._clear();
22403
+ }
22392
22404
  onMediaAttached(event, data) {
22393
22405
  if (!this.config.emeEnabled) {
22394
22406
  return;
@@ -22397,28 +22409,29 @@ class EMEController extends Logger {
22397
22409
 
22398
22410
  // keep reference of media
22399
22411
  this.media = media;
22400
- media.removeEventListener('encrypted', this.onMediaEncrypted);
22401
- media.removeEventListener('waitingforkey', this.onWaitingForKey);
22402
- media.addEventListener('encrypted', this.onMediaEncrypted);
22403
- media.addEventListener('waitingforkey', this.onWaitingForKey);
22412
+ addEventListener(media, 'encrypted', this.onMediaEncrypted);
22413
+ addEventListener(media, 'waitingforkey', this.onWaitingForKey);
22404
22414
  }
22405
22415
  onMediaDetached() {
22406
22416
  const media = this.media;
22407
22417
  if (media) {
22408
- media.removeEventListener('encrypted', this.onMediaEncrypted);
22409
- media.removeEventListener('waitingforkey', this.onWaitingForKey);
22418
+ removeEventListener(media, 'encrypted', this.onMediaEncrypted);
22419
+ removeEventListener(media, 'waitingforkey', this.onWaitingForKey);
22410
22420
  this.media = null;
22411
22421
  this.mediaKeys = null;
22412
22422
  }
22413
22423
  }
22414
- _clear(media) {
22424
+ _clear() {
22415
22425
  var _media$setMediaKeys;
22416
- const mediaKeysList = this.mediaKeySessions;
22417
22426
  this._requestLicenseFailureCount = 0;
22418
- this.mediaKeys = null;
22419
- this.setMediaKeysQueue = [];
22420
- this.mediaKeySessions = [];
22421
22427
  this.keyIdToKeySessionPromise = {};
22428
+ if (!this.mediaKeys && !this.mediaKeySessions.length) {
22429
+ return;
22430
+ }
22431
+ const media = this.media;
22432
+ const mediaKeysList = this.mediaKeySessions.slice();
22433
+ this.mediaKeySessions = [];
22434
+ this.mediaKeys = null;
22422
22435
  LevelKey.clearKeyUriToKeyIdMap();
22423
22436
 
22424
22437
  // Close all sessions and remove media keys from the video element.
@@ -22432,12 +22445,7 @@ class EMEController extends Logger {
22432
22445
  fatal: false,
22433
22446
  error: new Error(`Could not clear media keys: ${error}`)
22434
22447
  });
22435
- }))).then(() => {
22436
- if (keySessionCount) {
22437
- this.log('finished closing key sessions and clearing media keys');
22438
- mediaKeysList.length = 0;
22439
- }
22440
- }).catch(error => {
22448
+ }))).catch(error => {
22441
22449
  var _this$hls3;
22442
22450
  this.log(`Could not close sessions and clear media keys: ${error}`);
22443
22451
  (_this$hls3 = this.hls) == null ? void 0 : _this$hls3.trigger(Events.ERROR, {
@@ -22446,6 +22454,10 @@ class EMEController extends Logger {
22446
22454
  fatal: false,
22447
22455
  error: new Error(`Could not close sessions and clear media keys: ${error}`)
22448
22456
  });
22457
+ }).then(() => {
22458
+ if (keySessionCount) {
22459
+ this.log('finished closing key sessions and clearing media keys');
22460
+ }
22449
22461
  });
22450
22462
  }
22451
22463
  onManifestLoading() {
@@ -24304,14 +24316,6 @@ class AssetListLoader {
24304
24316
  }
24305
24317
  }
24306
24318
 
24307
- function addEventListener(el, type, listener) {
24308
- removeEventListener(el, type, listener);
24309
- el.addEventListener(type, listener);
24310
- }
24311
- function removeEventListener(el, type, listener) {
24312
- el.removeEventListener(type, listener);
24313
- }
24314
-
24315
24319
  function playWithCatch(media) {
24316
24320
  media == null ? void 0 : media.play().catch(() => {
24317
24321
  /* no-op */