rx-player 3.27.0-dev.20220317 → 3.27.0-dev.2022032800

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.
Files changed (134) hide show
  1. package/.eslintrc.js +0 -4
  2. package/CHANGELOG.md +5 -2
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/eme/close_session.js +1 -2
  5. package/dist/_esm5.processed/compat/eme/custom_key_system_access.d.ts +15 -0
  6. package/dist/_esm5.processed/compat/eme/custom_key_system_access.js +1 -17
  7. package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.js +6 -7
  8. package/dist/_esm5.processed/compat/eme/custom_media_keys/index.js +3 -4
  9. package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.js +20 -17
  10. package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.js +29 -14
  11. package/dist/_esm5.processed/compat/eme/generate_key_request.d.ts +4 -6
  12. package/dist/_esm5.processed/compat/eme/generate_key_request.js +4 -6
  13. package/dist/_esm5.processed/compat/eme/load_session.js +1 -2
  14. package/dist/_esm5.processed/config.d.ts +0 -3
  15. package/dist/_esm5.processed/core/api/option_utils.d.ts +3 -2
  16. package/dist/_esm5.processed/core/api/option_utils.js +2 -1
  17. package/dist/_esm5.processed/core/api/public_api.js +3 -4
  18. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +1 -2
  19. package/dist/_esm5.processed/core/decrypt/clear_on_stop.js +1 -2
  20. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +12 -5
  21. package/dist/_esm5.processed/core/decrypt/create_or_load_session.js +1 -1
  22. package/dist/_esm5.processed/core/decrypt/create_session.d.ts +3 -1
  23. package/dist/_esm5.processed/core/decrypt/create_session.js +16 -7
  24. package/dist/_esm5.processed/core/decrypt/find_key_system.js +1 -2
  25. package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +1 -2
  26. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.d.ts +94 -1
  27. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +238 -98
  28. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +1 -3
  29. package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +2 -3
  30. package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +2 -1
  31. package/dist/_esm5.processed/core/stream/index.d.ts +1 -0
  32. package/dist/_esm5.processed/core/stream/period/get_adaptation_switch_strategy.d.ts +15 -11
  33. package/dist/_esm5.processed/core/stream/period/get_adaptation_switch_strategy.js +5 -2
  34. package/dist/_esm5.processed/core/stream/period/index.d.ts +1 -0
  35. package/dist/_esm5.processed/core/stream/period/period_stream.d.ts +3 -11
  36. package/dist/_esm5.processed/core/stream/representation/append_segment_to_buffer.js +4 -3
  37. package/dist/_esm5.processed/default_config.d.ts +0 -27
  38. package/dist/_esm5.processed/default_config.js +0 -27
  39. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.js +5 -6
  40. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/index.js +2 -3
  41. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +15 -0
  42. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +1 -2
  43. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +2 -3
  44. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +2 -3
  45. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +1 -2
  46. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +1 -2
  47. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.js +1 -2
  48. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +1 -2
  49. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +4 -5
  50. package/dist/_esm5.processed/public_types.d.ts +1 -0
  51. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +1 -2
  52. package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +4 -3
  53. package/dist/_esm5.processed/transports/dash/image_pipelines.js +57 -11
  54. package/dist/_esm5.processed/transports/dash/init_segment_loader.js +1 -2
  55. package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -3
  56. package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +1 -1
  57. package/dist/_esm5.processed/transports/dash/segment_loader.js +3 -4
  58. package/dist/_esm5.processed/transports/dash/text_loader.js +1 -2
  59. package/dist/_esm5.processed/transports/local/segment_loader.js +2 -3
  60. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +2 -3
  61. package/dist/_esm5.processed/transports/smooth/pipelines.js +3 -4
  62. package/dist/_esm5.processed/transports/smooth/segment_loader.js +3 -4
  63. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +1 -2
  64. package/dist/_esm5.processed/utils/cancellable_sleep.js +1 -2
  65. package/dist/_esm5.processed/utils/cast_to_observable.js +1 -3
  66. package/dist/_esm5.processed/utils/request/xhr.js +1 -2
  67. package/dist/rx-player.js +851 -937
  68. package/dist/rx-player.min.js +1 -1
  69. package/package.json +1 -2
  70. package/scripts/update-version +2 -2
  71. package/sonar-project.properties +1 -1
  72. package/src/compat/__tests__/play.test.ts +2 -4
  73. package/src/compat/eme/close_session.ts +1 -2
  74. package/src/compat/eme/custom_key_system_access.ts +1 -2
  75. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +6 -7
  76. package/src/compat/eme/custom_media_keys/index.ts +3 -4
  77. package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +21 -18
  78. package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +28 -16
  79. package/src/compat/eme/generate_key_request.ts +4 -6
  80. package/src/compat/eme/load_session.ts +1 -2
  81. package/src/core/api/__tests__/option_utils.test.ts +12 -0
  82. package/src/core/api/option_utils.ts +5 -3
  83. package/src/core/api/public_api.ts +3 -4
  84. package/src/core/decrypt/attach_media_keys.ts +1 -2
  85. package/src/core/decrypt/clear_on_stop.ts +1 -2
  86. package/src/core/decrypt/content_decryptor.ts +16 -6
  87. package/src/core/decrypt/create_or_load_session.ts +4 -1
  88. package/src/core/decrypt/create_session.ts +25 -12
  89. package/src/core/decrypt/find_key_system.ts +1 -2
  90. package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +1 -2
  91. package/src/core/decrypt/utils/loaded_sessions_store.ts +256 -105
  92. package/src/core/fetchers/manifest/manifest_fetcher.ts +1 -3
  93. package/src/core/fetchers/utils/try_urls_with_backoff.ts +2 -3
  94. package/src/core/init/initialize_media_source.ts +2 -1
  95. package/src/core/stream/index.ts +1 -0
  96. package/src/core/stream/period/get_adaptation_switch_strategy.ts +24 -14
  97. package/src/core/stream/period/index.ts +1 -0
  98. package/src/core/stream/period/period_stream.ts +5 -14
  99. package/src/core/stream/representation/append_segment_to_buffer.ts +17 -13
  100. package/src/default_config.ts +0 -30
  101. package/src/experimental/tools/VideoThumbnailLoader/thumbnail_loader.ts +5 -6
  102. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +5 -6
  103. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/decodingInfos.test.ts +2 -4
  104. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +2 -3
  105. package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +1 -2
  106. package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +2 -3
  107. package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +2 -3
  108. package/src/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.ts +1 -2
  109. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +1 -2
  110. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.ts +1 -2
  111. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.ts +1 -2
  112. package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +4 -5
  113. package/src/public_types.ts +1 -0
  114. package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +1 -2
  115. package/src/transports/dash/image_pipelines.ts +12 -14
  116. package/src/transports/dash/init_segment_loader.ts +1 -2
  117. package/src/transports/dash/manifest_parser.ts +2 -3
  118. package/src/transports/dash/segment_loader.ts +4 -5
  119. package/src/transports/dash/text_loader.ts +2 -3
  120. package/src/transports/local/segment_loader.ts +2 -3
  121. package/src/transports/metaplaylist/pipelines.ts +2 -3
  122. package/src/transports/smooth/pipelines.ts +4 -5
  123. package/src/transports/smooth/segment_loader.ts +5 -6
  124. package/src/transports/utils/call_custom_manifest_loader.ts +1 -2
  125. package/src/utils/cancellable_sleep.ts +1 -2
  126. package/src/utils/cast_to_observable.ts +0 -2
  127. package/src/utils/request/xhr.ts +1 -2
  128. package/tsconfig.json +0 -1
  129. package/tsconfig.modules.json +0 -1
  130. package/dist/_esm5.processed/utils/promise.d.ts +0 -17
  131. package/dist/_esm5.processed/utils/promise.js +0 -18
  132. package/src/typings/pinkie.d.ts +0 -19
  133. package/src/utils/__tests__/promise.test.ts +0 -23
  134. package/src/utils/promise.ts +0 -20
package/.eslintrc.js CHANGED
@@ -350,10 +350,6 @@ module.exports = {
350
350
  "property": "substr",
351
351
  "message": "Please use `substring` instead.",
352
352
  },
353
- {
354
- "object": "Promise",
355
- "message": "Not available in IE11, use promise ponyfill instead",
356
- }
357
353
  ],
358
354
  "quote-props": [
359
355
  "error",
package/CHANGELOG.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## v3.27.0-dev.2022031700 (2022-03-17)
3
+ ## v3.27.0-dev.2022032800 (2022-03-28)
4
4
 
5
5
  ### Features
6
6
 
7
7
  - Add a `maxVideoBufferSize` constructor option and `{get,set}MaxVideoBufferSize` methods to limit the size of loaded video data buffered at the same time [#1041, #1054]
8
8
  - DRM: Add a `"periods"` mode to the `keySystems[].singleLicensePer` `loadVideo` option, allowing to obtain decryption license for groups of Periods allowing a compromise between optimization, features and compatibility [#1028, #1061]
9
+ - Add a `"reload"` `audioTrackSwitchingMode` to work-around rare compatibility issues when switching audio tracks [#1089]
9
10
 
10
11
  ### Bug fixes
11
12
 
@@ -18,6 +19,7 @@
18
19
  - avoid unnecessary warning logs when loading some initialization segments [#1049]
19
20
  - TypeScript: Add forgotten TypeScript types in the exposed segment and manifest loader APIs [#1057]
20
21
  - DRM: Avoid decryption issues when a license is persisted in a `singleLicensePer` `"init-data"` mode but loaded in a `"content"` mode [#1031, #1042]
22
+ - DRM: Totally avoid the theoretical possibility of leaking MediaKeySessions when a `generateRequest` or `load` call takes multiple seconds [#1093]
21
23
 
22
24
  ### Other improvements
23
25
 
@@ -25,9 +27,10 @@
25
27
  - add better buffer cleaning logic on a browser's `QuotaExceededError` to better handle memory limitations [#1065]
26
28
  - DASH: Prioritize selectionPriority attribute over a "main" Role when ordering AdaptationSets [#1082]
27
29
  - directfile/Safari: use the `getStartDate` method in `getWallClockTime` when available to obtain true offseted times when playing HLS contents on Safari [#1055]
28
- - avoid mistakenly relying on pinkie's Promise implementation when a native one is already available [#1058]
29
30
  - DRM: Improve DRM Session caches performance when `singleLicensePer` is set to `"content"`
31
+ - DRM: Stop retrying closing MediaKeySessions multiple times when it fails, instead doing it only once when it should work [#1093]
30
32
  - TypeScript: Add IBitrateEstimate, IPositionUpdate and IPlayerState types to the exported types [#1084]
33
+ - Remove dependency on pinkie's promise ponyfill [#1058, #1090]
31
34
  - tests: add performance tests, to better catch and avoid performance regressions [#1053, #1062]
32
35
  - DRM: Refactor DRM logic for better maintainability. DRM-linked logs are now prefixed by `DRM:` instead of `EME:` like previously [#1042]
33
36
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 3.27.0-dev.2022031700
1
+ 3.27.0-dev.2022032800
@@ -51,7 +51,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
51
51
  };
52
52
  import log from "../../log";
53
53
  import cancellableSleep from "../../utils/cancellable_sleep";
54
- import PPromise from "../../utils/promise";
55
54
  import TaskCanceller, { CancellationError, } from "../../utils/task_canceller";
56
55
  /**
57
56
  * Close the given `MediaKeySession` and returns a Promise resolving when the
@@ -68,7 +67,7 @@ import TaskCanceller, { CancellationError, } from "../../utils/task_canceller";
68
67
  */
69
68
  export default function closeSession(session) {
70
69
  var timeoutCanceller = new TaskCanceller();
71
- return PPromise.race([
70
+ return Promise.race([
72
71
  session.close()
73
72
  .then(function () { timeoutCanceller.cancel(); }),
74
73
  // The `closed` promise may resolve, even if `close()` result has not
@@ -1,3 +1,18 @@
1
+ /**
2
+ * Copyright 2015 CANAL+ Group
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import { ICustomMediaKeys } from "./custom_media_keys";
2
17
  export interface ICustomMediaKeySystemAccess {
3
18
  readonly keySystem: string;
@@ -1,19 +1,3 @@
1
- /**
2
- * Copyright 2015 CANAL+ Group
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import PPromise from "../../utils/promise";
17
1
  /**
18
2
  * Simple implementation of the MediaKeySystemAccess EME API.
19
3
  *
@@ -50,7 +34,7 @@ var CustomMediaKeySystemAccess = /** @class */ (function () {
50
34
  */
51
35
  CustomMediaKeySystemAccess.prototype.createMediaKeys = function () {
52
36
  var _this = this;
53
- return new PPromise(function (res) { return res(_this._mediaKeys); });
37
+ return new Promise(function (res) { return res(_this._mediaKeys); });
54
38
  };
55
39
  /**
56
40
  * @returns {Object} - Configuration accepted for this MediaKeySystemAccess.
@@ -30,7 +30,6 @@ var __extends = (this && this.__extends) || (function () {
30
30
  })();
31
31
  import { merge as observableMerge, Subject, takeUntil, } from "rxjs";
32
32
  import EventEmitter from "../../../utils/event_emitter";
33
- import PPromise from "../../../utils/promise";
34
33
  import * as events from "../../event_listeners";
35
34
  import { MSMediaKeysConstructor, } from "./ms_media_keys_constructor";
36
35
  var IE11MediaKeySession = /** @class */ (function (_super) {
@@ -41,11 +40,11 @@ var IE11MediaKeySession = /** @class */ (function (_super) {
41
40
  _this.keyStatuses = new Map();
42
41
  _this._mk = mk;
43
42
  _this._closeSession$ = new Subject();
44
- _this.closed = new PPromise(function (resolve) {
43
+ _this.closed = new Promise(function (resolve) {
45
44
  _this._closeSession$.subscribe(resolve);
46
45
  });
47
46
  _this.update = function (license) {
48
- return new PPromise(function (resolve, reject) {
47
+ return new Promise(function (resolve, reject) {
49
48
  if (_this._ss === undefined) {
50
49
  return reject("MediaKeySession not set.");
51
50
  }
@@ -61,7 +60,7 @@ var IE11MediaKeySession = /** @class */ (function (_super) {
61
60
  }
62
61
  IE11MediaKeySession.prototype.generateRequest = function (_initDataType, initData) {
63
62
  var _this = this;
64
- return new PPromise(function (resolve) {
63
+ return new Promise(function (resolve) {
65
64
  var initDataU8 = initData instanceof Uint8Array ? initData :
66
65
  initData instanceof ArrayBuffer ? new Uint8Array(initData) :
67
66
  new Uint8Array(initData.buffer);
@@ -73,7 +72,7 @@ var IE11MediaKeySession = /** @class */ (function (_super) {
73
72
  };
74
73
  IE11MediaKeySession.prototype.close = function () {
75
74
  var _this = this;
76
- return new PPromise(function (resolve) {
75
+ return new Promise(function (resolve) {
77
76
  if (_this._ss != null) {
78
77
  _this._ss.close();
79
78
  _this._ss = undefined;
@@ -84,10 +83,10 @@ var IE11MediaKeySession = /** @class */ (function (_super) {
84
83
  });
85
84
  };
86
85
  IE11MediaKeySession.prototype.load = function () {
87
- return PPromise.resolve(false);
86
+ return Promise.resolve(false);
88
87
  };
89
88
  IE11MediaKeySession.prototype.remove = function () {
90
- return PPromise.resolve();
89
+ return Promise.resolve();
91
90
  };
92
91
  Object.defineProperty(IE11MediaKeySession.prototype, "sessionId", {
93
92
  get: function () {
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import PPromise from "pinkie";
17
16
  import { MediaError } from "../../../errors";
18
17
  import assert from "../../../utils/assert";
19
18
  import { isIE11 } from "../../browser_detection";
@@ -126,7 +125,7 @@ else {
126
125
  }
127
126
  requestMediaKeySystemAccess = function (keyType, keySystemConfigurations) {
128
127
  if (!isTypeSupported_1(keyType)) {
129
- return PPromise.reject(new Error("Unsupported key type"));
128
+ return Promise.reject(new Error("Unsupported key type"));
130
129
  }
131
130
  for (var i = 0; i < keySystemConfigurations.length; i++) {
132
131
  var keySystemConfiguration = keySystemConfigurations[i];
@@ -151,10 +150,10 @@ else {
151
150
  }
152
151
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
153
152
  var customMediaKeys = createCustomMediaKeys_1(keyType);
154
- return PPromise.resolve(new CustomMediaKeySystemAccess(keyType, customMediaKeys, keySystemConfigurationResponse));
153
+ return Promise.resolve(new CustomMediaKeySystemAccess(keyType, customMediaKeys, keySystemConfigurationResponse));
155
154
  }
156
155
  }
157
- return PPromise.reject(new Error("Unsupported configuration"));
156
+ return Promise.reject(new Error("Unsupported configuration"));
158
157
  };
159
158
  }
160
159
  export { requestMediaKeySystemAccess, setMediaKeys, };
@@ -31,7 +31,6 @@ var __extends = (this && this.__extends) || (function () {
31
31
  import { base64ToBytes } from "../../../utils/base64";
32
32
  import EventEmitter from "../../../utils/event_emitter";
33
33
  import noop from "../../../utils/noop";
34
- import PPromise from "../../../utils/promise";
35
34
  import { utf8ToStr } from "../../../utils/string_parsing";
36
35
  /**
37
36
  * Returns true if the given media element has old webkit methods
@@ -57,21 +56,31 @@ var OldWebkitMediaKeySession = /** @class */ (function (_super) {
57
56
  _this._key = keySystem;
58
57
  _this.sessionId = "";
59
58
  _this._closeSession = noop; // Just here to make TypeScript happy
60
- _this.closed = new PPromise(function (resolve) {
61
- _this._closeSession = resolve;
62
- });
63
59
  _this.keyStatuses = new Map();
64
60
  _this.expiration = NaN;
65
- _this._onSessionRelatedEvent = function (evt) {
61
+ var onSessionRelatedEvent = function (evt) {
66
62
  _this.trigger(evt.type, evt);
67
63
  };
64
+ _this.closed = new Promise(function (resolve) {
65
+ _this._closeSession = function () {
66
+ ["keymessage", "message", "keyadded", "ready", "keyerror", "error"]
67
+ .forEach(function (evt) {
68
+ mediaElement.removeEventListener(evt, onSessionRelatedEvent);
69
+ mediaElement.removeEventListener("webkit".concat(evt), onSessionRelatedEvent);
70
+ });
71
+ resolve();
72
+ };
73
+ });
68
74
  ["keymessage", "message", "keyadded", "ready", "keyerror", "error"]
69
- .forEach(function (evt) { return mediaElement.addEventListener(evt, _this._onSessionRelatedEvent); });
75
+ .forEach(function (evt) {
76
+ mediaElement.addEventListener(evt, onSessionRelatedEvent);
77
+ mediaElement.addEventListener("webkit".concat(evt), onSessionRelatedEvent);
78
+ });
70
79
  return _this;
71
80
  }
72
81
  OldWebkitMediaKeySession.prototype.update = function (license) {
73
82
  var _this = this;
74
- return new PPromise(function (resolve, reject) {
83
+ return new Promise(function (resolve, reject) {
75
84
  try {
76
85
  if (_this._key.indexOf("clearkey") >= 0) {
77
86
  var licenseTypedArray = license instanceof ArrayBuffer ? new Uint8Array(license) :
@@ -98,15 +107,14 @@ var OldWebkitMediaKeySession = /** @class */ (function (_super) {
98
107
  };
99
108
  OldWebkitMediaKeySession.prototype.generateRequest = function (_initDataType, initData) {
100
109
  var _this = this;
101
- return new PPromise(function (resolve) {
110
+ return new Promise(function (resolve) {
102
111
  _this._vid.webkitGenerateKeyRequest(_this._key, initData);
103
112
  resolve();
104
113
  });
105
114
  };
106
115
  OldWebkitMediaKeySession.prototype.close = function () {
107
116
  var _this = this;
108
- return new PPromise(function (resolve) {
109
- _this._unbindSession();
117
+ return new Promise(function (resolve) {
110
118
  _this._closeSession();
111
119
  resolve();
112
120
  });
@@ -118,15 +126,10 @@ var OldWebkitMediaKeySession = /** @class */ (function (_super) {
118
126
  */
119
127
  OldWebkitMediaKeySession.prototype.load = function () {
120
128
  // Not implemented. Always return false as in "no session with that id".
121
- return PPromise.resolve(false);
129
+ return Promise.resolve(false);
122
130
  };
123
131
  OldWebkitMediaKeySession.prototype.remove = function () {
124
- return PPromise.resolve();
125
- };
126
- OldWebkitMediaKeySession.prototype._unbindSession = function () {
127
- var _this = this;
128
- ["keymessage", "message", "keyadded", "ready", "keyerror", "error"]
129
- .forEach(function (evt) { return _this._vid.removeEventListener(evt, _this._onSessionRelatedEvent); });
132
+ return Promise.resolve();
130
133
  };
131
134
  return OldWebkitMediaKeySession;
132
135
  }(EventEmitter));
@@ -30,7 +30,6 @@ var __extends = (this && this.__extends) || (function () {
30
30
  })();
31
31
  import EventEmitter from "../../../utils/event_emitter";
32
32
  import noop from "../../../utils/noop";
33
- import PPromise from "../../../utils/promise";
34
33
  import getWebKitFairplayInitData from "../get_webkit_fairplay_initdata";
35
34
  import { WebKitMediaKeysConstructor, } from "./webkit_media_keys_constructor";
36
35
  /**
@@ -77,19 +76,16 @@ var WebkitMediaKeySession = /** @class */ (function (_super) {
77
76
  _this._keyType = keyType;
78
77
  _this._unbindSession = noop;
79
78
  _this._closeSession = noop; // Just here to make TypeScript happy
80
- _this.closed = new PPromise(function (resolve) {
79
+ _this.closed = new Promise(function (resolve) {
81
80
  _this._closeSession = resolve;
82
81
  });
83
82
  _this.keyStatuses = new Map();
84
83
  _this.expiration = NaN;
85
- _this._onEvent = function (evt) {
86
- _this.trigger(evt.type, evt);
87
- };
88
84
  return _this;
89
85
  }
90
86
  WebkitMediaKeySession.prototype.update = function (license) {
91
87
  var _this = this;
92
- return new PPromise(function (resolve, reject) {
88
+ return new Promise(function (resolve, reject) {
93
89
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
94
90
  if (_this._nativeSession === undefined ||
95
91
  _this._nativeSession.update === undefined ||
@@ -97,9 +93,19 @@ var WebkitMediaKeySession = /** @class */ (function (_super) {
97
93
  return reject("Unavailable WebKit key session.");
98
94
  }
99
95
  try {
96
+ var uInt8Arraylicense = void 0;
97
+ if (license instanceof ArrayBuffer) {
98
+ uInt8Arraylicense = new Uint8Array(license);
99
+ }
100
+ else if (license instanceof Uint8Array) {
101
+ uInt8Arraylicense = license;
102
+ }
103
+ else {
104
+ uInt8Arraylicense = new Uint8Array(license.buffer);
105
+ }
100
106
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
101
107
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
102
- resolve(_this._nativeSession.update(license));
108
+ resolve(_this._nativeSession.update(uInt8Arraylicense));
103
109
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
104
110
  }
105
111
  catch (err) {
@@ -110,7 +116,7 @@ var WebkitMediaKeySession = /** @class */ (function (_super) {
110
116
  };
111
117
  WebkitMediaKeySession.prototype.generateRequest = function (_initDataType, initData) {
112
118
  var _this = this;
113
- return new PPromise(function (resolve) {
119
+ return new Promise(function (resolve) {
114
120
  var _a;
115
121
  var elt = _this._videoElement;
116
122
  if (((_a = elt.webkitKeys) === null || _a === void 0 ? void 0 : _a.createSession) === undefined) {
@@ -138,7 +144,7 @@ var WebkitMediaKeySession = /** @class */ (function (_super) {
138
144
  };
139
145
  WebkitMediaKeySession.prototype.close = function () {
140
146
  var _this = this;
141
- return new PPromise(function (resolve, reject) {
147
+ return new Promise(function (resolve, reject) {
142
148
  _this._unbindSession();
143
149
  _this._closeSession();
144
150
  if (_this._nativeSession === undefined) {
@@ -152,10 +158,10 @@ var WebkitMediaKeySession = /** @class */ (function (_super) {
152
158
  });
153
159
  };
154
160
  WebkitMediaKeySession.prototype.load = function () {
155
- return PPromise.resolve(false);
161
+ return Promise.resolve(false);
156
162
  };
157
163
  WebkitMediaKeySession.prototype.remove = function () {
158
- return PPromise.resolve();
164
+ return Promise.resolve();
159
165
  };
160
166
  Object.defineProperty(WebkitMediaKeySession.prototype, "sessionId", {
161
167
  get: function () {
@@ -172,14 +178,23 @@ var WebkitMediaKeySession = /** @class */ (function (_super) {
172
178
  WebkitMediaKeySession.prototype._listenEvent = function (session) {
173
179
  var _this = this;
174
180
  this._unbindSession(); // If previous session was linked
181
+ var onEvent = function (evt) {
182
+ _this.trigger(evt.type, evt);
183
+ };
175
184
  /* eslint-disable @typescript-eslint/no-unsafe-call */
176
185
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
177
186
  /* eslint-disable @typescript-eslint/no-unsafe-return */
178
187
  ["keymessage", "message", "keyadded", "ready", "keyerror", "error"]
179
- .forEach(function (evt) { return session.addEventListener(evt, _this._onEvent); });
188
+ .forEach(function (evt) {
189
+ session.addEventListener(evt, onEvent);
190
+ session.addEventListener("webkit".concat(evt), onEvent);
191
+ });
180
192
  this._unbindSession = function () {
181
193
  ["keymessage", "message", "keyadded", "ready", "keyerror", "error"]
182
- .forEach(function (evt) { return session.removeEventListener(evt, _this._onEvent); });
194
+ .forEach(function (evt) {
195
+ session.removeEventListener(evt, onEvent);
196
+ session.removeEventListener("webkit".concat(evt), onEvent);
197
+ });
183
198
  };
184
199
  /* eslint-disable @typescript-eslint/no-unsafe-return */
185
200
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
@@ -211,7 +226,7 @@ var WebKitCustomMediaKeys = /** @class */ (function () {
211
226
  };
212
227
  WebKitCustomMediaKeys.prototype.setServerCertificate = function (serverCertificate) {
213
228
  this._serverCertificate = serverCertificate;
214
- return PPromise.resolve();
229
+ return Promise.resolve();
215
230
  };
216
231
  return WebKitCustomMediaKeys;
217
232
  }());
@@ -45,12 +45,10 @@ export declare function patchInitData(initData: Uint8Array): Uint8Array;
45
45
  * Generate a request from session.
46
46
  * @param {MediaKeySession} session - MediaKeySession on which the request will
47
47
  * be done.
48
- * @param {Uint8Array} initData - Initialization data given e.g. by the
49
- * "encrypted" event for the corresponding request.
50
- * @param {string} initDataType - Initialization data type given e.g. by the
51
- * "encrypted" event for the corresponding request.
52
- * @param {string} sessionType - Type of session you want to generate. Consult
53
- * EME Specification for more information on session types.
48
+ * @param {string} initializationDataType - Initialization data type given e.g.
49
+ * by the "encrypted" event for the corresponding request.
50
+ * @param {Uint8Array} initializationData - Initialization data given e.g. by
51
+ * the "encrypted" event for the corresponding request.
54
52
  * @returns {Promise} - Emit when done. Errors if fails.
55
53
  */
56
54
  export default function generateKeyRequest(session: MediaKeySession | ICustomMediaKeySession, initializationDataType: string | undefined, initializationData: Uint8Array): Promise<unknown>;
@@ -114,12 +114,10 @@ export function patchInitData(initData) {
114
114
  * Generate a request from session.
115
115
  * @param {MediaKeySession} session - MediaKeySession on which the request will
116
116
  * be done.
117
- * @param {Uint8Array} initData - Initialization data given e.g. by the
118
- * "encrypted" event for the corresponding request.
119
- * @param {string} initDataType - Initialization data type given e.g. by the
120
- * "encrypted" event for the corresponding request.
121
- * @param {string} sessionType - Type of session you want to generate. Consult
122
- * EME Specification for more information on session types.
117
+ * @param {string} initializationDataType - Initialization data type given e.g.
118
+ * by the "encrypted" event for the corresponding request.
119
+ * @param {Uint8Array} initializationData - Initialization data given e.g. by
120
+ * the "encrypted" event for the corresponding request.
123
121
  * @returns {Promise} - Emit when done. Errors if fails.
124
122
  */
125
123
  export default function generateKeyRequest(session, initializationDataType, initializationData) {
@@ -49,7 +49,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
50
  }
51
51
  };
52
- import PPromise from "pinkie";
53
52
  import log from "../../log";
54
53
  var EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES = 100;
55
54
  /**
@@ -83,7 +82,7 @@ export default function loadSession(session, sessionId) {
83
82
  // Chromium/Chrome versions where the `keyStatuses` property from a loaded
84
83
  // MediaKeySession would not be populated directly as the load answer but
85
84
  // asynchronously after.
86
- return [2 /*return*/, new PPromise(function (resolve) {
85
+ return [2 /*return*/, new Promise(function (resolve) {
87
86
  session.addEventListener("keystatuseschange", resolveWithLoadedStatus);
88
87
  var timeout = setTimeout(resolveWithLoadedStatus, EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES);
89
88
  function resolveWithLoadedStatus() {
@@ -145,9 +145,6 @@ declare class ConfigHandler {
145
145
  DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0: number;
146
146
  EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS: number;
147
147
  EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION: number;
148
- EME_SESSION_CLOSING_MAX_RETRY: number;
149
- EME_SESSION_CLOSING_INITIAL_DELAY: number;
150
- EME_SESSION_CLOSING_MAX_DELAY: number;
151
148
  EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES: number;
152
149
  FORCED_ENDED_THRESHOLD: number;
153
150
  ADAPTATION_SWITCH_BUFFER_PADDINGS: {
@@ -16,6 +16,7 @@
16
16
  import { IRepresentationFilter } from "../../manifest";
17
17
  import { ICustomManifestLoader, ICustomSegmentLoader, ILoadedManifestFormat, ITransportOptions as IParsedTransportOptions } from "../../transports";
18
18
  import { IKeySystemOption } from "../decrypt";
19
+ import { IAudioTrackSwitchingMode } from "../stream";
19
20
  import { IAudioTrackPreference, ITextTrackPreference, IVideoTrackPreference } from "./track_choice_manager";
20
21
  export { IKeySystemOption };
21
22
  /** Value of the `serverSyncInfos` transport option. */
@@ -206,7 +207,7 @@ export interface ILoadVideoOptions {
206
207
  textTrackElement?: HTMLElement;
207
208
  manualBitrateSwitchingMode?: "seamless" | "direct";
208
209
  enableFastSwitching?: boolean;
209
- audioTrackSwitchingMode?: "seamless" | "direct";
210
+ audioTrackSwitchingMode?: IAudioTrackSwitchingMode;
210
211
  onCodecSwitch?: "continue" | "reload";
211
212
  supplementaryTextTracks?: ISupplementaryTextTrackOption[];
212
213
  supplementaryImageTracks?: ISupplementaryImageTrackOption[];
@@ -232,7 +233,7 @@ interface IParsedLoadVideoOptionsBase {
232
233
  startAt: IParsedStartAtOption | undefined;
233
234
  manualBitrateSwitchingMode: "seamless" | "direct";
234
235
  enableFastSwitching: boolean;
235
- audioTrackSwitchingMode: "seamless" | "direct";
236
+ audioTrackSwitchingMode: IAudioTrackSwitchingMode;
236
237
  onCodecSwitch: "continue" | "reload";
237
238
  }
238
239
  /**
@@ -326,11 +326,12 @@ function parseLoadVideoOptions(options) {
326
326
  var audioTrackSwitchingMode = isNullOrUndefined(options.audioTrackSwitchingMode)
327
327
  ? DEFAULT_AUDIO_TRACK_SWITCHING_MODE
328
328
  : options.audioTrackSwitchingMode;
329
- if (!arrayIncludes(["seamless", "direct"], audioTrackSwitchingMode)) {
329
+ if (!arrayIncludes(["seamless", "direct", "reload"], audioTrackSwitchingMode)) {
330
330
  log.warn("The `audioTrackSwitchingMode` loadVideo option must match one of " +
331
331
  "the following strategy name:\n" +
332
332
  "- `seamless`\n" +
333
333
  "- `direct`\n" +
334
+ "- `reload`\n" +
334
335
  "If badly set, " + DEFAULT_AUDIO_TRACK_SWITCHING_MODE +
335
336
  " strategy will be used as default");
336
337
  audioTrackSwitchingMode = DEFAULT_AUDIO_TRACK_SWITCHING_MODE;
@@ -56,7 +56,6 @@ import areArraysOfNumbersEqual from "../../utils/are_arrays_of_numbers_equal";
56
56
  import EventEmitter, { fromEvent, } from "../../utils/event_emitter";
57
57
  import isNullOrUndefined from "../../utils/is_null_or_undefined";
58
58
  import objectAssign from "../../utils/object_assign";
59
- import PPromise from "../../utils/promise";
60
59
  import { getLeftSizeOfRange, getPlayedSizeOfRange, getSizeOfRange, } from "../../utils/ranges";
61
60
  import createSharedReference from "../../utils/reference";
62
61
  import warnOnce from "../../utils/warn_once";
@@ -88,7 +87,7 @@ var Player = /** @class */ (function (_super) {
88
87
  // Workaround to support Firefox autoplay on FF 42.
89
88
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
90
89
  videoElement.preload = "auto";
91
- _this.version = /* PLAYER_VERSION */ "3.27.0-dev.2022031700";
90
+ _this.version = /* PLAYER_VERSION */ "3.27.0-dev.2022032800";
92
91
  _this.log = log;
93
92
  _this.state = "STOPPED";
94
93
  _this.videoElement = videoElement;
@@ -1045,7 +1044,7 @@ var Player = /** @class */ (function (_super) {
1045
1044
  /* eslint-disable @typescript-eslint/unbound-method */
1046
1045
  if (isNullOrUndefined(playPromise) || typeof playPromise.catch !== "function") {
1047
1046
  /* eslint-enable @typescript-eslint/unbound-method */
1048
- return PPromise.resolve();
1047
+ return Promise.resolve();
1049
1048
  }
1050
1049
  return playPromise.catch(function (error) {
1051
1050
  if (error.name === "NotAllowedError") {
@@ -2303,5 +2302,5 @@ var Player = /** @class */ (function (_super) {
2303
2302
  };
2304
2303
  return Player;
2305
2304
  }(EventEmitter));
2306
- Player.version = /* PLAYER_VERSION */ "3.27.0-dev.2022031700";
2305
+ Player.version = /* PLAYER_VERSION */ "3.27.0-dev.2022032800";
2307
2306
  export default Player;
@@ -51,7 +51,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
51
51
  };
52
52
  import { setMediaKeys, } from "../../compat";
53
53
  import log from "../../log";
54
- import PPromise from "../../utils/promise";
55
54
  import MediaKeysInfosStore from "./utils/media_keys_infos_store";
56
55
  /**
57
56
  * Dispose of the MediaKeys instance attached to the given media element, if
@@ -81,7 +80,7 @@ export default function attachMediaKeys(mediaElement, _a, cancelSignal) {
81
80
  closeAllSessions = previousState !== null &&
82
81
  previousState.loadedSessionsStore !== loadedSessionsStore ?
83
82
  previousState.loadedSessionsStore.closeAllSessions() :
84
- PPromise.resolve();
83
+ Promise.resolve();
85
84
  return [4 /*yield*/, closeAllSessions];
86
85
  case 1:
87
86
  _b.sent();
@@ -15,7 +15,6 @@
15
15
  */
16
16
  import { shouldUnsetMediaKeys } from "../../compat/";
17
17
  import log from "../../log";
18
- import PPromise from "../../utils/promise";
19
18
  import disposeDecryptionResources from "./dispose_decryption_resources";
20
19
  import MediaKeysInfosStore from "./utils/media_keys_infos_store";
21
20
  /**
@@ -37,5 +36,5 @@ export default function clearOnStop(mediaElement) {
37
36
  return currentState.loadedSessionsStore.closeAllSessions();
38
37
  }
39
38
  log.info("DRM: Nothing to clear. Returning right away. No state =", currentState === null);
40
- return PPromise.resolve();
39
+ return Promise.resolve();
41
40
  }
@@ -84,8 +84,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
84
84
  }
85
85
  return to.concat(ar || Array.prototype.slice.call(from));
86
86
  };
87
- import PPromise from "pinkie";
88
- import { events, generateKeyRequest, getInitData, } from "../../compat/";
87
+ import { events, getInitData, } from "../../compat/";
89
88
  import config from "../../config";
90
89
  import { EncryptedMediaError, OtherError, } from "../../errors";
91
90
  import log from "../../log";
@@ -319,7 +318,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
319
318
  */
320
319
  ContentDecryptor.prototype._processInitializationData = function (initializationData, mediaKeysData) {
321
320
  return __awaiter(this, void 0, void 0, function () {
322
- var mediaKeySystemAccess, stores, options, firstCreatedSession, keyIds, hexKids, period, createdSessions, periodKeys, _i, createdSessions_1, createdSess, periodKeysArr, _a, periodKeysArr_1, kid, _b, periodKeysArr_2, innerKid, wantedSessionType, _c, EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION, maxSessionCacheSize, sessionRes, sessionInfo, _d, mediaKeySession, sessionType, isSessionPersisted, sub, requestData, error_1;
321
+ var mediaKeySystemAccess, stores, options, firstCreatedSession, keyIds, hexKids, period, createdSessions, periodKeys, _i, createdSessions_1, createdSess, periodKeysArr, _a, periodKeysArr_1, kid, _b, periodKeysArr_2, innerKid, wantedSessionType, _c, EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION, maxSessionCacheSize, sessionRes, sessionInfo, _d, mediaKeySession, sessionType, isSessionPersisted, sub, requestData, error_1, entry, indexInCurrent;
323
322
  var _this = this;
324
323
  return __generator(this, function (_e) {
325
324
  switch (_e.label) {
@@ -487,15 +486,23 @@ var ContentDecryptor = /** @class */ (function (_super) {
487
486
  _e.label = 2;
488
487
  case 2:
489
488
  _e.trys.push([2, 4, , 5]);
490
- return [4 /*yield*/, generateKeyRequest(mediaKeySession, initializationData.type, requestData)];
489
+ return [4 /*yield*/, stores.loadedSessionsStore.generateLicenseRequest(mediaKeySession, initializationData.type, requestData)];
491
490
  case 3:
492
491
  _e.sent();
493
492
  return [3 /*break*/, 5];
494
493
  case 4:
495
494
  error_1 = _e.sent();
495
+ entry = stores.loadedSessionsStore.getEntryForSession(mediaKeySession);
496
+ if (entry === null || entry.closingStatus.type !== "none") {
497
+ indexInCurrent = this._currentSessions.indexOf(sessionInfo);
498
+ if (indexInCurrent >= 0) {
499
+ this._currentSessions.splice(indexInCurrent, 1);
500
+ }
501
+ return [2 /*return*/, Promise.resolve()];
502
+ }
496
503
  throw new EncryptedMediaError("KEY_GENERATE_REQUEST_ERROR", error_1 instanceof Error ? error_1.toString() :
497
504
  "Unknown error");
498
- case 5: return [2 /*return*/, PPromise.resolve()];
505
+ case 5: return [2 /*return*/, Promise.resolve()];
499
506
  }
500
507
  });
501
508
  });
@@ -111,7 +111,7 @@ export default function createOrLoadSession(initializationData, stores, wantedSe
111
111
  if (cancelSignal.cancellationError !== null) {
112
112
  throw cancelSignal.cancellationError; // stop here if cancelled since
113
113
  }
114
- return [4 /*yield*/, createSession(stores, initializationData, wantedSessionType)];
114
+ return [4 /*yield*/, createSession(stores, initializationData, wantedSessionType, cancelSignal)];
115
115
  case 4:
116
116
  evt = _a.sent();
117
117
  return [2 /*return*/, { type: evt.type,