rx-player 3.31.1-dev.2023070500 → 3.32.0-dev.2023092900

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 (365) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/CONTRIBUTING.md +27 -13
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.d.ts +2 -2
  5. package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.js +9 -5
  6. package/dist/_esm5.processed/compat/eme/custom_media_keys/index.d.ts +6 -27
  7. package/dist/_esm5.processed/compat/eme/custom_media_keys/index.js +1 -154
  8. package/dist/_esm5.processed/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts +1 -1
  9. package/dist/_esm5.processed/compat/eme/custom_media_keys/moz_media_keys_constructor.js +9 -5
  10. package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts +2 -2
  11. package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.js +9 -5
  12. package/dist/_esm5.processed/compat/eme/custom_media_keys/types.d.ts +1 -1
  13. package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.d.ts +2 -2
  14. package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.js +10 -6
  15. package/dist/_esm5.processed/compat/eme/eme-api-implementation.d.ts +78 -0
  16. package/dist/_esm5.processed/compat/eme/eme-api-implementation.js +198 -0
  17. package/dist/_esm5.processed/compat/eme/index.d.ts +5 -3
  18. package/dist/_esm5.processed/compat/eme/index.js +3 -3
  19. package/dist/_esm5.processed/compat/event_listeners.d.ts +13 -5
  20. package/dist/_esm5.processed/compat/event_listeners.js +8 -14
  21. package/dist/_esm5.processed/compat/index.d.ts +1 -3
  22. package/dist/_esm5.processed/compat/index.js +1 -3
  23. package/dist/_esm5.processed/compat/is_debug_mode_enabled.d.ts +7 -0
  24. package/dist/_esm5.processed/compat/is_debug_mode_enabled.js +9 -0
  25. package/dist/_esm5.processed/compat/on_height_width_change.js +2 -2
  26. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +40 -34
  27. package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.d.ts +17 -1
  28. package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.js +26 -8
  29. package/dist/_esm5.processed/core/api/option_utils.d.ts +1 -1
  30. package/dist/_esm5.processed/core/api/option_utils.js +12 -8
  31. package/dist/_esm5.processed/core/api/playback_observer.js +2 -2
  32. package/dist/_esm5.processed/core/api/public_api.d.ts +6 -0
  33. package/dist/_esm5.processed/core/api/public_api.js +28 -20
  34. package/dist/_esm5.processed/core/api/tracks_management/media_element_track_choice_manager.js +1 -2
  35. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +2 -2
  36. package/dist/_esm5.processed/core/api/utils.js +2 -2
  37. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +3 -3
  38. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +21 -14
  39. package/dist/_esm5.processed/core/decrypt/attach_media_keys.d.ts +8 -2
  40. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +17 -6
  41. package/dist/_esm5.processed/core/decrypt/clear_on_stop.d.ts +1 -1
  42. package/dist/_esm5.processed/core/decrypt/content_decryptor.d.ts +9 -67
  43. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +52 -76
  44. package/dist/_esm5.processed/core/decrypt/create_or_load_session.d.ts +1 -1
  45. package/dist/_esm5.processed/core/decrypt/create_session.d.ts +1 -1
  46. package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.d.ts +1 -1
  47. package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.js +11 -4
  48. package/dist/_esm5.processed/core/decrypt/find_key_system.d.ts +2 -2
  49. package/dist/_esm5.processed/core/decrypt/find_key_system.js +18 -15
  50. package/dist/_esm5.processed/core/decrypt/get_media_keys.d.ts +1 -1
  51. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +1 -1
  52. package/dist/_esm5.processed/core/decrypt/index.d.ts +2 -2
  53. package/dist/_esm5.processed/core/decrypt/index.js +2 -2
  54. package/dist/_esm5.processed/core/decrypt/session_events_listener.d.ts +1 -1
  55. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +1 -1
  56. package/dist/_esm5.processed/core/decrypt/set_server_certificate.d.ts +1 -1
  57. package/dist/_esm5.processed/core/decrypt/types.d.ts +61 -0
  58. package/dist/_esm5.processed/core/decrypt/types.js +40 -1
  59. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.d.ts +1 -1
  60. package/dist/_esm5.processed/core/decrypt/utils/is_session_usable.d.ts +1 -1
  61. package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.d.ts +0 -13
  62. package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.js +2 -19
  63. package/dist/_esm5.processed/core/decrypt/utils/key_session_record.js +3 -2
  64. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.d.ts +1 -1
  65. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +1 -1
  66. package/dist/_esm5.processed/core/decrypt/utils/media_keys_infos_store.d.ts +2 -1
  67. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +1 -1
  68. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +1 -2
  69. package/dist/_esm5.processed/core/decrypt/utils/server_certificate_store.d.ts +1 -1
  70. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +5 -6
  71. package/dist/_esm5.processed/core/init/index.d.ts +1 -4
  72. package/dist/_esm5.processed/core/init/index.js +1 -3
  73. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +41 -14
  74. package/dist/_esm5.processed/core/init/types.d.ts +2 -2
  75. package/dist/_esm5.processed/core/init/utils/create_media_source.js +4 -1
  76. package/dist/_esm5.processed/core/init/utils/create_stream_playback_observer.d.ts +9 -4
  77. package/dist/_esm5.processed/core/init/utils/create_stream_playback_observer.js +16 -10
  78. package/dist/_esm5.processed/core/init/utils/end_of_stream.js +1 -0
  79. package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +2 -2
  80. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +6 -6
  81. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.d.ts +3 -3
  82. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +28 -36
  83. package/dist/_esm5.processed/core/init/utils/media_source_duration_updater.js +12 -7
  84. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.js +18 -2
  85. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.d.ts +31 -9
  86. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +99 -56
  87. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +18 -7
  88. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +40 -41
  89. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +8 -0
  90. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +12 -0
  91. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +10 -2
  92. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +15 -3
  93. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +8 -0
  94. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +12 -0
  95. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +11 -4
  96. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +1 -0
  97. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +14 -19
  98. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +13 -7
  99. package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.js +2 -2
  100. package/dist/_esm5.processed/core/stream/index.d.ts +2 -2
  101. package/dist/_esm5.processed/core/stream/orchestrator/get_time_ranges_for_content.js +1 -6
  102. package/dist/_esm5.processed/core/stream/orchestrator/index.d.ts +2 -2
  103. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +15 -29
  104. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +12 -8
  105. package/dist/_esm5.processed/core/stream/period/period_stream.js +20 -26
  106. package/dist/_esm5.processed/core/stream/period/types.d.ts +2 -2
  107. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +18 -4
  108. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +28 -15
  109. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.d.ts +1 -1
  110. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +2 -2
  111. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.d.ts +3 -2
  112. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +2 -6
  113. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.d.ts +2 -2
  114. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +2 -3
  115. package/dist/_esm5.processed/errors/request_error.js +15 -1
  116. package/dist/_esm5.processed/experimental/features/dash_wasm.js +3 -0
  117. package/dist/_esm5.processed/experimental/features/index.d.ts +0 -1
  118. package/dist/_esm5.processed/experimental/features/index.js +0 -1
  119. package/dist/_esm5.processed/experimental/features/local.js +3 -0
  120. package/dist/_esm5.processed/experimental/features/metaplaylist.js +3 -0
  121. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +1 -1
  122. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +8 -7
  123. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +17 -9
  124. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/index.d.ts +1 -1
  125. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
  126. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +1 -1
  127. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +4 -3
  128. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.d.ts +1 -1
  129. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +5 -4
  130. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +4 -3
  131. package/dist/_esm5.processed/features/features_object.js +2 -1
  132. package/dist/_esm5.processed/features/initialize_features.d.ts +1 -3
  133. package/dist/_esm5.processed/features/initialize_features.js +10 -4
  134. package/dist/_esm5.processed/features/list/bif_parser.js +2 -0
  135. package/dist/_esm5.processed/features/list/dash.js +3 -0
  136. package/dist/_esm5.processed/features/list/directfile.js +5 -2
  137. package/dist/_esm5.processed/features/list/eme.js +1 -1
  138. package/dist/_esm5.processed/features/list/html_sami_parser.js +2 -0
  139. package/dist/_esm5.processed/features/list/html_srt_parser.js +2 -0
  140. package/dist/_esm5.processed/features/list/html_text_buffer.js +2 -2
  141. package/dist/_esm5.processed/features/list/html_ttml_parser.js +2 -0
  142. package/dist/_esm5.processed/features/list/html_vtt_parser.js +2 -0
  143. package/dist/_esm5.processed/features/list/native_sami_parser.js +3 -0
  144. package/dist/_esm5.processed/features/list/native_srt_parser.js +3 -0
  145. package/dist/_esm5.processed/features/list/native_text_buffer.js +3 -2
  146. package/dist/_esm5.processed/features/list/native_ttml_parser.js +3 -0
  147. package/dist/_esm5.processed/features/list/native_vtt_parser.js +3 -0
  148. package/dist/_esm5.processed/features/list/smooth.js +3 -0
  149. package/dist/_esm5.processed/features/types.d.ts +83 -5
  150. package/dist/_esm5.processed/index.d.ts +0 -6
  151. package/dist/_esm5.processed/index.js +2 -1
  152. package/dist/_esm5.processed/manifest/manifest.js +1 -2
  153. package/dist/_esm5.processed/manifest/representation.d.ts +34 -1
  154. package/dist/_esm5.processed/manifest/representation.js +8 -2
  155. package/dist/_esm5.processed/manifest/utils.js +1 -3
  156. package/dist/_esm5.processed/minimal.d.ts +1 -17
  157. package/dist/_esm5.processed/minimal.js +3 -35
  158. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +4 -1
  159. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +7 -0
  160. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +8 -0
  161. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +1 -0
  162. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +10 -0
  163. package/dist/_esm5.processed/parsers/manifest/local/parse_local_manifest.js +1 -0
  164. package/dist/_esm5.processed/parsers/manifest/local/types.d.ts +2 -0
  165. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +1 -0
  166. package/dist/_esm5.processed/parsers/manifest/types.d.ts +2 -0
  167. package/dist/_esm5.processed/public_types.d.ts +3 -1
  168. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +1 -1
  169. package/dist/_esm5.processed/transports/utils/get_isobmff_timing_infos.d.ts +0 -3
  170. package/dist/_esm5.processed/transports/utils/get_isobmff_timing_infos.js +0 -3
  171. package/dist/_esm5.processed/utils/are_arrays_of_numbers_equal.js +3 -0
  172. package/dist/_esm5.processed/utils/assert.js +2 -1
  173. package/dist/_esm5.processed/utils/deep_merge.d.ts +2 -5
  174. package/dist/_esm5.processed/utils/reference.d.ts +78 -37
  175. package/dist/_esm5.processed/utils/reference.js +237 -153
  176. package/dist/_esm5.processed/utils/wrapInPromise.d.ts +7 -0
  177. package/dist/_esm5.processed/utils/wrapInPromise.js +22 -0
  178. package/dist/mpd-parser.wasm +0 -0
  179. package/dist/rx-player.js +42294 -41851
  180. package/dist/rx-player.min.js +1 -1
  181. package/package.json +36 -36
  182. package/scripts/list-npm-scripts.js +146 -38
  183. package/sonar-project.properties +1 -1
  184. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +11 -8
  185. package/src/compat/eme/custom_media_keys/index.ts +8 -184
  186. package/src/compat/eme/custom_media_keys/moz_media_keys_constructor.ts +13 -7
  187. package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +11 -8
  188. package/src/compat/eme/custom_media_keys/types.ts +1 -1
  189. package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +15 -11
  190. package/src/compat/eme/eme-api-implementation.ts +318 -0
  191. package/src/compat/eme/index.ts +8 -6
  192. package/src/compat/event_listeners.ts +12 -20
  193. package/src/compat/index.ts +0 -24
  194. package/src/compat/is_debug_mode_enabled.ts +12 -0
  195. package/src/compat/on_height_width_change.ts +2 -2
  196. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +242 -99
  197. package/src/core/adaptive/adaptive_representation_selector.ts +52 -49
  198. package/src/core/adaptive/buffer_based_chooser.ts +36 -9
  199. package/src/core/adaptive/utils/pending_requests_store.ts +2 -2
  200. package/src/core/api/option_utils.ts +6 -1
  201. package/src/core/api/playback_observer.ts +3 -3
  202. package/src/core/api/public_api.ts +53 -40
  203. package/src/core/api/tracks_management/track_choice_manager.ts +5 -5
  204. package/src/core/api/utils.ts +3 -3
  205. package/src/core/decrypt/__tests__/__global__/get_license.test.ts +3 -3
  206. package/src/core/decrypt/__tests__/__global__/init_data.test.ts +24 -14
  207. package/src/core/decrypt/__tests__/__global__/media_key_system_access.test.ts +76 -48
  208. package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +19 -13
  209. package/src/core/decrypt/__tests__/__global__/server_certificate.test.ts +15 -12
  210. package/src/core/decrypt/__tests__/__global__/utils.ts +39 -24
  211. package/src/core/decrypt/attach_media_keys.ts +33 -8
  212. package/src/core/decrypt/clear_on_stop.ts +1 -1
  213. package/src/core/decrypt/content_decryptor.ts +213 -262
  214. package/src/core/decrypt/create_or_load_session.ts +1 -1
  215. package/src/core/decrypt/create_session.ts +1 -1
  216. package/src/core/decrypt/dispose_decryption_resources.ts +19 -4
  217. package/src/core/decrypt/find_key_system.ts +25 -20
  218. package/src/core/decrypt/get_media_keys.ts +2 -2
  219. package/src/core/decrypt/index.ts +1 -6
  220. package/src/core/decrypt/session_events_listener.ts +3 -4
  221. package/src/core/decrypt/set_server_certificate.ts +1 -1
  222. package/src/core/decrypt/types.ts +69 -0
  223. package/src/core/decrypt/utils/check_key_statuses.ts +1 -1
  224. package/src/core/decrypt/utils/is_session_usable.ts +1 -1
  225. package/src/core/decrypt/utils/key_id_comparison.ts +2 -27
  226. package/src/core/decrypt/utils/key_session_record.ts +3 -5
  227. package/src/core/decrypt/utils/loaded_sessions_store.ts +2 -2
  228. package/src/core/decrypt/utils/media_keys_infos_store.ts +4 -1
  229. package/src/core/decrypt/utils/persistent_sessions_store.ts +2 -5
  230. package/src/core/decrypt/utils/server_certificate_store.ts +1 -1
  231. package/src/core/init/directfile_content_initializer.ts +10 -6
  232. package/src/core/init/index.ts +6 -7
  233. package/src/core/init/media_source_content_initializer.ts +56 -24
  234. package/src/core/init/types.ts +2 -2
  235. package/src/core/init/utils/__tests__/refresh_scheduled_events_list.test.ts +22 -8
  236. package/src/core/init/utils/create_media_source.ts +4 -1
  237. package/src/core/init/utils/create_stream_playback_observer.ts +24 -14
  238. package/src/core/init/utils/end_of_stream.ts +1 -0
  239. package/src/core/init/utils/get_loaded_reference.ts +2 -2
  240. package/src/core/init/utils/initial_seek_and_play.ts +7 -7
  241. package/src/core/init/utils/initialize_content_decryption.ts +32 -39
  242. package/src/core/init/utils/media_source_duration_updater.ts +13 -9
  243. package/src/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.ts +7 -4
  244. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +113 -73
  245. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +66 -57
  246. package/src/core/segment_buffers/implementations/image/image_segment_buffer.ts +16 -0
  247. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +33 -17
  248. package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +1 -1
  249. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +18 -2
  250. package/src/core/segment_buffers/implementations/types.ts +16 -4
  251. package/src/core/segment_buffers/implementations/utils/manual_time_ranges.ts +2 -2
  252. package/src/core/segment_buffers/inventory/segment_inventory.ts +1 -0
  253. package/src/core/stream/adaptation/adaptation_stream.ts +17 -25
  254. package/src/core/stream/adaptation/types.ts +13 -7
  255. package/src/core/stream/adaptation/utils/create_representation_estimator.ts +2 -2
  256. package/src/core/stream/index.ts +2 -0
  257. package/src/core/stream/orchestrator/get_time_ranges_for_content.ts +1 -6
  258. package/src/core/stream/orchestrator/index.ts +2 -0
  259. package/src/core/stream/orchestrator/stream_orchestrator.ts +26 -37
  260. package/src/core/stream/period/period_stream.ts +27 -29
  261. package/src/core/stream/period/types.ts +2 -2
  262. package/src/core/stream/period/utils/get_adaptation_switch_strategy.ts +10 -1
  263. package/src/core/stream/representation/representation_stream.ts +42 -24
  264. package/src/core/stream/representation/utils/downloading_queue.ts +4 -5
  265. package/src/core/stream/representation/utils/push_init_segment.ts +4 -5
  266. package/src/core/stream/representation/utils/push_media_segment.ts +3 -3
  267. package/src/errors/__tests__/network_error.test.ts +10 -9
  268. package/src/errors/__tests__/request_error.test.ts +6 -4
  269. package/src/errors/request_error.ts +16 -1
  270. package/src/experimental/features/__tests__/dash_wasm.test.ts +4 -12
  271. package/src/experimental/features/__tests__/debug_element.test.ts +7 -21
  272. package/src/experimental/features/__tests__/local.test.ts +14 -23
  273. package/src/experimental/features/__tests__/metaplaylist.test.ts +14 -21
  274. package/src/experimental/features/dash_wasm.ts +3 -0
  275. package/src/experimental/features/index.ts +0 -1
  276. package/src/experimental/features/local.ts +3 -0
  277. package/src/experimental/features/metaplaylist.ts +3 -0
  278. package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +10 -7
  279. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +17 -6
  280. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +10 -9
  281. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +26 -18
  282. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +2 -4
  283. package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +7 -4
  284. package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +5 -4
  285. package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +4 -3
  286. package/src/features/__tests__/initialize_features.test.ts +182 -3
  287. package/src/features/features_object.ts +2 -1
  288. package/src/features/initialize_features.ts +35 -28
  289. package/src/features/list/__tests__/bif_parser.test.ts +5 -11
  290. package/src/features/list/__tests__/dash.test.ts +15 -15
  291. package/src/features/list/__tests__/directfile.test.ts +7 -16
  292. package/src/features/list/__tests__/eme.test.ts +4 -12
  293. package/src/features/list/__tests__/html_sami_parser.test.ts +9 -14
  294. package/src/features/list/__tests__/html_srt_parser.test.ts +5 -10
  295. package/src/features/list/__tests__/html_text_buffer.test.ts +10 -19
  296. package/src/features/list/__tests__/html_ttml_parser.test.ts +5 -10
  297. package/src/features/list/__tests__/html_vtt_parser.test.ts +5 -10
  298. package/src/features/list/__tests__/image_buffer.test.ts +2 -9
  299. package/src/features/list/__tests__/native_sami_parser.test.ts +9 -14
  300. package/src/features/list/__tests__/native_srt_parser.test.ts +5 -10
  301. package/src/features/list/__tests__/native_text_buffer.test.ts +5 -13
  302. package/src/features/list/__tests__/native_ttml_parser.test.ts +5 -10
  303. package/src/features/list/__tests__/native_vtt_parser.test.ts +5 -10
  304. package/src/features/list/__tests__/smooth.test.ts +10 -10
  305. package/src/features/list/bif_parser.ts +2 -0
  306. package/src/features/list/dash.ts +3 -0
  307. package/src/features/list/directfile.ts +5 -3
  308. package/src/features/list/eme.ts +1 -1
  309. package/src/features/list/html_sami_parser.ts +2 -0
  310. package/src/features/list/html_srt_parser.ts +2 -0
  311. package/src/features/list/html_text_buffer.ts +2 -2
  312. package/src/features/list/html_ttml_parser.ts +2 -0
  313. package/src/features/list/html_vtt_parser.ts +2 -0
  314. package/src/features/list/native_sami_parser.ts +3 -0
  315. package/src/features/list/native_srt_parser.ts +3 -0
  316. package/src/features/list/native_text_buffer.ts +3 -2
  317. package/src/features/list/native_ttml_parser.ts +3 -0
  318. package/src/features/list/native_vtt_parser.ts +3 -0
  319. package/src/features/list/smooth.ts +3 -0
  320. package/src/features/types.ts +88 -15
  321. package/src/index.ts +3 -2
  322. package/src/manifest/__tests__/manifest.test.ts +7 -7
  323. package/src/manifest/representation.ts +46 -3
  324. package/src/manifest/utils.ts +1 -3
  325. package/src/minimal.ts +4 -18
  326. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +1 -0
  327. package/src/parsers/manifest/dash/common/parse_representations.ts +10 -0
  328. package/src/parsers/manifest/dash/js-parser/node_parsers/Representation.ts +7 -0
  329. package/src/parsers/manifest/dash/node_parser_types.ts +1 -0
  330. package/src/parsers/manifest/dash/wasm-parser/Cargo.lock +2 -2
  331. package/src/parsers/manifest/dash/wasm-parser/Cargo.toml +1 -1
  332. package/src/parsers/manifest/dash/wasm-parser/rs/errors.rs +3 -3
  333. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +37 -67
  334. package/src/parsers/manifest/dash/wasm-parser/rs/lib.rs +7 -7
  335. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +94 -105
  336. package/src/parsers/manifest/dash/wasm-parser/rs/processor/mod.rs +119 -109
  337. package/src/parsers/manifest/dash/wasm-parser/rs/processor/s_element.rs +24 -26
  338. package/src/parsers/manifest/dash/wasm-parser/rs/reader.rs +2 -2
  339. package/src/parsers/manifest/dash/wasm-parser/rs/reportable.rs +42 -18
  340. package/src/parsers/manifest/dash/wasm-parser/rs/utils.rs +29 -29
  341. package/src/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.ts +1 -1
  342. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Representation.ts +12 -0
  343. package/src/parsers/manifest/local/parse_local_manifest.ts +1 -0
  344. package/src/parsers/manifest/local/types.ts +2 -0
  345. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +1 -0
  346. package/src/parsers/manifest/smooth/create_parser.ts +1 -1
  347. package/src/parsers/manifest/types.ts +2 -0
  348. package/src/public_types.ts +7 -1
  349. package/src/tools/TextTrackRenderer/text_track_renderer.ts +1 -1
  350. package/src/transports/dash/manifest_parser.ts +4 -3
  351. package/src/transports/smooth/segment_loader.ts +1 -1
  352. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +4 -4
  353. package/src/transports/utils/get_isobmff_timing_infos.ts +0 -3
  354. package/src/typings/globals.d.ts +0 -2
  355. package/src/utils/are_arrays_of_numbers_equal.ts +5 -1
  356. package/src/utils/assert.ts +4 -1
  357. package/src/utils/deep_merge.ts +2 -2
  358. package/src/utils/reference.ts +235 -237
  359. package/src/utils/request/xhr.ts +1 -1
  360. package/src/utils/wrapInPromise.ts +24 -0
  361. package/appveyor.yml +0 -24
  362. package/dist/_esm5.processed/compat/has_eme_apis.d.ts +0 -21
  363. package/dist/_esm5.processed/compat/has_eme_apis.js +0 -24
  364. package/src/compat/__tests__/has_eme_apis.test.ts +0 -56
  365. package/src/compat/has_eme_apis.ts +0 -26
package/CHANGELOG.md CHANGED
@@ -1,15 +1,38 @@
1
1
  # Changelog
2
2
 
3
- ## v3.31.1-dev.2023070500 (2023-07-05)
3
+ ## v3.32.0-dev.2023092900 (2023-09-29)
4
+
5
+ ### Features
6
+
7
+ - DASH: add optional `isSpatialAudio` boolean property to Representation returned by `getAvailableAudioTracks`, `getAudioTrack`, corresponding events, and `trackInfo` optional property of `MediaError` objects to signal Dolby Atmos techology [#1275]
8
+ - `LOCAL`: add `isSpatialAudio` property to Representation of the experiment `"local"` transport (used for offline playback) [#1275]
9
+ - `addFeatures` static method is now available on all RxPlayer builds. It was previously only in the minimal (`rx-player/minimal` import path) [#1287]
10
+ - The `NATIVE_TEXT_BUFFER`, `HTML_TEXT_BUFFER` and `IMAGE_BUFFER` features are now totally optional [#1287, #1293]
4
11
 
5
12
  ### Bug fixes
6
13
 
14
+ - Fix `setVideoBitrate` and `setAudioBitrate` API which may have led to a higher quality than wanted in the default `"seamless"` `manualBitrateSwitchingMode` if our buffer-based adaptive logic decided to [#1267, #1271]
7
15
  - On the PlayStation 5, only switch to the `"LOADED"` state once the HTMLMediaElement's `readyState` of `4` has been reached, as it seems to switch to `3` too soon there [#1257]
16
+ - DASH: Fix potential track duplication if more than two `AdaptationSet` have an `adaptation-set-switching` `<SupplementalProperty>` between one another [#1279]
17
+ - DASH-WASM: availabilityTimeOffset is actually a floating number [#1278]
8
18
 
9
19
  ### Other improvements
10
20
 
11
21
  - Do not load the last text segment if the current position goes after it as it is unnecessary [#1256]
22
+ - Implement better `NetworkError` messages [#1274]
12
23
  - Set a better error message for when no `keySystems` option is set when playing an encrypted content
24
+ - Fix very small memory leak when reloading a content [#1286]
25
+ - TTML: put saner values for extent and origins when weird ones are found
26
+ - Re-check for segments to load immediately after the manifest has been refreshed [#1282]
27
+ - When "fallbacking" an undecipherable Representation, now empty the whole buffer if we can't make out where content was in the buffer [#1283]
28
+ - DRM: Reload when playback is unexpectedly frozen with encrypted but only decipherable data in the buffer [#1236]
29
+ - Improve segment start detection in buffer when there's unknown data buffered before it [#1284]
30
+ - DRM: Selection of alternative EME API like those used on IE11 or Safari has been refactored to facilitate future developments [#1261]
31
+
32
+ ### Deprecated
33
+
34
+ - Deprecate the `manifestUpdateUrl` `loadVideo` option as it doesn't seem used anymore [#1288]
35
+ - Deprecate the `NATIVE_TEXT_BUFFER`, `HTML_TEXT_BUFFER` and `IMAGE_BUFFER` features as they are now unneeded [#1287, #1293]
13
36
 
14
37
 
15
38
  ## v3.31.0 (2023-06-14)
package/CONTRIBUTING.md CHANGED
@@ -12,23 +12,39 @@ Those have to follow the conventions defined below.
12
12
 
13
13
 
14
14
 
15
- ## Reading the current code
15
+ ## Important code concepts
16
16
 
17
- Even if we hope the current code is straightforward, readable and commented
18
- enough we can still admit that going blind into the codebase can be hard at
19
- first as this is a pretty big technical project on a specific matter.
17
+ ### Code documentation
20
18
 
21
- We thus encourage you to rely on the architecture documentation you can usually
22
- find alongside the code, in `README.md` files.
23
- You can for example start by reading `src/README.md`, to have a clearer idea
24
- of the general code architecture of the player.
19
+ We try to put `README.md` files inside every significant directories inside
20
+ `/src` to provide a global architecture documentation of that directory
21
+ specifically.
22
+
23
+ You can try to start understanding a piece of RxPlayer code by navigating
24
+ to that file. Understand that the documented behavior may be out of date
25
+ (in which case you're welcome to update it or open an issue) though even in
26
+ that case, it is a good starting point to understand the directory's role.
27
+ Likewise, don't forget to update it if a change you made to the code
28
+ necessitates a documentation change.
25
29
 
26
30
  Also, for a more exhaustive approach to the documentation of the project's file
27
31
  organization, you can look at [`FILES.md`](./FILES.md).
28
32
 
29
- The code of the RxPlayer being heavily modularized, you should not need to read
30
- the whole documentation to be ready, only the parts you want to update
31
- (hopefully!).
33
+ ### When renaming or deleting functions, classes or variables
34
+
35
+ When Refactoring/Renaming, make sure to grep any of the renamed class / function
36
+ / variable's name as they may also be referenced in documentation and code
37
+ comments. Same thing for a directory or file name.
38
+
39
+ If the name is hard to grep (e.g. the name is too generic and thus has too many
40
+ false positives), you can generally reduce the area to comments in the same file
41
+ and documentation files in the same directory.
42
+
43
+ ### `features` object
44
+
45
+ Some files should not be imported directly but only be accessed by going through
46
+ the `features` object exported at `/src/features`. This is to reduce bundle size
47
+ when an application doesn't need all of the RxPlayer's features.
32
48
 
33
49
 
34
50
 
@@ -53,8 +69,6 @@ directory) by calling `npm run lint:tests`.
53
69
 
54
70
  ### Types
55
71
 
56
- #### General TypeScript rules
57
-
58
72
  We try to be as strict as possible with types:
59
73
 
60
74
  - the `any` type should be avoided
package/VERSION CHANGED
@@ -1 +1 @@
1
- 3.31.1-dev.2023070500
1
+ 3.32.0-dev.2023092900
@@ -19,13 +19,13 @@ declare class IE11CustomMediaKeys implements ICustomMediaKeys {
19
19
  private _videoElement?;
20
20
  private _mediaKeys?;
21
21
  constructor(keyType: string);
22
- _setVideo(videoElement: HTMLMediaElement): void;
22
+ _setVideo(videoElement: HTMLMediaElement): Promise<unknown>;
23
23
  createSession(): ICustomMediaKeySession;
24
24
  setServerCertificate(): Promise<void>;
25
25
  }
26
26
  export default function getIE11MediaKeysCallbacks(): {
27
27
  isTypeSupported: (keyType: string) => boolean;
28
28
  createCustomMediaKeys: (keyType: string) => IE11CustomMediaKeys;
29
- setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => void;
29
+ setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => Promise<unknown>;
30
30
  };
31
31
  export { MSMediaKeysConstructor };
@@ -30,6 +30,7 @@ var __extends = (this && this.__extends) || (function () {
30
30
  })();
31
31
  import EventEmitter from "../../../utils/event_emitter";
32
32
  import TaskCanceller from "../../../utils/task_canceller";
33
+ import wrapInPromise from "../../../utils/wrapInPromise";
33
34
  import * as events from "../../event_listeners";
34
35
  import { MSMediaKeysConstructor, } from "./ms_media_keys_constructor";
35
36
  var IE11MediaKeySession = /** @class */ (function (_super) {
@@ -115,10 +116,13 @@ var IE11CustomMediaKeys = /** @class */ (function () {
115
116
  this._mediaKeys = new MSMediaKeysConstructor(keyType);
116
117
  }
117
118
  IE11CustomMediaKeys.prototype._setVideo = function (videoElement) {
118
- this._videoElement = videoElement;
119
- if (this._videoElement.msSetMediaKeys !== undefined) {
120
- return this._videoElement.msSetMediaKeys(this._mediaKeys);
121
- }
119
+ var _this = this;
120
+ return wrapInPromise(function () {
121
+ _this._videoElement = videoElement;
122
+ if (_this._videoElement.msSetMediaKeys !== undefined) {
123
+ _this._videoElement.msSetMediaKeys(_this._mediaKeys);
124
+ }
125
+ });
122
126
  };
123
127
  IE11CustomMediaKeys.prototype.createSession = function ( /* sessionType */) {
124
128
  if (this._videoElement === undefined || this._mediaKeys === undefined) {
@@ -149,7 +153,7 @@ export default function getIE11MediaKeysCallbacks() {
149
153
  // msSetMediaKeys only accepts native MSMediaKeys as argument.
150
154
  // Calling it with null or undefined will raise an exception.
151
155
  // There is no way to unset the mediakeys in that case, so return here.
152
- return;
156
+ return Promise.resolve(undefined);
153
157
  }
154
158
  if (!(mediaKeys instanceof IE11CustomMediaKeys)) {
155
159
  throw new Error("Custom setMediaKeys is supposed to be called " +
@@ -1,28 +1,7 @@
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 CustomMediaKeySystemAccess from "./../custom_key_system_access";
1
+ import getIE11MediaKeysCallbacks, { MSMediaKeysConstructor } from "./ie11_media_keys";
2
+ import getMozMediaKeysCallbacks, { MozMediaKeysConstructor } from "./moz_media_keys_constructor";
3
+ import getOldKitWebKitMediaKeyCallbacks, { isOldWebkitMediaElement } from "./old_webkit_media_keys";
17
4
  import { ICustomMediaKeys, ICustomMediaKeySession } from "./types";
18
- /** Generic implementation of the navigator.requestMediaKeySystemAccess API. */
19
- type ICompatRequestMediaKeySystemAccessFn = (keyType: string, config: MediaKeySystemConfiguration[]) => Promise<MediaKeySystemAccess | CustomMediaKeySystemAccess>;
20
- declare let requestMediaKeySystemAccess: ICompatRequestMediaKeySystemAccessFn | null;
21
- /**
22
- * Set the given MediaKeys on the given HTMLMediaElement.
23
- * Emits null when done then complete.
24
- * @param {HTMLMediaElement} elt
25
- * @param {Object} mediaKeys
26
- */
27
- declare let setMediaKeys: ((elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => unknown);
28
- export { requestMediaKeySystemAccess, setMediaKeys, ICustomMediaKeys, ICustomMediaKeySession, };
5
+ import getWebKitMediaKeysCallbacks from "./webkit_media_keys";
6
+ import { WebKitMediaKeysConstructor } from "./webkit_media_keys_constructor";
7
+ export { getIE11MediaKeysCallbacks, MSMediaKeysConstructor, getMozMediaKeysCallbacks, MozMediaKeysConstructor, getOldKitWebKitMediaKeyCallbacks, isOldWebkitMediaElement, ICustomMediaKeys, ICustomMediaKeySession, getWebKitMediaKeysCallbacks, WebKitMediaKeysConstructor, };
@@ -1,159 +1,6 @@
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 { MediaError } from "../../../errors";
17
- import assert from "../../../utils/assert";
18
- import { isIE11 } from "../../browser_detection";
19
- import isNode from "../../is_node";
20
- import shouldFavourCustomSafariEME from "../../should_favour_custom_safari_EME";
21
- import CustomMediaKeySystemAccess from "./../custom_key_system_access";
22
1
  import getIE11MediaKeysCallbacks, { MSMediaKeysConstructor, } from "./ie11_media_keys";
23
2
  import getMozMediaKeysCallbacks, { MozMediaKeysConstructor, } from "./moz_media_keys_constructor";
24
3
  import getOldKitWebKitMediaKeyCallbacks, { isOldWebkitMediaElement, } from "./old_webkit_media_keys";
25
4
  import getWebKitMediaKeysCallbacks from "./webkit_media_keys";
26
5
  import { WebKitMediaKeysConstructor } from "./webkit_media_keys_constructor";
27
- var requestMediaKeySystemAccess = null;
28
- /**
29
- * Set the given MediaKeys on the given HTMLMediaElement.
30
- * Emits null when done then complete.
31
- * @param {HTMLMediaElement} elt
32
- * @param {Object} mediaKeys
33
- */
34
- var setMediaKeys = function defaultSetMediaKeys(mediaElement, mediaKeys) {
35
- var elt = mediaElement;
36
- /* eslint-disable @typescript-eslint/unbound-method */
37
- if (typeof elt.setMediaKeys === "function") {
38
- return elt.setMediaKeys(mediaKeys);
39
- }
40
- /* eslint-enable @typescript-eslint/unbound-method */
41
- // If we get in the following code, it means that no compat case has been
42
- // found and no standard setMediaKeys API exists. This case is particulary
43
- // rare. We will try to call each API with native media keys.
44
- if (typeof elt.webkitSetMediaKeys === "function") {
45
- return elt.webkitSetMediaKeys(mediaKeys);
46
- }
47
- if (typeof elt.mozSetMediaKeys === "function") {
48
- return elt.mozSetMediaKeys(mediaKeys);
49
- }
50
- if (typeof elt.msSetMediaKeys === "function" && mediaKeys !== null) {
51
- return elt.msSetMediaKeys(mediaKeys);
52
- }
53
- };
54
- /**
55
- * Since Safari 12.1, EME APIs are available without webkit prefix.
56
- * However, it seems that since fairplay CDM implementation within the browser is not
57
- * standard with EME w3c current spec, the requestMediaKeySystemAccess API doesn't resolve
58
- * positively, even if the drm (fairplay in most cases) is supported.
59
- *
60
- * Therefore, we prefer not to use requestMediaKeySystemAccess on Safari when webkit API
61
- * is available.
62
- */
63
- if (isNode ||
64
- (navigator.requestMediaKeySystemAccess != null && !shouldFavourCustomSafariEME())) {
65
- requestMediaKeySystemAccess = function () {
66
- var args = [];
67
- for (var _i = 0; _i < arguments.length; _i++) {
68
- args[_i] = arguments[_i];
69
- }
70
- return navigator.requestMediaKeySystemAccess.apply(navigator, args);
71
- };
72
- }
73
- else {
74
- var isTypeSupported_1;
75
- var createCustomMediaKeys_1;
76
- // This is for Chrome with unprefixed EME api
77
- if (isOldWebkitMediaElement(HTMLVideoElement.prototype)) {
78
- var callbacks = getOldKitWebKitMediaKeyCallbacks();
79
- isTypeSupported_1 = callbacks.isTypeSupported;
80
- createCustomMediaKeys_1 = callbacks.createCustomMediaKeys;
81
- setMediaKeys = callbacks.setMediaKeys;
82
- // This is for WebKit with prefixed EME api
83
- }
84
- else if (WebKitMediaKeysConstructor !== undefined) {
85
- var callbacks = getWebKitMediaKeysCallbacks();
86
- isTypeSupported_1 = callbacks.isTypeSupported;
87
- createCustomMediaKeys_1 = callbacks.createCustomMediaKeys;
88
- setMediaKeys = callbacks.setMediaKeys;
89
- }
90
- else if (isIE11 && MSMediaKeysConstructor !== undefined) {
91
- var callbacks = getIE11MediaKeysCallbacks();
92
- isTypeSupported_1 = callbacks.isTypeSupported;
93
- createCustomMediaKeys_1 = callbacks.createCustomMediaKeys;
94
- setMediaKeys = callbacks.setMediaKeys;
95
- }
96
- else if (MozMediaKeysConstructor !== undefined) {
97
- var callbacks = getMozMediaKeysCallbacks();
98
- isTypeSupported_1 = callbacks.isTypeSupported;
99
- createCustomMediaKeys_1 = callbacks.createCustomMediaKeys;
100
- setMediaKeys = callbacks.setMediaKeys;
101
- }
102
- else {
103
- var MK_1 = window.MediaKeys;
104
- var checkForStandardMediaKeys_1 = function () {
105
- if (MK_1 === undefined) {
106
- throw new MediaError("MEDIA_KEYS_NOT_SUPPORTED", "No `MediaKeys` implementation found " +
107
- "in the current browser.");
108
- }
109
- if (typeof MK_1.isTypeSupported === "undefined") {
110
- var message = "This browser seems to be unable to play encrypted contents " +
111
- "currently. Note: Some browsers do not allow decryption " +
112
- "in some situations, like when not using HTTPS.";
113
- throw new Error(message);
114
- }
115
- };
116
- isTypeSupported_1 = function (keyType) {
117
- checkForStandardMediaKeys_1();
118
- assert(typeof MK_1.isTypeSupported === "function");
119
- return MK_1.isTypeSupported(keyType);
120
- };
121
- createCustomMediaKeys_1 = function (keyType) {
122
- checkForStandardMediaKeys_1();
123
- return new MK_1(keyType);
124
- };
125
- }
126
- requestMediaKeySystemAccess = function (keyType, keySystemConfigurations) {
127
- if (!isTypeSupported_1(keyType)) {
128
- return Promise.reject(new Error("Unsupported key type"));
129
- }
130
- for (var i = 0; i < keySystemConfigurations.length; i++) {
131
- var keySystemConfiguration = keySystemConfigurations[i];
132
- var videoCapabilities = keySystemConfiguration.videoCapabilities, audioCapabilities = keySystemConfiguration.audioCapabilities, initDataTypes = keySystemConfiguration.initDataTypes, distinctiveIdentifier = keySystemConfiguration.distinctiveIdentifier;
133
- var supported = true;
134
- supported = supported &&
135
- (initDataTypes == null ||
136
- initDataTypes.some(function (idt) { return idt === "cenc"; }));
137
- supported = supported && (distinctiveIdentifier !== "required");
138
- if (supported) {
139
- var keySystemConfigurationResponse = {
140
- initDataTypes: ["cenc"],
141
- distinctiveIdentifier: "not-allowed",
142
- persistentState: "required",
143
- sessionTypes: ["temporary", "persistent-license"],
144
- };
145
- if (videoCapabilities !== undefined) {
146
- keySystemConfigurationResponse.videoCapabilities = videoCapabilities;
147
- }
148
- if (audioCapabilities !== undefined) {
149
- keySystemConfigurationResponse.audioCapabilities = audioCapabilities;
150
- }
151
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
152
- var customMediaKeys = createCustomMediaKeys_1(keyType);
153
- return Promise.resolve(new CustomMediaKeySystemAccess(keyType, customMediaKeys, keySystemConfigurationResponse));
154
- }
155
- }
156
- return Promise.reject(new Error("Unsupported configuration"));
157
- };
158
- }
159
- export { requestMediaKeySystemAccess, setMediaKeys, };
6
+ export { getIE11MediaKeysCallbacks, MSMediaKeysConstructor, getMozMediaKeysCallbacks, MozMediaKeysConstructor, getOldKitWebKitMediaKeyCallbacks, isOldWebkitMediaElement, getWebKitMediaKeysCallbacks, WebKitMediaKeysConstructor, };
@@ -23,5 +23,5 @@ export { MozMediaKeysConstructor };
23
23
  export default function getMozMediaKeysCallbacks(): {
24
24
  isTypeSupported: (keyType: string) => boolean;
25
25
  createCustomMediaKeys: (keyType: string) => ICustomMediaKeys;
26
- setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => void;
26
+ setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => Promise<unknown>;
27
27
  };
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import wrapInPromise from "../../../utils/wrapInPromise";
16
17
  import isNode from "../../is_node";
17
18
  var MozMediaKeysConstructor;
18
19
  if (!isNode) {
@@ -45,11 +46,14 @@ export default function getMozMediaKeysCallbacks() {
45
46
  return new MozMediaKeysConstructor(keyType);
46
47
  };
47
48
  var setMediaKeys = function (mediaElement, mediaKeys) {
48
- var elt = mediaElement;
49
- if (elt.mozSetMediaKeys === undefined || typeof elt.mozSetMediaKeys !== "function") {
50
- throw new Error("Can't set video on MozMediaKeys.");
51
- }
52
- return elt.mozSetMediaKeys(mediaKeys);
49
+ return wrapInPromise(function () {
50
+ var elt = mediaElement;
51
+ if (elt.mozSetMediaKeys === undefined ||
52
+ typeof elt.mozSetMediaKeys !== "function") {
53
+ throw new Error("Can't set video on MozMediaKeys.");
54
+ }
55
+ return elt.mozSetMediaKeys(mediaKeys);
56
+ });
53
57
  };
54
58
  return {
55
59
  isTypeSupported: isTypeSupported,
@@ -29,13 +29,13 @@ declare class OldWebKitCustomMediaKeys implements ICustomMediaKeys {
29
29
  private readonly _keySystem;
30
30
  private _videoElement?;
31
31
  constructor(keySystem: string);
32
- _setVideo(videoElement: IOldWebkitHTMLMediaElement | HTMLMediaElement): void;
32
+ _setVideo(videoElement: IOldWebkitHTMLMediaElement | HTMLMediaElement): Promise<unknown>;
33
33
  createSession(): ICustomMediaKeySession;
34
34
  setServerCertificate(): Promise<void>;
35
35
  }
36
36
  export default function getOldWebKitMediaKeysCallbacks(): {
37
37
  isTypeSupported: (keyType: string) => boolean;
38
38
  createCustomMediaKeys: (keyType: string) => OldWebKitCustomMediaKeys;
39
- setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => void;
39
+ setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => Promise<unknown>;
40
40
  };
41
41
  export {};
@@ -32,6 +32,7 @@ import { base64ToBytes } from "../../../utils/base64";
32
32
  import EventEmitter from "../../../utils/event_emitter";
33
33
  import noop from "../../../utils/noop";
34
34
  import { utf8ToStr } from "../../../utils/string_parsing";
35
+ import wrapInPromise from "../../../utils/wrapInPromise";
35
36
  /**
36
37
  * Returns true if the given media element has old webkit methods
37
38
  * corresponding to the IOldWebkitHTMLMediaElement interface.
@@ -138,10 +139,13 @@ var OldWebKitCustomMediaKeys = /** @class */ (function () {
138
139
  this._keySystem = keySystem;
139
140
  }
140
141
  OldWebKitCustomMediaKeys.prototype._setVideo = function (videoElement) {
141
- if (!isOldWebkitMediaElement(videoElement)) {
142
- throw new Error("Video not attached to the MediaKeys");
143
- }
144
- this._videoElement = videoElement;
142
+ var _this = this;
143
+ return wrapInPromise(function () {
144
+ if (!isOldWebkitMediaElement(videoElement)) {
145
+ throw new Error("Video not attached to the MediaKeys");
146
+ }
147
+ _this._videoElement = videoElement;
148
+ });
145
149
  };
146
150
  OldWebKitCustomMediaKeys.prototype.createSession = function ( /* sessionType */) {
147
151
  if (this._videoElement == null) {
@@ -172,7 +176,7 @@ export default function getOldWebKitMediaKeysCallbacks() {
172
176
  var createCustomMediaKeys = function (keyType) { return new OldWebKitCustomMediaKeys(keyType); };
173
177
  var setMediaKeys = function (elt, mediaKeys) {
174
178
  if (mediaKeys === null) {
175
- return;
179
+ return Promise.resolve(undefined);
176
180
  }
177
181
  if (!(mediaKeys instanceof OldWebKitCustomMediaKeys)) {
178
182
  throw new Error("Custom setMediaKeys is supposed to be called " +
@@ -28,7 +28,7 @@ export interface ICustomMediaKeySession extends IEventEmitter<IMediaKeySessionEv
28
28
  remove(): Promise<void>;
29
29
  }
30
30
  export interface ICustomMediaKeys {
31
- _setVideo: (vid: HTMLMediaElement) => void;
31
+ _setVideo: (vid: HTMLMediaElement) => Promise<unknown>;
32
32
  createSession(sessionType?: MediaKeySessionType): ICustomMediaKeySession;
33
33
  setServerCertificate(setServerCertificate: BufferSource): Promise<void>;
34
34
  }
@@ -25,13 +25,13 @@ declare class WebKitCustomMediaKeys implements ICustomWebKitMediaKeys {
25
25
  private _serverCertificate?;
26
26
  private _keyType;
27
27
  constructor(keyType: string);
28
- _setVideo(videoElement: HTMLMediaElement): void;
28
+ _setVideo(videoElement: HTMLMediaElement): Promise<unknown>;
29
29
  createSession(): ICustomMediaKeySession;
30
30
  setServerCertificate(serverCertificate: Uint8Array): Promise<void>;
31
31
  }
32
32
  export default function getWebKitMediaKeysCallbacks(): {
33
33
  isTypeSupported: (keyType: string) => boolean;
34
34
  createCustomMediaKeys: (keyType: string) => WebKitCustomMediaKeys;
35
- setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => void;
35
+ setMediaKeys: (elt: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => Promise<unknown>;
36
36
  };
37
37
  export {};
@@ -30,6 +30,8 @@ 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 startsWith from "../../../utils/starts_with";
34
+ import wrapInPromise from "../../../utils/wrapInPromise";
33
35
  import getWebKitFairplayInitData from "../get_webkit_fairplay_initdata";
34
36
  import { WebKitMediaKeysConstructor, } from "./webkit_media_keys_constructor";
35
37
  /**
@@ -38,21 +40,23 @@ import { WebKitMediaKeysConstructor, } from "./webkit_media_keys_constructor";
38
40
  * @returns {boolean}
39
41
  */
40
42
  function isFairplayKeyType(keyType) {
41
- return keyType === "com.apple.fps.1_0" ||
42
- keyType === "com.apple.fps.2_0";
43
+ return startsWith(keyType, "com.apple.fps");
43
44
  }
44
45
  /**
45
46
  * Set media keys on video element using native HTMLMediaElement
46
47
  * setMediaKeys from WebKit.
47
48
  * @param {HTMLMediaElement} videoElement
48
49
  * @param {Object|null} mediaKeys
50
+ * @returns {Promise}
49
51
  */
50
52
  function setWebKitMediaKeys(videoElement, mediaKeys) {
51
53
  var elt = videoElement;
52
- if (elt.webkitSetMediaKeys === undefined) {
53
- throw new Error("No webKitMediaKeys API.");
54
- }
55
- return elt.webkitSetMediaKeys(mediaKeys);
54
+ return wrapInPromise(function () {
55
+ if (elt.webkitSetMediaKeys === undefined) {
56
+ throw new Error("No webKitMediaKeys API.");
57
+ }
58
+ elt.webkitSetMediaKeys(mediaKeys);
59
+ });
56
60
  }
57
61
  /**
58
62
  * On Safari browsers (>= 9), there are specific webkit prefixed APIs for cyphered
@@ -0,0 +1,78 @@
1
+ import { CancellationSignal } from "../../utils/task_canceller";
2
+ import { IEventTargetLike } from "../event_listeners";
3
+ import CustomMediaKeySystemAccess from "./custom_key_system_access";
4
+ import { ICustomMediaKeys } from "./custom_media_keys/types";
5
+ /**
6
+ * Automatically detect and set which EME implementation should be used in the
7
+ * current platform.
8
+ *
9
+ * You can call `getEmeApiImplementation` for a different implementation.
10
+ */
11
+ declare const defaultEmeImplementation: IEmeApiImplementation;
12
+ export default defaultEmeImplementation;
13
+ /**
14
+ * Generic interface harmonizing the structure of the different EME API
15
+ * implementations the RxPlayer could use.
16
+ */
17
+ export interface IEmeApiImplementation {
18
+ /**
19
+ * API implementing the `navigator.requestMediaKeySystemAccess` static method
20
+ * from EME.
21
+ * @param {string} keyType - Key system name, as a reverse domain name.
22
+ * @param {Array.<MediaKeySystemMediaCapability>} Wanted configurations, from
23
+ * the most wanted to the least.
24
+ * @returns {Promise}
25
+ */
26
+ requestMediaKeySystemAccess: (keyType: string, config: MediaKeySystemConfiguration[]) => Promise<MediaKeySystemAccess | CustomMediaKeySystemAccess>;
27
+ /**
28
+ * API allowing to listen for `"encrypted"` events, presumably sent by the
29
+ * HTMLMediaElement on which encrypted content is pushed.
30
+ * @param {EventTarget} The element on which the event will be listened to.
31
+ * Generally it is the HTMLMediaElement.
32
+ * @param {Function} listener - The event listener on which that event's
33
+ * payload will be dispatched.
34
+ * @param {Object} cancelSignal - The event listener will be removed once that
35
+ * `CancellationSignal` emits.
36
+ */
37
+ onEncrypted: (target: IEventTargetLike, listener: (evt: unknown) => void, cancelSignal: CancellationSignal) => void;
38
+ /**
39
+ * API allowing to attach a `MediaKeys` instance (or an `ICustomMediaKeys`) to
40
+ * the HTMLMediaElement so it can start decoding.
41
+ * @param {HTMLMediaElement} The HTMLMediaElement on which the content plays.
42
+ * @param {MediaKeys} mediaKeys - The MediaKeys instance to attach.
43
+ * @returns {Promise} - That promise resolves if the `MediaKeys` instance was
44
+ * attached to the `HTMLMediaElement` with success, or rejects on the opposite
45
+ * scenario.
46
+ */
47
+ setMediaKeys: (mediaElement: HTMLMediaElement, mediaKeys: MediaKeys | ICustomMediaKeys | null) => Promise<unknown>;
48
+ /**
49
+ * String describing the currently used EME implementation:
50
+ *
51
+ * - "standard": regular EME implementation
52
+ *
53
+ * - "webkit": The webkit-prefixed variant of the EME API
54
+ *
55
+ * - "older-webkit": An even older webkit-prefixed variant of the EME API
56
+ *
57
+ * - "ms": The ms-prefixed variant of the EME API
58
+ *
59
+ * - "moz": The moz-prefixed variant of the EME API
60
+ *
61
+ * - "unknown": An unidentified variant of the EME API
62
+ */
63
+ implementation: "standard" | "webkit" | "older-webkit" | "ms" | "moz" | "unknown";
64
+ }
65
+ /**
66
+ * Union of all the different value the preferred EME API type can be set to:
67
+ *
68
+ * - "auto": The implementation will be chosen automatically based on what
69
+ * we've most confidence on on the current device.
70
+ *
71
+ * - "standard": If present, the standard EME API will be given precedence
72
+ * over custom and browser-specific ones.
73
+ *
74
+ * - "webkit": The webkit-prefixed variant of the EME API will be given
75
+ * precedence over any other one if present.
76
+ *
77
+ */
78
+ export type IPreferredEmeApiType = "auto" | "standard" | "webkit";