rx-player 4.5.0-dev.2026031700 → 4.5.0-dev.2026033100

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 (222) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  5. package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
  6. package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
  7. package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
  8. package/dist/commonjs/compat/browser_version.d.ts +2 -1
  9. package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
  10. package/dist/commonjs/compat/browser_version.js +13 -0
  11. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  12. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
  13. package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
  14. package/dist/commonjs/compat/is_codec_supported.js +4 -3
  15. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  16. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  17. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
  18. package/dist/commonjs/core/entry/utils.js +3 -3
  19. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  20. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
  21. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  22. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  23. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  24. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
  25. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  26. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
  27. package/dist/commonjs/initialize_worker.js +1 -1
  28. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  29. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  30. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  31. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
  32. package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
  33. package/dist/commonjs/manifest/classes/adaptation.js +3 -1
  34. package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
  35. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  36. package/dist/commonjs/manifest/classes/representation.js +45 -23
  37. package/dist/commonjs/manifest/types.d.ts +14 -6
  38. package/dist/commonjs/manifest/types.d.ts.map +1 -1
  39. package/dist/commonjs/manifest/utils.js +4 -4
  40. package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
  41. package/dist/commonjs/mse/main_media_source_interface.js +3 -2
  42. package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
  43. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
  44. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  45. package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
  46. package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
  47. package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
  48. package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
  49. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  50. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  51. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
  52. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  53. package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
  54. package/dist/commonjs/transports/dash/segment_parser.js +6 -0
  55. package/dist/commonjs/transports/dash/text_parser.d.ts.map +1 -1
  56. package/dist/commonjs/transports/dash/text_parser.js +5 -1
  57. package/dist/commonjs/transports/local/text_parser.d.ts.map +1 -1
  58. package/dist/commonjs/transports/local/text_parser.js +5 -1
  59. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
  60. package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
  61. package/dist/commonjs/transports/smooth/pipelines.js +3 -3
  62. package/dist/commonjs/transports/types.d.ts +28 -2
  63. package/dist/commonjs/transports/types.d.ts.map +1 -1
  64. package/dist/commonjs/transports/utils/parse_text_track.d.ts +9 -2
  65. package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
  66. package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
  67. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  68. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  69. package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
  70. package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
  71. package/dist/es2017/compat/browser_compatibility_types.js +7 -1
  72. package/dist/es2017/compat/browser_version.d.ts +2 -1
  73. package/dist/es2017/compat/browser_version.d.ts.map +1 -1
  74. package/dist/es2017/compat/browser_version.js +13 -1
  75. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  76. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
  77. package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
  78. package/dist/es2017/compat/is_codec_supported.js +2 -1
  79. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  80. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  81. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
  82. package/dist/es2017/core/entry/utils.js +4 -4
  83. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  84. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
  85. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  86. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  87. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  88. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
  89. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  90. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
  91. package/dist/es2017/initialize_worker.js +1 -1
  92. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  93. package/dist/es2017/main_thread/api/public_api.js +2 -2
  94. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  95. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
  96. package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
  97. package/dist/es2017/manifest/classes/adaptation.js +3 -1
  98. package/dist/es2017/manifest/classes/representation.d.ts +6 -2
  99. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  100. package/dist/es2017/manifest/classes/representation.js +45 -23
  101. package/dist/es2017/manifest/types.d.ts +14 -6
  102. package/dist/es2017/manifest/types.d.ts.map +1 -1
  103. package/dist/es2017/manifest/utils.js +4 -4
  104. package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
  105. package/dist/es2017/mse/main_media_source_interface.js +2 -1
  106. package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
  107. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
  108. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  109. package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
  110. package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
  111. package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
  112. package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
  113. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  114. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  115. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
  116. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  117. package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
  118. package/dist/es2017/transports/dash/segment_parser.js +7 -1
  119. package/dist/es2017/transports/dash/text_parser.d.ts.map +1 -1
  120. package/dist/es2017/transports/dash/text_parser.js +5 -1
  121. package/dist/es2017/transports/local/text_parser.d.ts.map +1 -1
  122. package/dist/es2017/transports/local/text_parser.js +5 -1
  123. package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
  124. package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
  125. package/dist/es2017/transports/smooth/pipelines.js +3 -3
  126. package/dist/es2017/transports/types.d.ts +28 -2
  127. package/dist/es2017/transports/types.d.ts.map +1 -1
  128. package/dist/es2017/transports/utils/parse_text_track.d.ts +9 -2
  129. package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
  130. package/dist/es2017/transports/utils/parse_text_track.js +1 -1
  131. package/dist/worker.js +6 -6
  132. package/eslint.config.mjs +1 -14
  133. package/package.json +1 -1
  134. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  135. package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
  136. package/src/compat/__tests__/browser_version.test.ts +57 -18
  137. package/src/compat/__tests__/clear_element_src.test.ts +20 -40
  138. package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
  139. package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
  140. package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
  141. package/src/compat/__tests__/remove_cue.test.ts +8 -20
  142. package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
  143. package/src/compat/browser_compatibility_types.ts +8 -1
  144. package/src/compat/browser_version.ts +17 -1
  145. package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
  146. package/src/compat/is_codec_supported.ts +2 -1
  147. package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
  148. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +68 -28
  149. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
  150. package/src/core/entry/__tests__/utils.test.ts +7 -1
  151. package/src/core/entry/utils.ts +4 -4
  152. package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
  153. package/src/errors/__tests__/format_error.test.ts +23 -24
  154. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
  155. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
  156. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
  157. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
  158. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
  159. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
  160. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
  161. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
  162. package/src/features/__tests__/add_features.test.ts +12 -27
  163. package/src/initialize_worker.ts +1 -1
  164. package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
  165. package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
  166. package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
  167. package/src/main_thread/api/public_api.ts +2 -2
  168. package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
  169. package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
  170. package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
  171. package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
  172. package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
  173. package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
  174. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
  175. package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
  176. package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
  177. package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
  178. package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
  179. package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
  180. package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
  181. package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
  182. package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
  183. package/src/manifest/classes/__tests__/period.test.ts +167 -117
  184. package/src/manifest/classes/__tests__/representation.test.ts +84 -25
  185. package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
  186. package/src/manifest/classes/adaptation.ts +4 -1
  187. package/src/manifest/classes/representation.ts +59 -27
  188. package/src/manifest/types.ts +14 -6
  189. package/src/manifest/utils.ts +4 -4
  190. package/src/mse/__tests__/main_media_source_interface.test.ts +3 -1
  191. package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
  192. package/src/mse/main_media_source_interface.ts +2 -1
  193. package/src/mse/worker_media_source_interface.ts +2 -2
  194. package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
  195. package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
  196. package/src/parsers/containers/isobmff/get_box.ts +17 -0
  197. package/src/parsers/containers/isobmff/index.ts +8 -1
  198. package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
  199. package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
  200. package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
  201. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
  202. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
  203. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
  204. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
  205. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
  206. package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
  207. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
  208. package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
  209. package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
  210. package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
  211. package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
  212. package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
  213. package/src/transports/dash/segment_parser.ts +13 -0
  214. package/src/transports/dash/text_parser.ts +5 -1
  215. package/src/transports/local/text_parser.ts +5 -1
  216. package/src/transports/metaplaylist/pipelines.ts +2 -1
  217. package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
  218. package/src/transports/smooth/pipelines.ts +3 -3
  219. package/src/transports/types.ts +28 -2
  220. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
  221. package/src/transports/utils/parse_text_track.ts +10 -3
  222. package/src/utils/__tests__/object_assign.test.ts +2 -2
@@ -3,7 +3,7 @@ import type { IBufferType } from "../../../core/types";
3
3
  import type { IRepresentationMetadata } from "../../../manifest";
4
4
  import type { IAudioRepresentation, IVideoRepresentation } from "../../../public_types";
5
5
  import TaskCanceller from "../../../utils/task_canceller";
6
- import type IPublicAPI from "../public_api";
6
+ import PublicAPI from "../public_api";
7
7
  import type { IPublicApiContentInfos } from "../public_api";
8
8
 
9
9
  describe("API - Public API", () => {
@@ -13,17 +13,13 @@ describe("API - Public API", () => {
13
13
 
14
14
  describe("static properties", () => {
15
15
  describe("ErrorTypes", () => {
16
- it("should expose static ErrorTypes property", async () => {
17
- const PublicAPI = (await vi.importActual("../public_api"))
18
- .default as typeof IPublicAPI;
16
+ it("should expose static ErrorTypes property", () => {
19
17
  expect(typeof PublicAPI.ErrorTypes).toBe("object");
20
18
  });
21
19
  });
22
20
 
23
21
  describe("ErrorCodes", () => {
24
- it("should expose static ErrorCodes property", async () => {
25
- const PublicAPI = (await vi.importActual("../public_api"))
26
- .default as typeof IPublicAPI;
22
+ it("should expose static ErrorCodes property", () => {
27
23
  expect(typeof PublicAPI.ErrorTypes).toBe("object");
28
24
  });
29
25
  });
@@ -31,45 +27,35 @@ describe("API - Public API", () => {
31
27
 
32
28
  describe("public methods", () => {
33
29
  describe("getError", () => {
34
- it("should have no error by default", async () => {
35
- const PublicAPI = (await vi.importActual("../public_api"))
36
- .default as typeof IPublicAPI;
30
+ it("should have no error by default", () => {
37
31
  const player = new PublicAPI();
38
32
  expect(player.getError()).toBe(null);
39
33
  });
40
34
  });
41
35
 
42
36
  describe("getPlayerState", () => {
43
- it('should return "STOPPED" in getPlayerState by default', async () => {
44
- const PublicAPI = (await vi.importActual("../public_api"))
45
- .default as typeof IPublicAPI;
37
+ it('should return "STOPPED" in getPlayerState by default', () => {
46
38
  const player = new PublicAPI();
47
39
  expect(player.getPlayerState()).toBe("STOPPED");
48
40
  });
49
41
  });
50
42
 
51
43
  describe("isLive", () => {
52
- it("should return false in isLive by default", async () => {
53
- const PublicAPI = (await vi.importActual("../public_api"))
54
- .default as typeof IPublicAPI;
44
+ it("should return false in isLive by default", () => {
55
45
  const player = new PublicAPI();
56
46
  expect(player.isLive()).toBe(false);
57
47
  });
58
48
  });
59
49
 
60
50
  describe("getContentUrls", () => {
61
- it("should return undefined in getContentUrls by default", async () => {
62
- const PublicAPI = (await vi.importActual("../public_api"))
63
- .default as typeof IPublicAPI;
51
+ it("should return undefined in getContentUrls by default", () => {
64
52
  const player = new PublicAPI();
65
53
  expect(player.getContentUrls()).toBe(undefined);
66
54
  });
67
55
  });
68
56
 
69
57
  describe("getMediaDuration", () => {
70
- it("should return the video element initial duration in getMediaDuration by default", async () => {
71
- const PublicAPI = (await vi.importActual("../public_api"))
72
- .default as typeof IPublicAPI;
58
+ it("should return the video element initial duration in getMediaDuration by default", () => {
73
59
  const player = new PublicAPI();
74
60
 
75
61
  // ! HAHA ! NaN is not === to NaN
@@ -82,59 +68,48 @@ describe("API - Public API", () => {
82
68
  });
83
69
 
84
70
  describe("getCurrentBufferGap", () => {
85
- it("should return 0 in getCurrentBufferGap by default", async () => {
86
- const PublicAPI = (await vi.importActual("../public_api"))
87
- .default as typeof IPublicAPI;
71
+ it("should return 0 in getCurrentBufferGap by default", () => {
88
72
  const player = new PublicAPI();
89
73
  expect(player.getCurrentBufferGap()).toBe(0);
90
74
  });
91
75
  });
92
76
 
93
77
  describe("getWallClockTime", () => {
94
- it("should return 0 in getWallClockTime by default", async () => {
95
- const PublicAPI = (await vi.importActual("../public_api"))
96
- .default as typeof IPublicAPI;
78
+ it("should return 0 in getWallClockTime by default", () => {
97
79
  const player = new PublicAPI();
98
80
  expect(player.getWallClockTime()).toBe(0);
99
81
  });
100
82
  });
101
83
 
102
84
  describe("getPosition", () => {
103
- it("should return 0 in getPosition by default", async () => {
104
- const PublicAPI = (await vi.importActual("../public_api"))
105
- .default as typeof IPublicAPI;
85
+ it("should return 0 in getPosition by default", () => {
106
86
  const player = new PublicAPI();
107
87
  expect(player.getPosition()).toBe(0);
108
88
  });
109
89
  });
110
90
 
111
91
  describe("getPlaybackRate", () => {
112
- it("should return 1 in getPlaybackRate by default", async () => {
113
- const PublicAPI = (await vi.importActual("../public_api"))
114
- .default as typeof IPublicAPI;
92
+ it("should return 1 in getPlaybackRate by default", () => {
115
93
  const player = new PublicAPI();
116
94
  expect(player.getPlaybackRate()).toBe(1);
117
95
  });
118
96
  });
119
97
 
120
98
  describe("getVolume", () => {
121
- it("should return 1 in getVolume by default", async () => {
122
- const PublicAPI = (await vi.importActual("../public_api"))
123
- .default as typeof IPublicAPI;
99
+ it("should return 1 in getVolume by default", () => {
124
100
  const player = new PublicAPI();
125
101
  expect(player.getVolume()).toBe(1);
126
102
  });
127
103
  });
128
104
 
129
105
  describe("getVideoRepresentation", () => {
130
- let player: IPublicAPI;
106
+ let player: PublicAPI;
131
107
  beforeEach(async () => {
132
- const PublicAPI = (await vi.importActual("../public_api"))
133
- .default as typeof IPublicAPI;
134
108
  player = new PublicAPI();
135
109
  });
136
110
 
137
- it("should return undefined in getVideoRepresentation by default", async () => {
111
+ it("should return undefined in getVideoRepresentation by default", () => {
112
+ player = new PublicAPI();
138
113
  expect(player.getVideoRepresentation()).toBe(undefined);
139
114
  });
140
115
 
@@ -145,7 +120,8 @@ describe("API - Public API", () => {
145
120
  video: {
146
121
  id: "1",
147
122
  bitrate: 1000,
148
- codecs: ["avc1"],
123
+ baseCodecs: ["avc1"],
124
+ chosenCodec: "avc1",
149
125
  uniqueId: "unique1",
150
126
  isSupported: true,
151
127
  },
@@ -163,15 +139,14 @@ describe("API - Public API", () => {
163
139
  });
164
140
 
165
141
  describe("getAudioRepresentation", () => {
166
- let player: IPublicAPI;
142
+ let player: PublicAPI;
167
143
 
168
144
  beforeEach(async () => {
169
- const PublicAPI = (await vi.importActual("../public_api"))
170
- .default as typeof IPublicAPI;
171
145
  player = new PublicAPI();
172
146
  });
173
147
 
174
148
  it("should return undefined in getAudioRepresentation by default", async () => {
149
+ player = new PublicAPI();
175
150
  expect(player.getAudioRepresentation()).toBe(undefined);
176
151
  });
177
152
  it("should return the audio representation if available", () => {
@@ -181,7 +156,8 @@ describe("API - Public API", () => {
181
156
  audio: {
182
157
  id: "2",
183
158
  bitrate: 1000,
184
- codecs: ["mp4a"],
159
+ baseCodecs: ["mp4a"],
160
+ chosenCodec: "mp4a",
185
161
  uniqueId: "unique2",
186
162
  isSupported: true,
187
163
  },
@@ -199,36 +175,28 @@ describe("API - Public API", () => {
199
175
  });
200
176
 
201
177
  describe("getWantedBufferAhead", () => {
202
- it("should return 30 in getWantedBufferAhead by default", async () => {
203
- const PublicAPI = (await vi.importActual("../public_api"))
204
- .default as typeof IPublicAPI;
178
+ it("should return 30 in getWantedBufferAhead by default", () => {
205
179
  const player = new PublicAPI();
206
180
  expect(player.getWantedBufferAhead()).toBe(30);
207
181
  });
208
182
  });
209
183
 
210
184
  describe("getMaxBufferBehind", () => {
211
- it("should return Infinity in getMaxBufferBehind by default", async () => {
212
- const PublicAPI = (await vi.importActual("../public_api"))
213
- .default as typeof IPublicAPI;
185
+ it("should return Infinity in getMaxBufferBehind by default", () => {
214
186
  const player = new PublicAPI();
215
187
  expect(player.getMaxBufferBehind()).toBe(Infinity);
216
188
  });
217
189
  });
218
190
 
219
191
  describe("getMaxBufferAhead", () => {
220
- it("should return Infinity in getMaxBufferAhead by default", async () => {
221
- const PublicAPI = (await vi.importActual("../public_api"))
222
- .default as typeof IPublicAPI;
192
+ it("should return Infinity in getMaxBufferAhead by default", () => {
223
193
  const player = new PublicAPI();
224
194
  expect(player.getMaxBufferAhead()).toBe(Infinity);
225
195
  });
226
196
  });
227
197
 
228
198
  describe("getPlaybackRate/setPlaybackRate", () => {
229
- it("should allow to change the playback rate through setPlaybackRate", async () => {
230
- const PublicAPI = (await vi.importActual("../public_api"))
231
- .default as typeof IPublicAPI;
199
+ it("should allow to change the playback rate through setPlaybackRate", () => {
232
200
  const player = new PublicAPI();
233
201
  player.setPlaybackRate(4);
234
202
  expect(player.getPlaybackRate()).toBe(4);
@@ -251,9 +219,7 @@ describe("API - Public API", () => {
251
219
  });
252
220
 
253
221
  describe("seekTo", () => {
254
- it("should throw in seekTo by default", async () => {
255
- const PublicAPI = (await vi.importActual("../public_api"))
256
- .default as typeof IPublicAPI;
222
+ it("should throw in seekTo by default", () => {
257
223
  const player = new PublicAPI();
258
224
  expect(() => player.seekTo(10)).toThrow();
259
225
  expect(() => player.seekTo(54)).toThrow();
@@ -264,16 +230,12 @@ describe("API - Public API", () => {
264
230
  });
265
231
 
266
232
  describe("getVolume/setVolume", () => {
267
- it("should throw in setVolume by default if no volume has been given", async () => {
268
- const PublicAPI = (await vi.importActual("../public_api"))
269
- .default as typeof IPublicAPI;
233
+ it("should throw in setVolume by default if no volume has been given", () => {
270
234
  const player = new PublicAPI();
271
235
  expect(() => player.setVolume(5)).toThrow();
272
236
  });
273
237
 
274
- it("should set the volume in setVolume by default if a volume has been given", async () => {
275
- const PublicAPI = (await vi.importActual("../public_api"))
276
- .default as typeof IPublicAPI;
238
+ it("should set the volume in setVolume by default if a volume has been given", () => {
277
239
  const player = new PublicAPI();
278
240
  const videoElement = player.getVideoElement();
279
241
  if (videoElement === null) {
@@ -291,9 +253,7 @@ describe("API - Public API", () => {
291
253
  });
292
254
 
293
255
  describe("mute/unMute/isMute", () => {
294
- it("should keep the volume yet mute the media element in mute by default", async () => {
295
- const PublicAPI = (await vi.importActual("../public_api"))
296
- .default as typeof IPublicAPI;
256
+ it("should keep the volume yet mute the media element in mute by default", () => {
297
257
  const player = new PublicAPI();
298
258
  const videoElement = player.getVideoElement();
299
259
  if (videoElement === null) {
@@ -316,9 +276,7 @@ describe("API - Public API", () => {
316
276
  expect(videoElement.muted).toBe(false);
317
277
  });
318
278
 
319
- it("should unmute without changing the volume in unMute by default", async () => {
320
- const PublicAPI = (await vi.importActual("../public_api"))
321
- .default as typeof IPublicAPI;
279
+ it("should unmute without changing the volume in unMute by default", () => {
322
280
  const player = new PublicAPI();
323
281
  // back to a "normal" state.
324
282
  player.unMute();
@@ -349,16 +307,12 @@ describe("API - Public API", () => {
349
307
  expect(videoElement.muted).toBe(false);
350
308
  });
351
309
 
352
- it("should return false in isMute by default", async () => {
353
- const PublicAPI = (await vi.importActual("../public_api"))
354
- .default as typeof IPublicAPI;
310
+ it("should return false in isMute by default", () => {
355
311
  const player = new PublicAPI();
356
312
  expect(player.isMute()).toBe(false);
357
313
  });
358
314
 
359
- it("should not return true in isMute if just the volume is equal to 0", async () => {
360
- const PublicAPI = (await vi.importActual("../public_api"))
361
- .default as typeof IPublicAPI;
315
+ it("should not return true in isMute if just the volume is equal to 0", () => {
362
316
  const player = new PublicAPI();
363
317
 
364
318
  expect(player.isMute()).toBe(false);
@@ -369,9 +323,7 @@ describe("API - Public API", () => {
369
323
  });
370
324
 
371
325
  describe("getMaxBufferBehind/setMaxBufferBehind", () => {
372
- it("should update the max buffer behind through setMaxBufferBehind by default", async () => {
373
- const PublicAPI = (await vi.importActual("../public_api"))
374
- .default as typeof IPublicAPI;
326
+ it("should update the max buffer behind through setMaxBufferBehind by default", () => {
375
327
  const player = new PublicAPI();
376
328
  player.setMaxBufferBehind(50);
377
329
  expect(player.getMaxBufferBehind()).toBe(50);
@@ -382,9 +334,7 @@ describe("API - Public API", () => {
382
334
  });
383
335
 
384
336
  describe("getMaxBufferAhead/setMaxBufferAhead", () => {
385
- it("should update the max buffer behind through setMaxBufferAhead by default", async () => {
386
- const PublicAPI = (await vi.importActual("../public_api"))
387
- .default as typeof IPublicAPI;
337
+ it("should update the max buffer behind through setMaxBufferAhead by default", () => {
388
338
  const player = new PublicAPI();
389
339
  player.setMaxBufferAhead(50);
390
340
  expect(player.getMaxBufferAhead()).toBe(50);
@@ -395,9 +345,7 @@ describe("API - Public API", () => {
395
345
  });
396
346
 
397
347
  describe("getWantedBufferAhead/setWantedBufferAhead", () => {
398
- it("should update the buffer goal through setWantedBufferAhead by default", async () => {
399
- const PublicAPI = (await vi.importActual("../public_api"))
400
- .default as typeof IPublicAPI;
348
+ it("should update the buffer goal through setWantedBufferAhead by default", () => {
401
349
  const player = new PublicAPI();
402
350
  player.setWantedBufferAhead(50);
403
351
  expect(player.getWantedBufferAhead()).toBe(50);
@@ -408,63 +356,49 @@ describe("API - Public API", () => {
408
356
  });
409
357
 
410
358
  describe("getAvailableAudioTracks", () => {
411
- it("should return an empty array through getAvailableAudioTracks by default", async () => {
412
- const PublicAPI = (await vi.importActual("../public_api"))
413
- .default as typeof IPublicAPI;
359
+ it("should return an empty array through getAvailableAudioTracks by default", () => {
414
360
  const player = new PublicAPI();
415
361
  expect(player.getAvailableAudioTracks()).toEqual([]);
416
362
  });
417
363
  });
418
364
 
419
365
  describe("getAvailableTextTracks", () => {
420
- it("should return an empty array through getAvailableTextTracks by default", async () => {
421
- const PublicAPI = (await vi.importActual("../public_api"))
422
- .default as typeof IPublicAPI;
366
+ it("should return an empty array through getAvailableTextTracks by default", () => {
423
367
  const player = new PublicAPI();
424
368
  expect(player.getAvailableTextTracks()).toEqual([]);
425
369
  });
426
370
  });
427
371
 
428
372
  describe("getAvailableVideoTracks", () => {
429
- it("should return an empty array through getAvailableVideoTracks by default", async () => {
430
- const PublicAPI = (await vi.importActual("../public_api"))
431
- .default as typeof IPublicAPI;
373
+ it("should return an empty array through getAvailableVideoTracks by default", () => {
432
374
  const player = new PublicAPI();
433
375
  expect(player.getAvailableVideoTracks()).toEqual([]);
434
376
  });
435
377
  });
436
378
 
437
379
  describe("getAudioTrack", () => {
438
- it("should return undefined through getAudioTrack by default", async () => {
439
- const PublicAPI = (await vi.importActual("../public_api"))
440
- .default as typeof IPublicAPI;
380
+ it("should return undefined through getAudioTrack by default", () => {
441
381
  const player = new PublicAPI();
442
382
  expect(player.getAudioTrack()).toBe(undefined);
443
383
  });
444
384
  });
445
385
 
446
386
  describe("getTextTrack", () => {
447
- it("should return undefined through getTextTrack by default", async () => {
448
- const PublicAPI = (await vi.importActual("../public_api"))
449
- .default as typeof IPublicAPI;
387
+ it("should return undefined through getTextTrack by default", () => {
450
388
  const player = new PublicAPI();
451
389
  expect(player.getTextTrack()).toBe(undefined);
452
390
  });
453
391
  });
454
392
 
455
393
  describe("getVideoTrack", () => {
456
- it("should return undefined through getVideoTrack by default", async () => {
457
- const PublicAPI = (await vi.importActual("../public_api"))
458
- .default as typeof IPublicAPI;
394
+ it("should return undefined through getVideoTrack by default", () => {
459
395
  const player = new PublicAPI();
460
396
  expect(player.getVideoTrack()).toBe(undefined);
461
397
  });
462
398
  });
463
399
 
464
400
  describe("setAudioTrack", () => {
465
- it("should throw in setAudioTrack by default", async () => {
466
- const PublicAPI = (await vi.importActual("../public_api"))
467
- .default as typeof IPublicAPI;
401
+ it("should throw in setAudioTrack by default", () => {
468
402
  const player = new PublicAPI();
469
403
  expect(() => player.setAudioTrack("a")).toThrow();
470
404
  expect(() => player.setAudioTrack("test")).toThrow();
@@ -472,9 +406,7 @@ describe("API - Public API", () => {
472
406
  });
473
407
 
474
408
  describe("setTextTrack", () => {
475
- it("should throw in setTextTrack by default", async () => {
476
- const PublicAPI = (await vi.importActual("../public_api"))
477
- .default as typeof IPublicAPI;
409
+ it("should throw in setTextTrack by default", () => {
478
410
  const player = new PublicAPI();
479
411
  expect(() => player.setTextTrack("a")).toThrow();
480
412
  expect(() => player.setTextTrack("test")).toThrow();
@@ -482,9 +414,7 @@ describe("API - Public API", () => {
482
414
  });
483
415
 
484
416
  describe("setVideoTrack", () => {
485
- it("should throw in setVideoTrack by default", async () => {
486
- const PublicAPI = (await vi.importActual("../public_api"))
487
- .default as typeof IPublicAPI;
417
+ it("should throw in setVideoTrack by default", () => {
488
418
  const player = new PublicAPI();
489
419
  expect(() => player.setVideoTrack("a")).toThrow();
490
420
  expect(() => player.setVideoTrack("test")).toThrow();
@@ -492,9 +422,7 @@ describe("API - Public API", () => {
492
422
  });
493
423
 
494
424
  describe("disableTextTrack", () => {
495
- it("should disable text tracks in disableTextTrack by default", async () => {
496
- const PublicAPI = (await vi.importActual("../public_api"))
497
- .default as typeof IPublicAPI;
425
+ it("should disable text tracks in disableTextTrack by default", () => {
498
426
  const player = new PublicAPI();
499
427
  player.disableTextTrack();
500
428
  expect(player.getTextTrack()).toBe(undefined);
@@ -502,27 +430,21 @@ describe("API - Public API", () => {
502
430
  });
503
431
 
504
432
  describe("getMinimumPosition", () => {
505
- it("should return null in getMinimumPosition by default", async () => {
506
- const PublicAPI = (await vi.importActual("../public_api"))
507
- .default as typeof IPublicAPI;
433
+ it("should return null in getMinimumPosition by default", () => {
508
434
  const player = new PublicAPI();
509
435
  expect(player.getMinimumPosition()).toBe(null);
510
436
  });
511
437
  });
512
438
 
513
439
  describe("getMaximumPosition", () => {
514
- it("should return null in getMaximumPosition by default", async () => {
515
- const PublicAPI = (await vi.importActual("../public_api"))
516
- .default as typeof IPublicAPI;
440
+ it("should return null in getMaximumPosition by default", () => {
517
441
  const player = new PublicAPI();
518
442
  expect(player.getMinimumPosition()).toBe(null);
519
443
  });
520
444
  });
521
445
 
522
446
  describe("Player instantiation", () => {
523
- it("should log a warning if creating two players attached to the same video element", async () => {
524
- const PublicAPI = (await vi.importActual("../public_api"))
525
- .default as typeof IPublicAPI;
447
+ it("should log a warning if creating two players attached to the same video element", () => {
526
448
  const warn = vi.spyOn(console, "warn").mockImplementation(vi.fn());
527
449
  const videoElement = document.createElement("video");
528
450
  const player1 = new PublicAPI({ videoElement });
@@ -549,9 +471,7 @@ describe("API - Public API", () => {
549
471
  });
550
472
 
551
473
  it(`should not log a warning if creating a player attached to
552
- the same video element after the previous one was disposed`, async () => {
553
- const PublicAPI = (await vi.importActual("../public_api"))
554
- .default as typeof IPublicAPI;
474
+ the same video element after the previous one was disposed`, () => {
555
475
  const warn = vi.spyOn(console, "warn").mockImplementation(vi.fn());
556
476
  const videoElement = document.createElement("video");
557
477
  const player1 = new PublicAPI({ videoElement });
@@ -575,10 +495,8 @@ describe("API - Public API", () => {
575
495
 
576
496
  describe("event emitters", () => {
577
497
  describe("videoRepresentationChange", () => {
578
- let player: IPublicAPI;
498
+ let player: PublicAPI;
579
499
  beforeEach(async () => {
580
- const PublicAPI = (await vi.importActual("../public_api"))
581
- .default as typeof IPublicAPI;
582
500
  player = new PublicAPI();
583
501
  });
584
502
 
@@ -610,7 +528,8 @@ describe("API - Public API", () => {
610
528
  representation: {
611
529
  id: "1",
612
530
  bitrate: 1000,
613
- codecs: ["avc1"],
531
+ baseCodecs: ["avc1"],
532
+ chosenCodec: "avc1",
614
533
  uniqueId: "unique1",
615
534
  isSupported: true,
616
535
  } satisfies IRepresentationMetadata,
@@ -629,10 +548,8 @@ describe("API - Public API", () => {
629
548
  });
630
549
 
631
550
  describe("audioRepresentationChange", () => {
632
- let player: IPublicAPI;
551
+ let player: PublicAPI;
633
552
  beforeEach(async () => {
634
- const PublicAPI = (await vi.importActual("../public_api"))
635
- .default as typeof IPublicAPI;
636
553
  player = new PublicAPI();
637
554
  });
638
555
 
@@ -664,7 +581,8 @@ describe("API - Public API", () => {
664
581
  representation: {
665
582
  id: "2",
666
583
  bitrate: 1000,
667
- codecs: ["mp4a"],
584
+ baseCodecs: ["mp4a"],
585
+ chosenCodec: "mp4a",
668
586
  uniqueId: "unique2",
669
587
  isSupported: true,
670
588
  } satisfies IRepresentationMetadata,
@@ -175,7 +175,7 @@ function constructRepresentationInfo(content: {
175
175
  isSignInterpreted,
176
176
  type: bufferType,
177
177
  } = content.adaptation;
178
- const { id, height, width, bitrate, codecs, hdrInfo } = content.representation;
178
+ const { id, height, width, bitrate, chosenCodec, hdrInfo } = content.representation;
179
179
  let representationInfo = `"${id}" `;
180
180
  if (height !== undefined && width !== undefined) {
181
181
  representationInfo += `${width}x${height} `;
@@ -183,8 +183,8 @@ function constructRepresentationInfo(content: {
183
183
  if (bitrate !== undefined) {
184
184
  representationInfo += `(${(bitrate / 1000).toFixed(0)}kbps) `;
185
185
  }
186
- if (codecs !== undefined && codecs.length > 0) {
187
- representationInfo += `c:"${codecs.join(" / ")}" `;
186
+ if (chosenCodec !== undefined) {
187
+ representationInfo += `c:"${chosenCodec}" `;
188
188
  }
189
189
  if (language !== undefined) {
190
190
  representationInfo += `l:"${language}" `;
@@ -437,7 +437,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
437
437
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
438
438
  videoElement.preload = "auto";
439
439
 
440
- this.version = /* PLAYER_VERSION */ "4.5.0-dev.2026031700";
440
+ this.version = /* PLAYER_VERSION */ "4.5.0-dev.2026033100";
441
441
  this.log = log;
442
442
  this.state = "STOPPED";
443
443
  this.videoElement = videoElement;
@@ -3831,7 +3831,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
3831
3831
  return true;
3832
3832
  }
3833
3833
  }
3834
- Player.version = /* PLAYER_VERSION */ "4.5.0-dev.2026031700";
3834
+ Player.version = /* PLAYER_VERSION */ "4.5.0-dev.2026033100";
3835
3835
 
3836
3836
  /** Every events sent by the RxPlayer's public API. */
3837
3837
  interface IPublicAPIEvent {
@@ -1,56 +1,72 @@
1
- import type { MockInstance } from "vitest";
2
1
  import { describe, beforeEach, it, expect, vi } from "vitest";
3
- import * as compat from "../../../../compat/can_rely_on_request_media_key_system_access";
2
+ import getEmeApiImplementation from "../../../../compat/eme";
3
+ import assert from "../../../../utils/assert";
4
4
  import { testKeySystem } from "../../find_key_system";
5
5
 
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ const mocks = vi.hoisted(() => {
7
+ return {
8
+ requestMediaKeySystemAccess: vi.fn(),
9
+ canRelyOnRequestMediaKeySystemAccess: vi.fn(),
10
+ };
11
+ });
12
+
13
+ vi.mock("../../../../compat/can_rely_on_request_media_key_system_access", () => {
14
+ return {
15
+ canRelyOnRequestMediaKeySystemAccess: mocks.canRelyOnRequestMediaKeySystemAccess,
16
+ };
17
+ });
18
+ vi.mock("../../../../compat/eme", () => ({
19
+ default: () => ({
20
+ onEncrypted: vi.fn(),
21
+ requestMediaKeySystemAccess: mocks.requestMediaKeySystemAccess,
22
+ setMediaKeys: vi.fn(),
23
+ }),
24
+ getInitData: vi.fn(),
25
+ generateKeyRequest: vi.fn(),
26
+ closeSession: vi.fn(),
27
+ loadSession: vi.fn(),
28
+ }));
7
29
 
8
30
  describe("find_key_systems - ", () => {
9
- let requestMediaKeySystemAccessMock: MockInstance;
10
- let canRelyOnEMEMock: MockInstance;
11
31
  const keySystem = "com.microsoft.playready.recommendation";
12
- const eme = {
13
- implementation: "standard",
14
- requestMediaKeySystemAccess: (
15
- _type: string,
16
- _config: MediaKeySystemConfiguration[],
17
- ): Promise<any> => Promise.reject(new Error("Unimplemented")),
18
- onEncrypted: () => {
19
- /* noop */
20
- },
21
- setMediaKeys: () => Promise.reject(new Error("Unimplemented")),
22
- } as const;
23
-
24
32
  beforeEach(() => {
25
33
  vi.resetModules();
26
34
  vi.restoreAllMocks();
27
- requestMediaKeySystemAccessMock = vi.spyOn(eme, "requestMediaKeySystemAccess");
28
- canRelyOnEMEMock = vi.spyOn(compat, "canRelyOnRequestMediaKeySystemAccess");
35
+ mocks.canRelyOnRequestMediaKeySystemAccess.mockReset();
36
+ mocks.requestMediaKeySystemAccess.mockReset();
29
37
  });
30
38
 
31
39
  it("should resolve if the keySystem is supported", async () => {
32
40
  /* mock implementation of requestMediaKeySystemAccess that support the keySystem */
33
- requestMediaKeySystemAccessMock.mockImplementation(() =>
41
+ mocks.requestMediaKeySystemAccess.mockImplementation(() =>
34
42
  Promise.resolve({
35
43
  createMediaKeys: () => ({
36
44
  createSession: () => ({
37
- // eslint-disable-next-line @typescript-eslint/no-empty-function
38
- generateRequest: () => {},
45
+ generateRequest: () => {
46
+ /* noop */
47
+ },
48
+ close: () => {
49
+ return Promise.resolve();
50
+ },
39
51
  }),
40
52
  }),
41
53
  }),
42
54
  );
55
+ const eme = getEmeApiImplementation("auto");
56
+ assert(eme !== null);
43
57
  await expect(testKeySystem(eme, keySystem, [])).resolves.toBeTruthy();
44
- expect(requestMediaKeySystemAccessMock).toHaveBeenCalledTimes(1);
58
+ expect(mocks.requestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
45
59
  });
46
60
 
47
61
  it("should reject if the keySystem is not supported", async () => {
48
62
  /* mock implementation of requestMediaKeySystemAccess that does not support the keySystem */
49
- requestMediaKeySystemAccessMock.mockImplementation(() => {
63
+ mocks.requestMediaKeySystemAccess.mockImplementation(() => {
50
64
  throw new Error();
51
65
  });
66
+ const eme = getEmeApiImplementation("auto");
67
+ assert(eme !== null);
52
68
  await expect(testKeySystem(eme, keySystem, [])).rejects.toThrow();
53
- expect(requestMediaKeySystemAccessMock).toHaveBeenCalledTimes(1);
69
+ expect(mocks.requestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
54
70
  });
55
71
 
56
72
  it("should reject if the keySystem seems to be supported but the EME workflow fail", async () => {
@@ -58,8 +74,8 @@ describe("find_key_systems - ", () => {
58
74
  but that is failing when performing the usual EME workflow of creating mediaKeys, creating a session
59
75
  and generating a request. */
60
76
 
61
- canRelyOnEMEMock.mockImplementation(() => false);
62
- requestMediaKeySystemAccessMock.mockImplementation(() =>
77
+ mocks.canRelyOnRequestMediaKeySystemAccess.mockImplementation(() => false);
78
+ mocks.requestMediaKeySystemAccess.mockImplementation(() =>
63
79
  Promise.resolve({
64
80
  createMediaKeys: () => ({
65
81
  createSession: () => ({
@@ -70,7 +86,9 @@ describe("find_key_systems - ", () => {
70
86
  }),
71
87
  }),
72
88
  );
89
+ const eme = getEmeApiImplementation("auto");
90
+ assert(eme !== null);
73
91
  await expect(testKeySystem(eme, keySystem, [])).rejects.toThrow();
74
- expect(requestMediaKeySystemAccessMock).toHaveBeenCalledTimes(1);
92
+ expect(mocks.requestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
75
93
  });
76
94
  });