hls.js 1.6.7-0.canary.11368 → 1.6.7-0.canary.11370

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.js CHANGED
@@ -1165,7 +1165,7 @@
1165
1165
  // Some browsers don't allow to use bind on console object anyway
1166
1166
  // fallback to default if needed
1167
1167
  try {
1168
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.7-0.canary.11368");
1168
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.7-0.canary.11370");
1169
1169
  } catch (e) {
1170
1170
  /* log fn threw an exception. All logger methods are no-ops. */
1171
1171
  return createLogger();
@@ -1298,6 +1298,9 @@
1298
1298
  return str;
1299
1299
  }
1300
1300
  };
1301
+ function hexToArrayBuffer(str) {
1302
+ return Uint8Array.from(str.replace(/^0x/, '').replace(/([\da-fA-F]{2}) ?/g, '0x$1 ').replace(/ +$/, '').split(' ')).buffer;
1303
+ }
1301
1304
 
1302
1305
  var LoadStats = function LoadStats() {
1303
1306
  this.aborted = false;
@@ -2813,88 +2816,6 @@
2813
2816
  // 16 bytes
2814
2817
  kidCount, kids, dataSize, data || new Uint8Array());
2815
2818
  }
2816
- function parseMultiPssh(initData) {
2817
- var results = [];
2818
- if (initData instanceof ArrayBuffer) {
2819
- var length = initData.byteLength;
2820
- var offset = 0;
2821
- while (offset + 32 < length) {
2822
- var view = new DataView(initData, offset);
2823
- var pssh = parsePssh(view);
2824
- results.push(pssh);
2825
- offset += pssh.size;
2826
- }
2827
- }
2828
- return results;
2829
- }
2830
- function parsePssh(view) {
2831
- var size = view.getUint32(0);
2832
- var offset = view.byteOffset;
2833
- var length = view.byteLength;
2834
- if (length < size) {
2835
- return {
2836
- offset: offset,
2837
- size: length
2838
- };
2839
- }
2840
- var type = view.getUint32(4);
2841
- if (type !== 0x70737368) {
2842
- return {
2843
- offset: offset,
2844
- size: size
2845
- };
2846
- }
2847
- var version = view.getUint32(8) >>> 24;
2848
- if (version !== 0 && version !== 1) {
2849
- return {
2850
- offset: offset,
2851
- size: size
2852
- };
2853
- }
2854
- var buffer = view.buffer;
2855
- var systemId = Hex.hexDump(new Uint8Array(buffer, offset + 12, 16));
2856
- var kids = null;
2857
- var data = null;
2858
- var dataSizeOffset = 0;
2859
- if (version === 0) {
2860
- dataSizeOffset = 28;
2861
- } else if (version === 1) {
2862
- var kidCounts = view.getUint32(28);
2863
- if (!kidCounts || length < 32 + kidCounts * 16) {
2864
- return {
2865
- offset: offset,
2866
- size: size
2867
- };
2868
- }
2869
- kids = [];
2870
- for (var i = 0; i < kidCounts; i++) {
2871
- kids.push(new Uint8Array(buffer, offset + 32 + i * 16, 16));
2872
- }
2873
- dataSizeOffset = 32 + kidCounts * 16;
2874
- }
2875
- if (!dataSizeOffset) {
2876
- return {
2877
- offset: offset,
2878
- size: size
2879
- };
2880
- }
2881
- var dataSizeOrKidCount = view.getUint32(dataSizeOffset);
2882
- if (size - 32 < dataSizeOrKidCount) {
2883
- return {
2884
- offset: offset,
2885
- size: size
2886
- };
2887
- }
2888
- data = new Uint8Array(buffer, offset + dataSizeOffset + 4, dataSizeOrKidCount);
2889
- return {
2890
- version: version,
2891
- systemId: systemId,
2892
- kids: kids,
2893
- data: data,
2894
- offset: offset,
2895
- size: size
2896
- };
2897
- }
2898
2819
 
2899
2820
  var userAgentHevcSupportIsInaccurate = function userAgentHevcSupportIsInaccurate() {
2900
2821
  return /\(Windows.+Firefox\//i.test(navigator.userAgent);
@@ -7532,23 +7453,6 @@
7532
7453
  return KeySystems.CLEARKEY;
7533
7454
  }
7534
7455
  }
7535
-
7536
- // System IDs for which we can extract a key ID from "encrypted" event PSSH
7537
- var KeySystemIds = {
7538
- CENC: "1077efecc0b24d02ace33c1e52e2fb4b",
7539
- CLEARKEY: "e2719d58a985b3c9781ab030af78d30e",
7540
- PLAYREADY: "9a04f07998404286ab92e65be0885f95",
7541
- WIDEVINE: "edef8ba979d64acea3c827dcd51d21ed"
7542
- };
7543
- function keySystemIdToKeySystemDomain(systemId) {
7544
- if (systemId === KeySystemIds.WIDEVINE) {
7545
- return KeySystems.WIDEVINE;
7546
- } else if (systemId === KeySystemIds.PLAYREADY) {
7547
- return KeySystems.PLAYREADY;
7548
- } else if (systemId === KeySystemIds.CENC || systemId === KeySystemIds.CLEARKEY) {
7549
- return KeySystems.CLEARKEY;
7550
- }
7551
- }
7552
7456
  function keySystemDomainToKeySystemFormat(keySystem) {
7553
7457
  switch (keySystem) {
7554
7458
  case KeySystems.FAIRPLAY:
@@ -7654,7 +7558,7 @@
7654
7558
 
7655
7559
  var keyUriToKeyIdMap = {};
7656
7560
  var LevelKey = /*#__PURE__*/function () {
7657
- function LevelKey(method, uri, format, formatversions, iv) {
7561
+ function LevelKey(method, uri, format, formatversions, iv, keyId) {
7658
7562
  if (formatversions === void 0) {
7659
7563
  formatversions = [1];
7660
7564
  }
@@ -7678,11 +7582,18 @@
7678
7582
  this.iv = iv;
7679
7583
  this.encrypted = method ? method !== 'NONE' : false;
7680
7584
  this.isCommonEncryption = this.encrypted && !isFullSegmentEncryption(method);
7585
+ if (keyId != null && keyId.startsWith('0x')) {
7586
+ this.keyId = new Uint8Array(hexToArrayBuffer(keyId));
7587
+ }
7681
7588
  }
7682
7589
  LevelKey.clearKeyUriToKeyIdMap = function clearKeyUriToKeyIdMap() {
7683
7590
  keyUriToKeyIdMap = {};
7684
7591
  };
7685
7592
  var _proto = LevelKey.prototype;
7593
+ _proto.matches = function matches(key) {
7594
+ var _key$iv, _this$iv;
7595
+ return key.uri === this.uri && key.method === this.method && key.encrypted === this.encrypted && key.keyFormat === this.keyFormat && key.keyFormatVersions.join(',') === this.keyFormatVersions.join(',') && ((_key$iv = key.iv) == null ? void 0 : _key$iv.join(',')) === ((_this$iv = this.iv) == null ? void 0 : _this$iv.join(','));
7596
+ };
7686
7597
  _proto.isSupported = function isSupported() {
7687
7598
  // If it's Segment encryption or No encryption, just select that key system
7688
7599
  if (this.method) {
@@ -7722,6 +7633,9 @@
7722
7633
  var decryptdata = new LevelKey(this.method, this.uri, 'identity', this.keyFormatVersions, iv);
7723
7634
  return decryptdata;
7724
7635
  }
7636
+ if (this.pssh && this.keyId) {
7637
+ return this;
7638
+ }
7725
7639
 
7726
7640
  // Initialize keyId if possible
7727
7641
  var keyBytes = convertDataUriToArrayBytes(this.uri);
@@ -7731,9 +7645,10 @@
7731
7645
  // Setting `pssh` on this LevelKey/DecryptData allows HLS.js to generate a session using
7732
7646
  // the playlist-key before the "encrypted" event. (Comment out to only use "encrypted" path.)
7733
7647
  this.pssh = keyBytes;
7734
- // In case of widevine keyID is embedded in PSSH box. Read Key ID.
7735
- if (keyBytes.length >= 22) {
7736
- this.keyId = keyBytes.subarray(keyBytes.length - 22, keyBytes.length - 6);
7648
+ // In case of Widevine, if KEYID is not in the playlist, assume only two fields in the pssh KEY tag URI.
7649
+ if (!this.keyId && keyBytes.length >= 22) {
7650
+ var offset = keyBytes.length - 22;
7651
+ this.keyId = keyBytes.subarray(offset, offset + 16);
7737
7652
  }
7738
7653
  break;
7739
7654
  case KeySystemFormats.PLAYREADY:
@@ -8233,10 +8148,14 @@
8233
8148
  if (!levelkeys) {
8234
8149
  levelkeys = {};
8235
8150
  }
8236
- if (levelkeys[levelKey.keyFormat]) {
8237
- levelkeys = _extends({}, levelkeys);
8151
+ var currentKey = levelkeys[levelKey.keyFormat];
8152
+ // Ignore duplicate playlist KEY tags
8153
+ if (!(currentKey != null && currentKey.matches(levelKey))) {
8154
+ if (currentKey) {
8155
+ levelkeys = _extends({}, levelkeys);
8156
+ }
8157
+ levelkeys[levelKey.keyFormat] = levelKey;
8238
8158
  }
8239
- levelkeys[levelKey.keyFormat] = levelKey;
8240
8159
  } else {
8241
8160
  logger.warn("[Keys] Ignoring invalid EXT-X-KEY tag: \"" + value1 + "\"");
8242
8161
  }
@@ -8460,7 +8379,7 @@
8460
8379
  // No uri is allowed when METHOD is NONE
8461
8380
  var resolvedUri = decrypturi ? M3U8Parser.resolve(decrypturi, baseurl) : '';
8462
8381
  var keyFormatVersions = (decryptkeyformatversions ? decryptkeyformatversions : '1').split('/').map(Number).filter(Number.isFinite);
8463
- return new LevelKey(decryptmethod, resolvedUri, decryptkeyformat, keyFormatVersions, decryptiv);
8382
+ return new LevelKey(decryptmethod, resolvedUri, decryptkeyformat, keyFormatVersions, decryptiv, keyAttrs.KEYID);
8464
8383
  }
8465
8384
  function parseStartTimeOffset(startAttributes) {
8466
8385
  var startAttrs = new AttrList(startAttributes);
@@ -16725,7 +16644,7 @@
16725
16644
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
16726
16645
  }
16727
16646
 
16728
- var version = "1.6.7-0.canary.11368";
16647
+ var version = "1.6.7-0.canary.11370";
16729
16648
 
16730
16649
  // ensure the worker ends up in the bundle
16731
16650
  // If the worker should not be included this gets aliased to empty.js
@@ -17213,7 +17132,7 @@
17213
17132
  var syncFrag = findNearestWithCC(trackDetails, targetDiscontinuity, pos);
17214
17133
  // Only stop waiting for audioFrag.cc if an audio segment of the same discontinuity domain (cc) is found
17215
17134
  if (syncFrag) {
17216
- this.log("Waiting fragment cc (" + (waitingToAppend == null ? void 0 : waitingToAppend.cc) + ") cancelled because video is at cc " + mainAnchor.cc);
17135
+ this.log("Syncing with main frag at " + syncFrag.start + " cc " + syncFrag.cc);
17217
17136
  this.startFragRequested = false;
17218
17137
  this.nextLoadPosition = syncFrag.start;
17219
17138
  this.resetLoadingState();
@@ -22324,154 +22243,6 @@
22324
22243
  _this.keyIdToKeySessionPromise = {};
22325
22244
  _this.mediaKeys = null;
22326
22245
  _this.setMediaKeysQueue = EMEController.CDMCleanupPromise ? [EMEController.CDMCleanupPromise] : [];
22327
- _this.onMediaEncrypted = function (event) {
22328
- var initDataType = event.initDataType,
22329
- initData = event.initData;
22330
- var logMessage = "\"" + event.type + "\" event: init data type: \"" + initDataType + "\"";
22331
- _this.debug(logMessage);
22332
-
22333
- // Ignore event when initData is null
22334
- if (initData === null) {
22335
- return;
22336
- }
22337
- if (!_this.keyFormatPromise) {
22338
- var keySystems = Object.keys(_this.keySystemAccessPromises);
22339
- if (!keySystems.length) {
22340
- keySystems = getKeySystemsForConfig(_this.config);
22341
- }
22342
- var keyFormats = keySystems.map(keySystemDomainToKeySystemFormat).filter(function (k) {
22343
- return !!k;
22344
- });
22345
- _this.keyFormatPromise = _this.getKeyFormatPromise(keyFormats);
22346
- }
22347
- _this.keyFormatPromise.then(function (keySystemFormat) {
22348
- var keySystem = keySystemFormatToKeySystemDomain(keySystemFormat);
22349
- var keyId;
22350
- var keySystemDomain;
22351
- if (initDataType === 'sinf') {
22352
- if (keySystem !== KeySystems.FAIRPLAY) {
22353
- _this.warn("Ignoring unexpected \"" + event.type + "\" event with init data type: \"" + initDataType + "\" for selected key-system " + keySystem);
22354
- return;
22355
- }
22356
- // Match sinf keyId to playlist skd://keyId=
22357
- var json = bin2str(new Uint8Array(initData));
22358
- try {
22359
- var sinf = base64Decode(JSON.parse(json).sinf);
22360
- var tenc = parseSinf(sinf);
22361
- if (!tenc) {
22362
- throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");
22363
- }
22364
- keyId = new Uint8Array(tenc.subarray(8, 24));
22365
- keySystemDomain = KeySystems.FAIRPLAY;
22366
- } catch (error) {
22367
- _this.warn(logMessage + " Failed to parse sinf: " + error);
22368
- return;
22369
- }
22370
- } else {
22371
- if (keySystem !== KeySystems.WIDEVINE && keySystem !== KeySystems.PLAYREADY) {
22372
- _this.warn("Ignoring unexpected \"" + event.type + "\" event with init data type: \"" + initDataType + "\" for selected key-system " + keySystem);
22373
- return;
22374
- }
22375
- // Support Widevine/PlayReady clear-lead key-session creation (otherwise depend on playlist keys)
22376
- var psshResults = parseMultiPssh(initData);
22377
- var psshInfos = psshResults.filter(function (pssh) {
22378
- return !!pssh.systemId && keySystemIdToKeySystemDomain(pssh.systemId) === keySystem;
22379
- });
22380
- if (psshInfos.length > 1) {
22381
- _this.warn(logMessage + " Using first of " + psshInfos.length + " pssh found for selected key-system " + keySystem);
22382
- }
22383
- var psshInfo = psshInfos[0];
22384
- if (!psshInfo) {
22385
- if (psshResults.length === 0 || psshResults.some(function (pssh) {
22386
- return !pssh.systemId;
22387
- })) {
22388
- _this.warn(logMessage + " contains incomplete or invalid pssh data");
22389
- } else {
22390
- _this.log("ignoring " + logMessage + " for " + psshResults.map(function (pssh) {
22391
- return keySystemIdToKeySystemDomain(pssh.systemId);
22392
- }).join(',') + " pssh data in favor of playlist keys");
22393
- }
22394
- return;
22395
- }
22396
- keySystemDomain = keySystemIdToKeySystemDomain(psshInfo.systemId);
22397
- if (psshInfo.version === 0 && psshInfo.data) {
22398
- if (keySystemDomain === KeySystems.WIDEVINE) {
22399
- var offset = psshInfo.data.length - 22;
22400
- keyId = new Uint8Array(psshInfo.data.subarray(offset, offset + 16));
22401
- } else if (keySystemDomain === KeySystems.PLAYREADY) {
22402
- keyId = parsePlayReadyWRM(psshInfo.data);
22403
- }
22404
- }
22405
- }
22406
- if (!keySystemDomain || !keyId) {
22407
- return;
22408
- }
22409
- var keyIdHex = Hex.hexDump(keyId);
22410
- var _this2 = _this,
22411
- keyIdToKeySessionPromise = _this2.keyIdToKeySessionPromise,
22412
- mediaKeySessions = _this2.mediaKeySessions;
22413
- var keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex];
22414
- var _loop = function _loop() {
22415
- // Match playlist key
22416
- var keyContext = mediaKeySessions[i];
22417
- var decryptdata = keyContext.decryptdata;
22418
- if (!decryptdata.keyId) {
22419
- return 0; // continue
22420
- }
22421
- var oldKeyIdHex = Hex.hexDump(decryptdata.keyId);
22422
- if (keyIdHex === oldKeyIdHex || decryptdata.uri.replace(/-/g, '').indexOf(keyIdHex) !== -1) {
22423
- keySessionContextPromise = keyIdToKeySessionPromise[oldKeyIdHex];
22424
- if (decryptdata.pssh) {
22425
- return 1; // break
22426
- }
22427
- delete keyIdToKeySessionPromise[oldKeyIdHex];
22428
- decryptdata.pssh = new Uint8Array(initData);
22429
- decryptdata.keyId = keyId;
22430
- keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = keySessionContextPromise.then(function () {
22431
- return _this.generateRequestWithPreferredKeySession(keyContext, initDataType, initData, 'encrypted-event-key-match');
22432
- });
22433
- keySessionContextPromise.catch(function (error) {
22434
- return _this.handleError(error);
22435
- });
22436
- return 1; // break
22437
- }
22438
- },
22439
- _ret;
22440
- for (var i = 0; i < mediaKeySessions.length; i++) {
22441
- _ret = _loop();
22442
- if (_ret === 0) continue;
22443
- if (_ret === 1) break;
22444
- }
22445
- if (!keySessionContextPromise) {
22446
- if (keySystemDomain !== keySystem) {
22447
- _this.log("Ignoring \"" + event.type + "\" event with " + keySystemDomain + " init data for selected key-system " + keySystem);
22448
- return;
22449
- }
22450
- // "Clear-lead" (misc key not encountered in playlist)
22451
- keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = _this.getKeySystemSelectionPromise([keySystemDomain]).then(function (_ref) {
22452
- var _keySystemToKeySystem;
22453
- var keySystem = _ref.keySystem,
22454
- mediaKeys = _ref.mediaKeys;
22455
- _this.throwIfDestroyed();
22456
- var decryptdata = new LevelKey('ISO-23001-7', keyIdHex, (_keySystemToKeySystem = keySystemDomainToKeySystemFormat(keySystem)) != null ? _keySystemToKeySystem : '');
22457
- decryptdata.pssh = new Uint8Array(initData);
22458
- decryptdata.keyId = keyId;
22459
- return _this.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
22460
- _this.throwIfDestroyed();
22461
- var keySessionContext = _this.createMediaKeySessionContext({
22462
- decryptdata: decryptdata,
22463
- keySystem: keySystem,
22464
- mediaKeys: mediaKeys
22465
- });
22466
- return _this.generateRequestWithPreferredKeySession(keySessionContext, initDataType, initData, 'encrypted-event-no-match');
22467
- });
22468
- });
22469
- keySessionContextPromise.catch(function (error) {
22470
- return _this.handleError(error);
22471
- });
22472
- }
22473
- });
22474
- };
22475
22246
  _this.onWaitingForKey = function (event) {
22476
22247
  _this.log("\"" + event.type + "\" event");
22477
22248
  };
@@ -22493,7 +22264,7 @@
22493
22264
  // @ts-ignore
22494
22265
  this.hls = this.config = this.keyIdToKeySessionPromise = null;
22495
22266
  // @ts-ignore
22496
- this.onMediaEncrypted = this.onWaitingForKey = null;
22267
+ this.onWaitingForKey = null;
22497
22268
  };
22498
22269
  _proto.registerListeners = function registerListeners() {
22499
22270
  this.hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
@@ -22540,7 +22311,7 @@
22540
22311
  }
22541
22312
  };
22542
22313
  _proto.attemptKeySystemAccess = function attemptKeySystemAccess(keySystemsToAttempt) {
22543
- var _this3 = this;
22314
+ var _this2 = this;
22544
22315
  var levels = this.hls.levels;
22545
22316
  var uniqueCodec = function uniqueCodec(value, i, a) {
22546
22317
  return !!value && a.indexOf(value) === i;
@@ -22557,7 +22328,7 @@
22557
22328
  return new Promise(function (resolve, reject) {
22558
22329
  var _attempt = function attempt(keySystems) {
22559
22330
  var keySystem = keySystems.shift();
22560
- _this3.getMediaKeysPromise(keySystem, audioCodecs, videoCodecs).then(function (mediaKeys) {
22331
+ _this2.getMediaKeysPromise(keySystem, audioCodecs, videoCodecs).then(function (mediaKeys) {
22561
22332
  return resolve({
22562
22333
  keySystem: keySystem,
22563
22334
  mediaKeys: mediaKeys
@@ -22592,7 +22363,7 @@
22592
22363
  return requestMediaKeySystemAccessFunc(keySystem, supportedConfigurations);
22593
22364
  };
22594
22365
  _proto.getMediaKeysPromise = function getMediaKeysPromise(keySystem, audioCodecs, videoCodecs) {
22595
- var _this4 = this;
22366
+ var _this3 = this;
22596
22367
  // This can throw, but is caught in event handler callpath
22597
22368
  var mediaKeySystemConfigs = getSupportedMediaKeySystemConfigurations(keySystem, audioCodecs, videoCodecs, this.config.drmSystemOptions);
22598
22369
  var keySystemAccessPromises = this.keySystemAccessPromises[keySystem];
@@ -22604,24 +22375,24 @@
22604
22375
  keySystemAccess: keySystemAccess
22605
22376
  };
22606
22377
  keySystemAccess.catch(function (error) {
22607
- _this4.log("Failed to obtain access to key-system \"" + keySystem + "\": " + error);
22378
+ _this3.log("Failed to obtain access to key-system \"" + keySystem + "\": " + error);
22608
22379
  });
22609
22380
  return keySystemAccess.then(function (mediaKeySystemAccess) {
22610
- _this4.log("Access for key-system \"" + mediaKeySystemAccess.keySystem + "\" obtained");
22611
- var certificateRequest = _this4.fetchServerCertificate(keySystem);
22612
- _this4.log("Create media-keys for \"" + keySystem + "\"");
22381
+ _this3.log("Access for key-system \"" + mediaKeySystemAccess.keySystem + "\" obtained");
22382
+ var certificateRequest = _this3.fetchServerCertificate(keySystem);
22383
+ _this3.log("Create media-keys for \"" + keySystem + "\"");
22613
22384
  _keySystemAccessPromises.mediaKeys = mediaKeySystemAccess.createMediaKeys().then(function (mediaKeys) {
22614
- _this4.log("Media-keys created for \"" + keySystem + "\"");
22385
+ _this3.log("Media-keys created for \"" + keySystem + "\"");
22615
22386
  _keySystemAccessPromises.hasMediaKeys = true;
22616
22387
  return certificateRequest.then(function (certificate) {
22617
22388
  if (certificate) {
22618
- return _this4.setMediaKeysServerCertificate(mediaKeys, keySystem, certificate);
22389
+ return _this3.setMediaKeysServerCertificate(mediaKeys, keySystem, certificate);
22619
22390
  }
22620
22391
  return mediaKeys;
22621
22392
  });
22622
22393
  });
22623
22394
  _keySystemAccessPromises.mediaKeys.catch(function (error) {
22624
- _this4.error("Failed to create media-keys for \"" + keySystem + "\"}: " + error);
22395
+ _this3.error("Failed to create media-keys for \"" + keySystem + "\"}: " + error);
22625
22396
  });
22626
22397
  return _keySystemAccessPromises.mediaKeys;
22627
22398
  });
@@ -22630,10 +22401,10 @@
22630
22401
  return keySystemAccessPromises.mediaKeys;
22631
22402
  });
22632
22403
  };
22633
- _proto.createMediaKeySessionContext = function createMediaKeySessionContext(_ref2) {
22634
- var decryptdata = _ref2.decryptdata,
22635
- keySystem = _ref2.keySystem,
22636
- mediaKeys = _ref2.mediaKeys;
22404
+ _proto.createMediaKeySessionContext = function createMediaKeySessionContext(_ref) {
22405
+ var decryptdata = _ref.decryptdata,
22406
+ keySystem = _ref.keySystem,
22407
+ mediaKeys = _ref.mediaKeys;
22637
22408
  this.log("Creating key-system session \"" + keySystem + "\" keyId: " + Hex.hexDump(decryptdata.keyId || []));
22638
22409
  var mediaKeysSession = mediaKeys.createSession();
22639
22410
  var mediaKeySessionContext = {
@@ -22674,35 +22445,35 @@
22674
22445
  return keySession.update(data);
22675
22446
  };
22676
22447
  _proto.getSelectedKeySystemFormats = function getSelectedKeySystemFormats() {
22677
- var _this5 = this;
22448
+ var _this4 = this;
22678
22449
  return Object.keys(this.keySystemAccessPromises).map(function (keySystem) {
22679
22450
  return {
22680
22451
  keySystem: keySystem,
22681
- hasMediaKeys: _this5.keySystemAccessPromises[keySystem].hasMediaKeys
22452
+ hasMediaKeys: _this4.keySystemAccessPromises[keySystem].hasMediaKeys
22682
22453
  };
22683
- }).filter(function (_ref3) {
22684
- var hasMediaKeys = _ref3.hasMediaKeys;
22454
+ }).filter(function (_ref2) {
22455
+ var hasMediaKeys = _ref2.hasMediaKeys;
22685
22456
  return !!hasMediaKeys;
22686
- }).map(function (_ref4) {
22687
- var keySystem = _ref4.keySystem;
22457
+ }).map(function (_ref3) {
22458
+ var keySystem = _ref3.keySystem;
22688
22459
  return keySystemDomainToKeySystemFormat(keySystem);
22689
22460
  }).filter(function (keySystem) {
22690
22461
  return !!keySystem;
22691
22462
  });
22692
22463
  };
22693
22464
  _proto.getKeySystemAccess = function getKeySystemAccess(keySystemsToAttempt) {
22694
- var _this6 = this;
22695
- return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(function (_ref5) {
22696
- var keySystem = _ref5.keySystem,
22697
- mediaKeys = _ref5.mediaKeys;
22698
- return _this6.attemptSetMediaKeys(keySystem, mediaKeys);
22465
+ var _this5 = this;
22466
+ return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(function (_ref4) {
22467
+ var keySystem = _ref4.keySystem,
22468
+ mediaKeys = _ref4.mediaKeys;
22469
+ return _this5.attemptSetMediaKeys(keySystem, mediaKeys);
22699
22470
  });
22700
22471
  };
22701
22472
  _proto.selectKeySystem = function selectKeySystem(keySystemsToAttempt) {
22702
- var _this7 = this;
22473
+ var _this6 = this;
22703
22474
  return new Promise(function (resolve, reject) {
22704
- return _this7.getKeySystemSelectionPromise(keySystemsToAttempt).then(function (_ref6) {
22705
- var keySystem = _ref6.keySystem;
22475
+ return _this6.getKeySystemSelectionPromise(keySystemsToAttempt).then(function (_ref5) {
22476
+ var keySystem = _ref5.keySystem;
22706
22477
  var keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
22707
22478
  if (keySystemFormat) {
22708
22479
  resolve(keySystemFormat);
@@ -22728,21 +22499,21 @@
22728
22499
  return this.selectKeySystem(keySystemsToAttempt);
22729
22500
  };
22730
22501
  _proto.loadKey = function loadKey(data) {
22731
- var _this8 = this;
22502
+ var _this7 = this;
22732
22503
  var decryptdata = data.keyInfo.decryptdata;
22733
22504
  var keyId = this.getKeyIdString(decryptdata);
22734
22505
  var keyDetails = "(keyId: " + keyId + " format: \"" + decryptdata.keyFormat + "\" method: " + decryptdata.method + " uri: " + decryptdata.uri + ")";
22735
22506
  this.log("Starting session for key " + keyDetails);
22736
22507
  var keyContextPromise = this.keyIdToKeySessionPromise[keyId];
22737
22508
  if (!keyContextPromise) {
22738
- keyContextPromise = this.getKeySystemForKeyPromise(decryptdata).then(function (_ref7) {
22739
- var keySystem = _ref7.keySystem,
22740
- mediaKeys = _ref7.mediaKeys;
22741
- _this8.throwIfDestroyed();
22742
- _this8.log("Handle encrypted media sn: " + data.frag.sn + " " + data.frag.type + ": " + data.frag.level + " using key " + keyDetails);
22743
- return _this8.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
22744
- _this8.throwIfDestroyed();
22745
- return _this8.createMediaKeySessionContext({
22509
+ keyContextPromise = this.getKeySystemForKeyPromise(decryptdata).then(function (_ref6) {
22510
+ var keySystem = _ref6.keySystem,
22511
+ mediaKeys = _ref6.mediaKeys;
22512
+ _this7.throwIfDestroyed();
22513
+ _this7.log("Handle encrypted media sn: " + data.frag.sn + " " + data.frag.type + ": " + data.frag.level + " using key " + keyDetails);
22514
+ return _this7.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
22515
+ _this7.throwIfDestroyed();
22516
+ return _this7.createMediaKeySessionContext({
22746
22517
  keySystem: keySystem,
22747
22518
  mediaKeys: mediaKeys,
22748
22519
  decryptdata: decryptdata
@@ -22752,10 +22523,10 @@
22752
22523
  var keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = keyContextPromise.then(function (keySessionContext) {
22753
22524
  var scheme = 'cenc';
22754
22525
  var initData = decryptdata.pssh ? decryptdata.pssh.buffer : null;
22755
- return _this8.generateRequestWithPreferredKeySession(keySessionContext, scheme, initData, 'playlist-key');
22526
+ return _this7.generateRequestWithPreferredKeySession(keySessionContext, scheme, initData, 'playlist-key');
22756
22527
  });
22757
22528
  keySessionContextPromise.catch(function (error) {
22758
- return _this8.handleError(error);
22529
+ return _this7.handleError(error);
22759
22530
  });
22760
22531
  }
22761
22532
  return keyContextPromise;
@@ -22807,7 +22578,7 @@
22807
22578
  return this.attemptKeySystemAccess(keySystemsToAttempt);
22808
22579
  };
22809
22580
  _proto.attemptSetMediaKeys = function attemptSetMediaKeys(keySystem, mediaKeys) {
22810
- var _this9 = this;
22581
+ var _this8 = this;
22811
22582
  if (this.mediaKeys === mediaKeys) {
22812
22583
  return Promise.resolve();
22813
22584
  }
@@ -22816,18 +22587,18 @@
22816
22587
  // Only one setMediaKeys() can run at one time, and multiple setMediaKeys() operations
22817
22588
  // can be queued for execution for multiple key sessions.
22818
22589
  var setMediaKeysPromise = Promise.all(queue).then(function () {
22819
- if (!_this9.media) {
22820
- _this9.mediaKeys = null;
22590
+ if (!_this8.media) {
22591
+ _this8.mediaKeys = null;
22821
22592
  throw new Error('Attempted to set mediaKeys without media element attached');
22822
22593
  }
22823
- return _this9.media.setMediaKeys(mediaKeys);
22594
+ return _this8.media.setMediaKeys(mediaKeys);
22824
22595
  });
22825
22596
  this.mediaKeys = mediaKeys;
22826
22597
  this.setMediaKeysQueue.push(setMediaKeysPromise);
22827
22598
  return setMediaKeysPromise.then(function () {
22828
- _this9.log("Media-keys set for \"" + keySystem + "\"");
22599
+ _this8.log("Media-keys set for \"" + keySystem + "\"");
22829
22600
  queue.push(setMediaKeysPromise);
22830
- _this9.setMediaKeysQueue = _this9.setMediaKeysQueue.filter(function (p) {
22601
+ _this8.setMediaKeysQueue = _this8.setMediaKeysQueue.filter(function (p) {
22831
22602
  return queue.indexOf(p) === -1;
22832
22603
  });
22833
22604
  });
@@ -22835,7 +22606,7 @@
22835
22606
  _proto.generateRequestWithPreferredKeySession = function generateRequestWithPreferredKeySession(context, initDataType, initData, reason) {
22836
22607
  var _this$config$drmSyste,
22837
22608
  _this$config$drmSyste2,
22838
- _this0 = this;
22609
+ _this9 = this;
22839
22610
  var generateRequestFilter = (_this$config$drmSyste = this.config.drmSystems) == null ? void 0 : (_this$config$drmSyste2 = _this$config$drmSyste[context.keySystem]) == null ? void 0 : _this$config$drmSyste2.generateRequest;
22840
22611
  if (generateRequestFilter) {
22841
22612
  try {
@@ -22869,22 +22640,22 @@
22869
22640
  }
22870
22641
  var messageType = event.messageType,
22871
22642
  message = event.message;
22872
- _this0.log("\"" + messageType + "\" message event for session \"" + keySession.sessionId + "\" message size: " + message.byteLength);
22643
+ _this9.log("\"" + messageType + "\" message event for session \"" + keySession.sessionId + "\" message size: " + message.byteLength);
22873
22644
  if (messageType === 'license-request' || messageType === 'license-renewal') {
22874
- _this0.renewLicense(context, message).catch(function (error) {
22645
+ _this9.renewLicense(context, message).catch(function (error) {
22875
22646
  if (licenseStatus.eventNames().length) {
22876
22647
  licenseStatus.emit('error', error);
22877
22648
  } else {
22878
- _this0.handleError(error);
22649
+ _this9.handleError(error);
22879
22650
  }
22880
22651
  });
22881
22652
  } else if (messageType === 'license-release') {
22882
22653
  if (context.keySystem === KeySystems.FAIRPLAY) {
22883
- _this0.updateKeySession(context, strToUtf8array('acknowledged'));
22884
- _this0.removeSession(context);
22654
+ _this9.updateKeySession(context, strToUtf8array('acknowledged'));
22655
+ _this9.removeSession(context);
22885
22656
  }
22886
22657
  } else {
22887
- _this0.warn("unhandled media key message type \"" + messageType + "\"");
22658
+ _this9.warn("unhandled media key message type \"" + messageType + "\"");
22888
22659
  }
22889
22660
  };
22890
22661
  var onkeystatuseschange = context._onkeystatuseschange = function (event) {
@@ -22893,12 +22664,12 @@
22893
22664
  licenseStatus.emit('error', new Error('invalid state'));
22894
22665
  return;
22895
22666
  }
22896
- _this0.onKeyStatusChange(context);
22667
+ _this9.onKeyStatusChange(context);
22897
22668
  var keyStatus = context.keyStatus;
22898
22669
  licenseStatus.emit('keyStatus', keyStatus);
22899
22670
  if (keyStatus === 'expired') {
22900
- _this0.warn(context.keySystem + " expired for key " + keyId);
22901
- _this0.renewKeySession(context);
22671
+ _this9.warn(context.keySystem + " expired for key " + keyId);
22672
+ _this9.renewKeySession(context);
22902
22673
  }
22903
22674
  };
22904
22675
  addEventListener(context.mediaKeysSession, 'message', onmessage);
@@ -22923,13 +22694,13 @@
22923
22694
  } else if (keyStatus === 'expired') {
22924
22695
  reject(new Error('key expired while generating request'));
22925
22696
  } else {
22926
- _this0.warn("unhandled key status change \"" + keyStatus + "\"");
22697
+ _this9.warn("unhandled key status change \"" + keyStatus + "\"");
22927
22698
  }
22928
22699
  });
22929
22700
  });
22930
22701
  return context.mediaKeysSession.generateRequest(initDataType, initData).then(function () {
22931
22702
  var _context$mediaKeysSes;
22932
- _this0.log("Request generated for key-session \"" + ((_context$mediaKeysSes = context.mediaKeysSession) == null ? void 0 : _context$mediaKeysSes.sessionId) + "\" keyId: " + keyId);
22703
+ _this9.log("Request generated for key-session \"" + ((_context$mediaKeysSes = context.mediaKeysSession) == null ? void 0 : _context$mediaKeysSes.sessionId) + "\" keyId: " + keyId);
22933
22704
  }).catch(function (error) {
22934
22705
  throw new EMEKeyError({
22935
22706
  type: ErrorTypes.KEY_SYSTEM_ERROR,
@@ -22941,7 +22712,7 @@
22941
22712
  return keyUsablePromise;
22942
22713
  }).catch(function (error) {
22943
22714
  licenseStatus.removeAllListeners();
22944
- _this0.removeSession(context);
22715
+ _this9.removeSession(context);
22945
22716
  throw error;
22946
22717
  }).then(function () {
22947
22718
  licenseStatus.removeAllListeners();
@@ -22949,7 +22720,7 @@
22949
22720
  });
22950
22721
  };
22951
22722
  _proto.onKeyStatusChange = function onKeyStatusChange(mediaKeySessionContext) {
22952
- var _this1 = this;
22723
+ var _this0 = this;
22953
22724
  mediaKeySessionContext.mediaKeysSession.keyStatuses.forEach(function (status, keyId) {
22954
22725
  // keyStatuses.forEach is not standard API so the callback value looks weird on xboxone
22955
22726
  // xboxone callback(keyId, status) so we need to exchange them
@@ -22958,7 +22729,7 @@
22958
22729
  keyId = status;
22959
22730
  status = temp;
22960
22731
  }
22961
- _this1.log("key status change \"" + status + "\" for keyStatuses keyId: " + Hex.hexDump('buffer' in keyId ? new Uint8Array(keyId.buffer, keyId.byteOffset, keyId.byteLength) : new Uint8Array(keyId)) + " session keyId: " + Hex.hexDump(new Uint8Array(mediaKeySessionContext.decryptdata.keyId || [])) + " uri: " + mediaKeySessionContext.decryptdata.uri);
22732
+ _this0.log("key status change \"" + status + "\" for keyStatuses keyId: " + Hex.hexDump('buffer' in keyId ? new Uint8Array(keyId.buffer, keyId.byteOffset, keyId.byteLength) : new Uint8Array(keyId)) + " session keyId: " + Hex.hexDump(new Uint8Array(mediaKeySessionContext.decryptdata.keyId || [])) + " uri: " + mediaKeySessionContext.decryptdata.uri);
22962
22733
  mediaKeySessionContext.keyStatus = status;
22963
22734
  });
22964
22735
  };
@@ -23020,10 +22791,10 @@
23020
22791
  });
23021
22792
  };
23022
22793
  _proto.setMediaKeysServerCertificate = function setMediaKeysServerCertificate(mediaKeys, keySystem, cert) {
23023
- var _this10 = this;
22794
+ var _this1 = this;
23024
22795
  return new Promise(function (resolve, reject) {
23025
22796
  mediaKeys.setServerCertificate(cert).then(function (success) {
23026
- _this10.log("setServerCertificate " + (success ? 'success' : 'not supported by CDM') + " (" + (cert == null ? void 0 : cert.byteLength) + ") on \"" + keySystem + "\"");
22797
+ _this1.log("setServerCertificate " + (success ? 'success' : 'not supported by CDM') + " (" + (cert == null ? void 0 : cert.byteLength) + ") on \"" + keySystem + "\"");
23027
22798
  resolve(mediaKeys);
23028
22799
  }).catch(function (error) {
23029
22800
  reject(new EMEKeyError({
@@ -23036,9 +22807,9 @@
23036
22807
  });
23037
22808
  };
23038
22809
  _proto.renewLicense = function renewLicense(context, keyMessage) {
23039
- var _this11 = this;
22810
+ var _this10 = this;
23040
22811
  return this.requestLicense(context, new Uint8Array(keyMessage)).then(function (data) {
23041
- return _this11.updateKeySession(context, new Uint8Array(data)).catch(function (error) {
22812
+ return _this10.updateKeySession(context, new Uint8Array(data)).catch(function (error) {
23042
22813
  throw new EMEKeyError({
23043
22814
  type: ErrorTypes.KEY_SYSTEM_ERROR,
23044
22815
  details: ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,
@@ -23086,7 +22857,7 @@
23086
22857
  return strToUtf8array(atob(challengeText));
23087
22858
  };
23088
22859
  _proto.setupLicenseXHR = function setupLicenseXHR(xhr, url, keysListItem, licenseChallenge) {
23089
- var _this12 = this;
22860
+ var _this11 = this;
23090
22861
  var licenseXhrSetup = this.config.licenseXhrSetup;
23091
22862
  if (!licenseXhrSetup) {
23092
22863
  xhr.open('POST', url, true);
@@ -23099,7 +22870,7 @@
23099
22870
  if (!keysListItem.decryptdata) {
23100
22871
  throw new Error('Key removed');
23101
22872
  }
23102
- return licenseXhrSetup.call(_this12.hls, xhr, url, keysListItem, licenseChallenge);
22873
+ return licenseXhrSetup.call(_this11.hls, xhr, url, keysListItem, licenseChallenge);
23103
22874
  }).catch(function (error) {
23104
22875
  if (!keysListItem.decryptdata) {
23105
22876
  // Key session removed. Cancel license request.
@@ -23107,7 +22878,7 @@
23107
22878
  }
23108
22879
  // let's try to open before running setup
23109
22880
  xhr.open('POST', url, true);
23110
- return licenseXhrSetup.call(_this12.hls, xhr, url, keysListItem, licenseChallenge);
22881
+ return licenseXhrSetup.call(_this11.hls, xhr, url, keysListItem, licenseChallenge);
23111
22882
  }).then(function (licenseXhrSetupResult) {
23112
22883
  // if licenseXhrSetup did not yet call open, let's do it now
23113
22884
  if (!xhr.readyState) {
@@ -23121,36 +22892,36 @@
23121
22892
  });
23122
22893
  };
23123
22894
  _proto.requestLicense = function requestLicense(keySessionContext, licenseChallenge) {
23124
- var _this13 = this;
22895
+ var _this12 = this;
23125
22896
  var keyLoadPolicy = this.config.keyLoadPolicy.default;
23126
22897
  return new Promise(function (resolve, reject) {
23127
- var url = _this13.getLicenseServerUrlOrThrow(keySessionContext.keySystem);
23128
- _this13.log("Sending license request to URL: " + url);
22898
+ var url = _this12.getLicenseServerUrlOrThrow(keySessionContext.keySystem);
22899
+ _this12.log("Sending license request to URL: " + url);
23129
22900
  var xhr = new XMLHttpRequest();
23130
22901
  xhr.responseType = 'arraybuffer';
23131
22902
  xhr.onreadystatechange = function () {
23132
- if (!_this13.hls || !keySessionContext.mediaKeysSession) {
22903
+ if (!_this12.hls || !keySessionContext.mediaKeysSession) {
23133
22904
  return reject(new Error('invalid state'));
23134
22905
  }
23135
22906
  if (xhr.readyState === 4) {
23136
22907
  if (xhr.status === 200) {
23137
- _this13._requestLicenseFailureCount = 0;
22908
+ _this12._requestLicenseFailureCount = 0;
23138
22909
  var data = xhr.response;
23139
- _this13.log("License received " + (data instanceof ArrayBuffer ? data.byteLength : data));
23140
- var licenseResponseCallback = _this13.config.licenseResponseCallback;
22910
+ _this12.log("License received " + (data instanceof ArrayBuffer ? data.byteLength : data));
22911
+ var licenseResponseCallback = _this12.config.licenseResponseCallback;
23141
22912
  if (licenseResponseCallback) {
23142
22913
  try {
23143
- data = licenseResponseCallback.call(_this13.hls, xhr, url, keySessionContext);
22914
+ data = licenseResponseCallback.call(_this12.hls, xhr, url, keySessionContext);
23144
22915
  } catch (error) {
23145
- _this13.error(error);
22916
+ _this12.error(error);
23146
22917
  }
23147
22918
  }
23148
22919
  resolve(data);
23149
22920
  } else {
23150
22921
  var retryConfig = keyLoadPolicy.errorRetry;
23151
22922
  var maxNumRetry = retryConfig ? retryConfig.maxNumRetry : 0;
23152
- _this13._requestLicenseFailureCount++;
23153
- if (_this13._requestLicenseFailureCount > maxNumRetry || xhr.status >= 400 && xhr.status < 500) {
22923
+ _this12._requestLicenseFailureCount++;
22924
+ if (_this12._requestLicenseFailureCount > maxNumRetry || xhr.status >= 400 && xhr.status < 500) {
23154
22925
  reject(new EMEKeyError({
23155
22926
  type: ErrorTypes.KEY_SYSTEM_ERROR,
23156
22927
  details: ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,
@@ -23164,9 +22935,9 @@
23164
22935
  }
23165
22936
  }, "License Request XHR failed (" + url + "). Status: " + xhr.status + " (" + xhr.statusText + ")"));
23166
22937
  } else {
23167
- var attemptsLeft = maxNumRetry - _this13._requestLicenseFailureCount + 1;
23168
- _this13.warn("Retrying license request, " + attemptsLeft + " attempts left");
23169
- _this13.requestLicense(keySessionContext, licenseChallenge).then(resolve, reject);
22938
+ var attemptsLeft = maxNumRetry - _this12._requestLicenseFailureCount + 1;
22939
+ _this12.warn("Retrying license request, " + attemptsLeft + " attempts left");
22940
+ _this12.requestLicense(keySessionContext, licenseChallenge).then(resolve, reject);
23170
22941
  }
23171
22942
  }
23172
22943
  }
@@ -23175,11 +22946,11 @@
23175
22946
  keySessionContext.licenseXhr.abort();
23176
22947
  }
23177
22948
  keySessionContext.licenseXhr = xhr;
23178
- _this13.setupLicenseXHR(xhr, url, keySessionContext, licenseChallenge).then(function (_ref8) {
23179
- var xhr = _ref8.xhr,
23180
- licenseChallenge = _ref8.licenseChallenge;
22949
+ _this12.setupLicenseXHR(xhr, url, keySessionContext, licenseChallenge).then(function (_ref7) {
22950
+ var xhr = _ref7.xhr,
22951
+ licenseChallenge = _ref7.licenseChallenge;
23181
22952
  if (keySessionContext.keySystem == KeySystems.PLAYREADY) {
23182
- licenseChallenge = _this13.unpackPlayReadyKeyMessage(xhr, licenseChallenge);
22953
+ licenseChallenge = _this12.unpackPlayReadyKeyMessage(xhr, licenseChallenge);
23183
22954
  }
23184
22955
  xhr.send(licenseChallenge);
23185
22956
  });
@@ -23197,20 +22968,18 @@
23197
22968
 
23198
22969
  // keep reference of media
23199
22970
  this.media = media;
23200
- addEventListener(media, 'encrypted', this.onMediaEncrypted);
23201
22971
  addEventListener(media, 'waitingforkey', this.onWaitingForKey);
23202
22972
  };
23203
22973
  _proto.onMediaDetached = function onMediaDetached() {
23204
22974
  var media = this.media;
23205
22975
  if (media) {
23206
- removeEventListener(media, 'encrypted', this.onMediaEncrypted);
23207
22976
  removeEventListener(media, 'waitingforkey', this.onWaitingForKey);
23208
22977
  this.media = null;
23209
22978
  this.mediaKeys = null;
23210
22979
  }
23211
22980
  };
23212
22981
  _proto._clear = function _clear() {
23213
- var _this14 = this,
22982
+ var _this13 = this,
23214
22983
  _media$setMediaKeys;
23215
22984
  this._requestLicenseFailureCount = 0;
23216
22985
  this.keyIdToKeySessionPromise = {};
@@ -23226,20 +22995,20 @@
23226
22995
  // Close all sessions and remove media keys from the video element.
23227
22996
  var keySessionCount = mediaKeysList.length;
23228
22997
  EMEController.CDMCleanupPromise = Promise.all(mediaKeysList.map(function (mediaKeySessionContext) {
23229
- return _this14.removeSession(mediaKeySessionContext);
22998
+ return _this13.removeSession(mediaKeySessionContext);
23230
22999
  }).concat(media == null ? void 0 : (_media$setMediaKeys = media.setMediaKeys(null)) == null ? void 0 : _media$setMediaKeys.catch(function (error) {
23231
- var _this14$hls;
23232
- _this14.log("Could not clear media keys: " + error);
23233
- (_this14$hls = _this14.hls) == null ? void 0 : _this14$hls.trigger(Events.ERROR, {
23000
+ var _this13$hls;
23001
+ _this13.log("Could not clear media keys: " + error);
23002
+ (_this13$hls = _this13.hls) == null ? void 0 : _this13$hls.trigger(Events.ERROR, {
23234
23003
  type: ErrorTypes.OTHER_ERROR,
23235
23004
  details: ErrorDetails.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,
23236
23005
  fatal: false,
23237
23006
  error: new Error("Could not clear media keys: " + error)
23238
23007
  });
23239
23008
  }))).catch(function (error) {
23240
- var _this14$hls2;
23241
- _this14.log("Could not close sessions and clear media keys: " + error);
23242
- (_this14$hls2 = _this14.hls) == null ? void 0 : _this14$hls2.trigger(Events.ERROR, {
23009
+ var _this13$hls2;
23010
+ _this13.log("Could not close sessions and clear media keys: " + error);
23011
+ (_this13$hls2 = _this13.hls) == null ? void 0 : _this13$hls2.trigger(Events.ERROR, {
23243
23012
  type: ErrorTypes.OTHER_ERROR,
23244
23013
  details: ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,
23245
23014
  fatal: false,
@@ -23247,15 +23016,15 @@
23247
23016
  });
23248
23017
  }).then(function () {
23249
23018
  if (keySessionCount) {
23250
- _this14.log('finished closing key sessions and clearing media keys');
23019
+ _this13.log('finished closing key sessions and clearing media keys');
23251
23020
  }
23252
23021
  });
23253
23022
  };
23254
23023
  _proto.onManifestLoading = function onManifestLoading() {
23255
23024
  this.keyFormatPromise = null;
23256
23025
  };
23257
- _proto.onManifestLoaded = function onManifestLoaded(event, _ref9) {
23258
- var sessionKeys = _ref9.sessionKeys;
23026
+ _proto.onManifestLoaded = function onManifestLoaded(event, _ref8) {
23027
+ var sessionKeys = _ref8.sessionKeys;
23259
23028
  if (!sessionKeys || !this.config.emeEnabled) {
23260
23029
  return;
23261
23030
  }
@@ -23271,7 +23040,7 @@
23271
23040
  }
23272
23041
  };
23273
23042
  _proto.removeSession = function removeSession(mediaKeySessionContext) {
23274
- var _this15 = this;
23043
+ var _this14 = this;
23275
23044
  var mediaKeysSession = mediaKeySessionContext.mediaKeysSession,
23276
23045
  licenseXhr = mediaKeySessionContext.licenseXhr;
23277
23046
  if (mediaKeysSession) {
@@ -23300,9 +23069,9 @@
23300
23069
  mediaKeysSession.remove().then(resolve);
23301
23070
  }) : Promise.resolve();
23302
23071
  return removePromise.catch(function (error) {
23303
- var _this15$hls;
23304
- _this15.log("Could not remove session: " + error);
23305
- (_this15$hls = _this15.hls) == null ? void 0 : _this15$hls.trigger(Events.ERROR, {
23072
+ var _this14$hls;
23073
+ _this14.log("Could not remove session: " + error);
23074
+ (_this14$hls = _this14.hls) == null ? void 0 : _this14$hls.trigger(Events.ERROR, {
23306
23075
  type: ErrorTypes.OTHER_ERROR,
23307
23076
  details: ErrorDetails.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,
23308
23077
  fatal: false,
@@ -23311,9 +23080,9 @@
23311
23080
  }).then(function () {
23312
23081
  return mediaKeysSession.close();
23313
23082
  }).catch(function (error) {
23314
- var _this15$hls2;
23315
- _this15.log("Could not close session: " + error);
23316
- (_this15$hls2 = _this15.hls) == null ? void 0 : _this15$hls2.trigger(Events.ERROR, {
23083
+ var _this14$hls2;
23084
+ _this14.log("Could not close session: " + error);
23085
+ (_this14$hls2 = _this14.hls) == null ? void 0 : _this14$hls2.trigger(Events.ERROR, {
23317
23086
  type: ErrorTypes.OTHER_ERROR,
23318
23087
  details: ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,
23319
23088
  fatal: false,
@@ -23327,13 +23096,13 @@
23327
23096
  EMEController.CDMCleanupPromise = void 0;
23328
23097
  var EMEKeyError = /*#__PURE__*/function (_Error) {
23329
23098
  function EMEKeyError(data, message) {
23330
- var _this16;
23331
- _this16 = _Error.call(this, message) || this;
23332
- _this16.data = void 0;
23099
+ var _this15;
23100
+ _this15 = _Error.call(this, message) || this;
23101
+ _this15.data = void 0;
23333
23102
  data.error || (data.error = new Error(message));
23334
- _this16.data = data;
23103
+ _this15.data = data;
23335
23104
  data.err = data.error;
23336
- return _this16;
23105
+ return _this15;
23337
23106
  }
23338
23107
  _inheritsLoose(EMEKeyError, _Error);
23339
23108
  return EMEKeyError;
@@ -32184,9 +31953,6 @@
32184
31953
  }
32185
31954
  return Number.POSITIVE_INFINITY;
32186
31955
  }();
32187
- function hexToArrayBuffer(str) {
32188
- return Uint8Array.from(str.replace(/^0x/, '').replace(/([\da-fA-F]{2}) ?/g, '0x$1 ').replace(/ +$/, '').split(' ')).buffer;
32189
- }
32190
31956
  var ID3TrackController = /*#__PURE__*/function () {
32191
31957
  function ID3TrackController(hls) {
32192
31958
  var _this = this;
@@ -34756,7 +34522,8 @@
34756
34522
  _ret = _loop();
34757
34523
  if (_ret) return _ret.v;
34758
34524
  }
34759
- } else if (this.config.requireKeySystemAccessOnStart) {
34525
+ }
34526
+ if (this.config.requireKeySystemAccessOnStart) {
34760
34527
  var keySystemsInConfig = getKeySystemsForConfig(this.config);
34761
34528
  if (keySystemsInConfig.length) {
34762
34529
  return this.emeController.getKeySystemAccess(keySystemsInConfig);