rx-player 4.0.0-dev.2023110700 → 4.0.0-dev.2023120600

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 (479) hide show
  1. package/CHANGELOG.md +18 -226
  2. package/FILES.md +1 -1
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/add_text_track.d.ts +1 -3
  5. package/dist/_esm5.processed/compat/add_text_track.js +4 -7
  6. package/dist/_esm5.processed/compat/browser_compatibility_types.d.ts +0 -7
  7. package/dist/_esm5.processed/compat/event_listeners.d.ts +2 -15
  8. package/dist/_esm5.processed/compat/event_listeners.js +2 -37
  9. package/dist/_esm5.processed/compat/index.d.ts +1 -3
  10. package/dist/_esm5.processed/compat/index.js +1 -3
  11. package/dist/_esm5.processed/config.d.ts +9 -21
  12. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.d.ts +0 -58
  13. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +14 -54
  14. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.d.ts +2 -8
  15. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.js +2 -11
  16. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
  17. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +13 -32
  18. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +3 -3
  19. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +1 -1
  20. package/dist/_esm5.processed/core/api/option_utils.d.ts +14 -35
  21. package/dist/_esm5.processed/core/api/option_utils.js +47 -230
  22. package/dist/_esm5.processed/core/api/public_api.d.ts +92 -266
  23. package/dist/_esm5.processed/core/api/public_api.js +451 -807
  24. package/dist/_esm5.processed/core/{segment_buffers/implementations/image → api/track_management}/index.d.ts +3 -2
  25. package/dist/_esm5.processed/core/{segment_buffers/implementations/image → api/track_management}/index.js +3 -2
  26. package/dist/_esm5.processed/core/api/{tracks_management/media_element_track_choice_manager.d.ts → track_management/media_element_tracks_store.d.ts} +15 -75
  27. package/dist/_esm5.processed/core/api/{tracks_management/media_element_track_choice_manager.js → track_management/media_element_tracks_store.js} +74 -193
  28. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +84 -0
  29. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +158 -0
  30. package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +406 -0
  31. package/dist/_esm5.processed/core/api/track_management/tracks_store.js +932 -0
  32. package/dist/_esm5.processed/core/api/utils.d.ts +1 -0
  33. package/dist/_esm5.processed/core/api/utils.js +28 -11
  34. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +3 -3
  35. package/dist/_esm5.processed/core/decrypt/find_key_system.js +83 -71
  36. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +6 -5
  37. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +10 -72
  38. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +4 -4
  39. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +6 -4
  40. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +1 -3
  41. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +7 -26
  42. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +3 -9
  43. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +16 -9
  44. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -3
  45. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +1 -1
  46. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.d.ts +1 -6
  47. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +4 -41
  48. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  49. package/dist/_esm5.processed/core/init/media_source_content_initializer.d.ts +1 -8
  50. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +5 -19
  51. package/dist/_esm5.processed/core/init/types.d.ts +5 -15
  52. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +2 -36
  53. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +2 -82
  54. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/text_track_cues_store.js +54 -6
  55. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.d.ts +2 -1
  56. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.js +19 -2
  57. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +1 -2
  58. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +2 -3
  59. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +2 -2
  60. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  61. package/dist/_esm5.processed/core/segment_buffers/index.js +2 -1
  62. package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +1 -0
  63. package/dist/_esm5.processed/core/segment_buffers/inventory/index.js +1 -0
  64. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.d.ts +33 -0
  65. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.js +49 -0
  66. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.d.ts +0 -1
  67. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +2 -16
  68. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +0 -15
  69. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +183 -93
  70. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.d.ts +39 -0
  71. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.js +133 -0
  72. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +27 -13
  73. package/dist/_esm5.processed/core/stream/index.d.ts +2 -3
  74. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +2 -0
  75. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +5 -7
  76. package/dist/_esm5.processed/core/stream/period/period_stream.js +13 -12
  77. package/dist/_esm5.processed/core/stream/period/types.d.ts +5 -14
  78. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +2 -4
  79. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.js +10 -46
  80. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +29 -23
  81. package/dist/_esm5.processed/core/stream/representation/types.d.ts +11 -1
  82. package/dist/_esm5.processed/default_config.d.ts +35 -98
  83. package/dist/_esm5.processed/default_config.js +36 -113
  84. package/dist/_esm5.processed/errors/custom_loader_error.d.ts +1 -3
  85. package/dist/_esm5.processed/errors/custom_loader_error.js +1 -3
  86. package/dist/_esm5.processed/errors/media_error.js +2 -2
  87. package/dist/_esm5.processed/errors/network_error.d.ts +0 -1
  88. package/dist/_esm5.processed/errors/network_error.js +0 -1
  89. package/dist/_esm5.processed/errors/request_error.d.ts +2 -3
  90. package/dist/_esm5.processed/errors/request_error.js +2 -5
  91. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -3
  92. package/dist/_esm5.processed/features/features_object.js +0 -2
  93. package/dist/_esm5.processed/features/list/directfile.js +2 -5
  94. package/dist/_esm5.processed/features/list/index.d.ts +0 -2
  95. package/dist/_esm5.processed/features/list/index.js +0 -2
  96. package/dist/_esm5.processed/features/types.d.ts +3 -27
  97. package/dist/_esm5.processed/manifest/adaptation.d.ts +9 -11
  98. package/dist/_esm5.processed/manifest/adaptation.js +41 -30
  99. package/dist/_esm5.processed/manifest/index.d.ts +3 -4
  100. package/dist/_esm5.processed/manifest/manifest.d.ts +5 -54
  101. package/dist/_esm5.processed/manifest/manifest.js +5 -110
  102. package/dist/_esm5.processed/manifest/period.d.ts +4 -5
  103. package/dist/_esm5.processed/manifest/representation.d.ts +10 -5
  104. package/dist/_esm5.processed/manifest/representation.js +33 -10
  105. package/dist/_esm5.processed/manifest/representation_index/index.d.ts +2 -2
  106. package/dist/_esm5.processed/manifest/representation_index/static.d.ts +2 -0
  107. package/dist/_esm5.processed/manifest/representation_index/static.js +6 -0
  108. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +42 -21
  109. package/dist/_esm5.processed/manifest/types.d.ts +0 -2
  110. package/dist/_esm5.processed/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +17 -0
  111. package/dist/_esm5.processed/parsers/manifest/dash/common/convert_supplemental_codecs.js +26 -0
  112. package/dist/_esm5.processed/parsers/manifest/dash/common/flatten_overlapping_periods.js +5 -0
  113. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +17 -31
  114. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +26 -19
  115. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +2 -0
  116. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +7 -1
  117. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +2 -6
  118. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +11 -8
  119. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -0
  120. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +6 -0
  121. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
  122. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.js +1 -6
  123. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +3 -5
  124. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +0 -2
  125. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -1
  126. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +2 -2
  127. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +0 -2
  128. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +2 -2
  129. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +29 -17
  130. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +13 -6
  131. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +7 -2
  132. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +10 -1
  133. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +18 -2
  134. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +6 -4
  135. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +7 -6
  136. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +5 -2
  137. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  138. package/dist/_esm5.processed/parsers/manifest/local/representation_index.d.ts +2 -0
  139. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +6 -0
  140. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +6 -6
  141. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.d.ts +12 -3
  142. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +11 -2
  143. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +0 -1
  144. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +11 -17
  145. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +21 -83
  146. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +53 -125
  147. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +119 -0
  148. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.js +159 -0
  149. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.d.ts +3 -6
  150. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.js +4 -4
  151. package/dist/_esm5.processed/parsers/manifest/types.d.ts +4 -3
  152. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +1 -8
  153. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
  154. package/dist/_esm5.processed/public_types.d.ts +396 -308
  155. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.d.ts +5 -4
  156. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +5 -4
  157. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +4 -4
  158. package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -3
  159. package/dist/_esm5.processed/transports/dash/pipelines.js +1 -4
  160. package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
  161. package/dist/_esm5.processed/transports/dash/segment_loader.js +26 -20
  162. package/dist/_esm5.processed/transports/dash/segment_parser.js +19 -24
  163. package/dist/_esm5.processed/transports/dash/text_loader.js +5 -5
  164. package/dist/_esm5.processed/transports/dash/text_parser.js +28 -33
  165. package/dist/_esm5.processed/transports/local/pipelines.js +1 -10
  166. package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
  167. package/dist/_esm5.processed/transports/local/segment_parser.d.ts +1 -1
  168. package/dist/_esm5.processed/transports/local/segment_parser.js +10 -10
  169. package/dist/_esm5.processed/transports/local/text_parser.d.ts +2 -2
  170. package/dist/_esm5.processed/transports/local/text_parser.js +23 -23
  171. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +34 -52
  172. package/dist/_esm5.processed/{utils/list_to_map.d.ts → transports/smooth/is_mp4_embedded_track.d.ts} +5 -5
  173. package/dist/_esm5.processed/{features/list/image_buffer.d.ts → transports/smooth/is_mp4_embedded_track.js} +7 -6
  174. package/dist/_esm5.processed/transports/smooth/pipelines.js +33 -190
  175. package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +1 -1
  176. package/dist/_esm5.processed/transports/smooth/segment_loader.js +28 -22
  177. package/dist/_esm5.processed/transports/smooth/utils.d.ts +1 -26
  178. package/dist/_esm5.processed/transports/smooth/utils.js +1 -55
  179. package/dist/_esm5.processed/transports/types.d.ts +94 -89
  180. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
  181. package/dist/_esm5.processed/transports/utils/infer_segment_container.d.ts +3 -3
  182. package/dist/_esm5.processed/transports/utils/infer_segment_container.js +5 -7
  183. package/dist/_esm5.processed/transports/utils/parse_text_track.d.ts +8 -12
  184. package/dist/_esm5.processed/transports/utils/parse_text_track.js +19 -21
  185. package/dist/_esm5.processed/utils/array_includes.d.ts +2 -1
  186. package/dist/_esm5.processed/utils/array_includes.js +30 -28
  187. package/dist/_esm5.processed/utils/request/xhr.js +5 -5
  188. package/dist/commonjs/compat/is_codec_supported.js +22 -1
  189. package/dist/commonjs/compat/patch_webkit_source_buffer.js +2 -2
  190. package/dist/commonjs/config.d.ts +1 -0
  191. package/dist/commonjs/core/api/debug/buffer_graph.js +2 -6
  192. package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
  193. package/dist/commonjs/core/api/option_utils.d.ts +4 -0
  194. package/dist/commonjs/core/api/option_utils.js +8 -3
  195. package/dist/commonjs/core/api/public_api.d.ts +11 -1
  196. package/dist/commonjs/core/api/public_api.js +46 -11
  197. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  198. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
  199. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  200. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
  201. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  202. package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
  203. package/dist/commonjs/core/init/directfile_content_initializer.js +24 -7
  204. package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
  205. package/dist/commonjs/core/init/media_source_content_initializer.js +4 -6
  206. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  207. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +16 -17
  208. package/dist/commonjs/core/init/utils/get_initial_time.d.ts +17 -3
  209. package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
  210. package/dist/commonjs/core/segment_buffers/implementations/text/html/text_track_cues_store.js +54 -6
  211. package/dist/commonjs/core/segment_buffers/implementations/text/html/utils.d.ts +2 -1
  212. package/dist/commonjs/core/segment_buffers/implementations/text/html/utils.js +19 -2
  213. package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +2 -2
  214. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +3 -3
  215. package/dist/commonjs/core/stream/period/period_stream.js +2 -2
  216. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +3 -3
  217. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  218. package/dist/commonjs/default_config.d.ts +5 -0
  219. package/dist/commonjs/default_config.js +5 -0
  220. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  221. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  222. package/dist/commonjs/manifest/representation.js +18 -5
  223. package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
  224. package/dist/commonjs/manifest/representation_index/static.js +2 -2
  225. package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
  226. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +17 -0
  227. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.js +30 -0
  228. package/dist/commonjs/parsers/manifest/dash/common/flatten_overlapping_periods.js +5 -0
  229. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  230. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
  231. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  232. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  233. package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  234. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  235. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
  236. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  237. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
  238. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  239. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  240. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
  241. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  242. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  243. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
  244. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
  245. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  246. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
  247. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  248. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
  249. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +36 -20
  250. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +3 -0
  251. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Representation.js +3 -0
  252. package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts +2 -0
  253. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +4 -0
  254. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +4 -0
  255. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  256. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
  257. package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
  258. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  259. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
  260. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
  261. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
  262. package/dist/commonjs/parsers/manifest/types.d.ts +1 -0
  263. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
  264. package/dist/commonjs/public_types.d.ts +78 -34
  265. package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
  266. package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
  267. package/dist/commonjs/transports/dash/segment_loader.js +2 -1
  268. package/dist/commonjs/transports/dash/text_loader.js +2 -0
  269. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
  270. package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
  271. package/dist/commonjs/transports/smooth/pipelines.js +4 -2
  272. package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
  273. package/dist/commonjs/transports/types.d.ts +12 -0
  274. package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
  275. package/dist/commonjs/utils/queue_microtask.d.ts +2 -0
  276. package/dist/commonjs/utils/queue_microtask.js +7 -0
  277. package/dist/commonjs/utils/request/fetch.d.ts +6 -0
  278. package/dist/commonjs/utils/request/fetch.js +29 -8
  279. package/dist/commonjs/utils/request/xhr.d.ts +11 -5
  280. package/dist/commonjs/utils/request/xhr.js +29 -8
  281. package/dist/es2017/compat/is_codec_supported.js +22 -1
  282. package/dist/es2017/compat/patch_webkit_source_buffer.js +2 -2
  283. package/dist/es2017/config.d.ts +1 -0
  284. package/dist/es2017/core/api/debug/buffer_graph.js +2 -6
  285. package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
  286. package/dist/es2017/core/api/option_utils.d.ts +4 -0
  287. package/dist/es2017/core/api/option_utils.js +8 -3
  288. package/dist/es2017/core/api/public_api.d.ts +11 -1
  289. package/dist/es2017/core/api/public_api.js +44 -9
  290. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  291. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
  292. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  293. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
  294. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  295. package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
  296. package/dist/es2017/core/init/directfile_content_initializer.js +24 -7
  297. package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
  298. package/dist/es2017/core/init/media_source_content_initializer.js +4 -6
  299. package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  300. package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +16 -15
  301. package/dist/es2017/core/init/utils/get_initial_time.d.ts +17 -3
  302. package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
  303. package/dist/es2017/core/segment_buffers/implementations/text/html/text_track_cues_store.js +54 -6
  304. package/dist/es2017/core/segment_buffers/implementations/text/html/utils.d.ts +2 -1
  305. package/dist/es2017/core/segment_buffers/implementations/text/html/utils.js +18 -2
  306. package/dist/es2017/core/stream/adaptation/adaptation_stream.js +2 -2
  307. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +3 -3
  308. package/dist/es2017/core/stream/period/period_stream.js +2 -2
  309. package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +3 -3
  310. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  311. package/dist/es2017/default_config.d.ts +5 -0
  312. package/dist/es2017/default_config.js +5 -0
  313. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  314. package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  315. package/dist/es2017/manifest/representation.js +18 -5
  316. package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
  317. package/dist/es2017/manifest/representation_index/static.js +2 -2
  318. package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
  319. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +17 -0
  320. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.js +26 -0
  321. package/dist/es2017/parsers/manifest/dash/common/flatten_overlapping_periods.js +5 -0
  322. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  323. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
  324. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  325. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  326. package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  327. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  328. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
  329. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  330. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
  331. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  332. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  333. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
  334. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  335. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  336. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
  337. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
  338. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  339. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
  340. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  341. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
  342. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +36 -20
  343. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +3 -0
  344. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Representation.js +3 -0
  345. package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts +2 -0
  346. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +4 -0
  347. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +4 -0
  348. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  349. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
  350. package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
  351. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  352. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
  353. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
  354. package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
  355. package/dist/es2017/parsers/manifest/types.d.ts +1 -0
  356. package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
  357. package/dist/es2017/public_types.d.ts +78 -34
  358. package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
  359. package/dist/es2017/transports/dash/manifest_parser.js +3 -0
  360. package/dist/es2017/transports/dash/segment_loader.js +1 -0
  361. package/dist/es2017/transports/dash/text_loader.js +2 -0
  362. package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
  363. package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
  364. package/dist/es2017/transports/smooth/pipelines.js +2 -0
  365. package/dist/es2017/transports/smooth/segment_loader.js +1 -0
  366. package/dist/es2017/transports/types.d.ts +12 -0
  367. package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
  368. package/dist/es2017/utils/queue_microtask.d.ts +2 -0
  369. package/dist/es2017/utils/queue_microtask.js +5 -0
  370. package/dist/es2017/utils/request/fetch.d.ts +6 -0
  371. package/dist/es2017/utils/request/fetch.js +29 -8
  372. package/dist/es2017/utils/request/xhr.d.ts +11 -5
  373. package/dist/es2017/utils/request/xhr.js +30 -9
  374. package/dist/mpd-parser.wasm +0 -0
  375. package/dist/rx-player.js +900 -492
  376. package/dist/rx-player.min.js +1 -1
  377. package/package.json +3 -7
  378. package/scripts/update-version +2 -0
  379. package/sonar-project.properties +1 -1
  380. package/src/compat/is_codec_supported.ts +23 -1
  381. package/src/compat/patch_webkit_source_buffer.ts +2 -2
  382. package/src/core/api/debug/buffer_graph.ts +2 -5
  383. package/src/core/api/debug/modules/general_info.ts +15 -10
  384. package/src/core/api/option_utils.ts +11 -3
  385. package/src/core/api/public_api.ts +48 -8
  386. package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
  387. package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
  388. package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
  389. package/src/core/fetchers/utils/schedule_request.ts +1 -1
  390. package/src/core/init/directfile_content_initializer.ts +23 -7
  391. package/src/core/init/media_source_content_initializer.ts +13 -7
  392. package/src/core/init/utils/content_time_boundaries_observer.ts +23 -22
  393. package/src/core/init/utils/get_initial_time.ts +25 -12
  394. package/src/core/segment_buffers/implementations/text/html/__tests__/utils.test.ts +15 -0
  395. package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +57 -6
  396. package/src/core/segment_buffers/implementations/text/html/utils.ts +19 -2
  397. package/src/core/stream/adaptation/adaptation_stream.ts +2 -2
  398. package/src/core/stream/orchestrator/stream_orchestrator.ts +3 -3
  399. package/src/core/stream/period/period_stream.ts +2 -2
  400. package/src/core/stream/representation/utils/get_buffer_status.ts +3 -3
  401. package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
  402. package/src/default_config.ts +5 -0
  403. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
  404. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
  405. package/src/manifest/representation.ts +19 -6
  406. package/src/manifest/representation_index/static.ts +2 -2
  407. package/src/manifest/representation_index/types.ts +4 -4
  408. package/src/parsers/manifest/dash/common/__tests__/convert_supplemental_codecs.test.ts +37 -0
  409. package/src/parsers/manifest/dash/common/__tests__/flatten_overlapping_period.test.ts +20 -0
  410. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
  411. package/src/parsers/manifest/dash/common/convert_supplemental_codecs.ts +32 -0
  412. package/src/parsers/manifest/dash/common/flatten_overlapping_periods.ts +5 -0
  413. package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
  414. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
  415. package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
  416. package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
  417. package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
  418. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
  419. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
  420. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
  421. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
  422. package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
  423. package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
  424. package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
  425. package/src/parsers/manifest/dash/common/parse_representations.ts +39 -20
  426. package/src/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.ts +4 -0
  427. package/src/parsers/manifest/dash/js-parser/node_parsers/Representation.ts +4 -0
  428. package/src/parsers/manifest/dash/node_parser_types.ts +2 -0
  429. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +2 -0
  430. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +2 -0
  431. package/src/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.ts +4 -0
  432. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Representation.ts +4 -0
  433. package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +2 -0
  434. package/src/parsers/manifest/local/representation_index.ts +3 -3
  435. package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
  436. package/src/parsers/manifest/smooth/representation_index.ts +23 -9
  437. package/src/parsers/manifest/types.ts +2 -0
  438. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
  439. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
  440. package/src/parsers/manifest/utils/index_helpers.ts +1 -1
  441. package/src/public_types.ts +79 -34
  442. package/src/transports/dash/init_segment_loader.ts +5 -0
  443. package/src/transports/dash/manifest_parser.ts +6 -0
  444. package/src/transports/dash/segment_loader.ts +1 -0
  445. package/src/transports/dash/text_loader.ts +2 -0
  446. package/src/transports/metaplaylist/manifest_loader.ts +1 -0
  447. package/src/transports/metaplaylist/pipelines.ts +4 -1
  448. package/src/transports/smooth/pipelines.ts +2 -0
  449. package/src/transports/smooth/segment_loader.ts +1 -0
  450. package/src/transports/types.ts +12 -0
  451. package/src/transports/utils/generate_manifest_loader.ts +3 -0
  452. package/src/utils/queue_microtask.ts +7 -0
  453. package/src/utils/request/fetch.ts +35 -8
  454. package/src/utils/request/xhr.ts +45 -14
  455. package/dist/_esm5.processed/compat/fullscreen.d.ts +0 -32
  456. package/dist/_esm5.processed/compat/fullscreen.js +0 -78
  457. package/dist/_esm5.processed/compat/is_offline.d.ts +0 -39
  458. package/dist/_esm5.processed/compat/is_offline.js +0 -43
  459. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +0 -258
  460. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.js +0 -989
  461. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +0 -75
  462. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +0 -133
  463. package/dist/_esm5.processed/features/list/bif_parser.d.ts +0 -23
  464. package/dist/_esm5.processed/features/list/bif_parser.js +0 -27
  465. package/dist/_esm5.processed/features/list/image_buffer.js +0 -25
  466. package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +0 -38
  467. package/dist/_esm5.processed/transports/dash/image_pipelines.js +0 -129
  468. package/dist/_esm5.processed/utils/list_to_map.js +0 -28
  469. package/dist/_esm5.processed/utils/simple_set.d.ts +0 -51
  470. package/dist/_esm5.processed/utils/simple_set.js +0 -57
  471. package/dist/_esm5.processed/utils/uniq.d.ts +0 -36
  472. package/dist/_esm5.processed/utils/uniq.js +0 -43
  473. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  474. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
  475. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  476. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
  477. package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
  478. package/src/typings/next-tick.d.ts +0 -23
  479. package/src/typings/object-assign.d.ts +0 -48
@@ -43,32 +43,32 @@ var __assign = (this && this.__assign) || function () {
43
43
  * This file defines the public API for the RxPlayer.
44
44
  * It also starts the different sub-parts of the player on various API calls.
45
45
  */
46
- import { events, exitFullscreen, getStartDate, isFullscreen, requestFullscreen, } from "../../compat";
46
+ import { events, getStartDate, } from "../../compat";
47
47
  /* eslint-disable-next-line max-len */
48
48
  import canRelyOnVideoVisibilityAndSize from "../../compat/can_rely_on_video_visibility_and_size";
49
49
  import config from "../../config";
50
50
  import { ErrorCodes, ErrorTypes, formatError, MediaError, } from "../../errors";
51
51
  import features, { addFeatures, } from "../../features";
52
52
  import log from "../../log";
53
- import areArraysOfNumbersEqual from "../../utils/are_arrays_of_numbers_equal";
54
53
  import arrayIncludes from "../../utils/array_includes";
55
54
  import assert from "../../utils/assert";
55
+ import assertUnreachable from "../../utils/assert_unreachable";
56
56
  import EventEmitter from "../../utils/event_emitter";
57
57
  import idGenerator from "../../utils/id_generator";
58
58
  import isNullOrUndefined from "../../utils/is_null_or_undefined";
59
59
  import objectAssign from "../../utils/object_assign";
60
- import { getLeftSizeOfRange, getPlayedSizeOfRange, getSizeOfRange, } from "../../utils/ranges";
60
+ import { getLeftSizeOfRange } from "../../utils/ranges";
61
61
  import SharedReference, { createMappedReference, } from "../../utils/reference";
62
62
  import TaskCanceller from "../../utils/task_canceller";
63
63
  import warnOnce from "../../utils/warn_once";
64
64
  import { clearOnStop, disposeDecryptionResources, getKeySystemConfiguration, getCurrentKeySystem, } from "../decrypt";
65
65
  import { checkReloadOptions, parseConstructorOptions, parseLoadVideoOptions, } from "./option_utils";
66
66
  import PlaybackObserver from "./playback_observer";
67
- import TrackChoiceManager from "./tracks_management/track_choice_manager";
67
+ import TracksStore from "./track_management/tracks_store";
68
68
  import { constructPlayerStateReference, emitPlayPauseEvents, emitSeekEvents, isLoadedState, } from "./utils";
69
69
  /* eslint-disable @typescript-eslint/naming-convention */
70
70
  var generateContentId = idGenerator();
71
- var getPageActivityRef = events.getPageActivityRef, getPictureOnPictureStateRef = events.getPictureOnPictureStateRef, getVideoVisibilityRef = events.getVideoVisibilityRef, getVideoWidthRef = events.getVideoWidthRef, onFullscreenChange = events.onFullscreenChange, onTextTrackAdded = events.onTextTrackAdded, onTextTrackRemoved = events.onTextTrackRemoved;
71
+ var getPictureOnPictureStateRef = events.getPictureOnPictureStateRef, getVideoVisibilityRef = events.getVideoVisibilityRef, getVideoWidthRef = events.getVideoWidthRef;
72
72
  /**
73
73
  * @class Player
74
74
  * @extends EventEmitter
@@ -81,64 +81,19 @@ var Player = /** @class */ (function (_super) {
81
81
  */
82
82
  function Player(options) {
83
83
  if (options === void 0) { options = {}; }
84
- var _a, _b;
85
84
  var _this = _super.call(this) || this;
86
- var _c = parseConstructorOptions(options), initialAudioBitrate = _c.initialAudioBitrate, initialVideoBitrate = _c.initialVideoBitrate, limitVideoWidth = _c.limitVideoWidth, minAudioBitrate = _c.minAudioBitrate, minVideoBitrate = _c.minVideoBitrate, maxAudioBitrate = _c.maxAudioBitrate, maxBufferAhead = _c.maxBufferAhead, maxBufferBehind = _c.maxBufferBehind, maxVideoBitrate = _c.maxVideoBitrate, preferredAudioTracks = _c.preferredAudioTracks, preferredTextTracks = _c.preferredTextTracks, preferredVideoTracks = _c.preferredVideoTracks, throttleWhenHidden = _c.throttleWhenHidden, throttleVideoBitrateWhenHidden = _c.throttleVideoBitrateWhenHidden, videoElement = _c.videoElement, wantedBufferAhead = _c.wantedBufferAhead, maxVideoBufferSize = _c.maxVideoBufferSize, stopAtEnd = _c.stopAtEnd;
85
+ var _a = parseConstructorOptions(options), baseBandwidth = _a.baseBandwidth, limitVideoWidth = _a.limitVideoWidth, maxBufferAhead = _a.maxBufferAhead, maxBufferBehind = _a.maxBufferBehind, throttleVideoBitrateWhenHidden = _a.throttleVideoBitrateWhenHidden, videoElement = _a.videoElement, wantedBufferAhead = _a.wantedBufferAhead, maxVideoBufferSize = _a.maxVideoBufferSize;
87
86
  var DEFAULT_UNMUTED_VOLUME = config.getCurrent().DEFAULT_UNMUTED_VOLUME;
88
87
  // Workaround to support Firefox autoplay on FF 42.
89
88
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
90
89
  videoElement.preload = "auto";
91
- _this.version = /* PLAYER_VERSION */ "3.32.2-canal.2023110700";
90
+ _this.version = /* PLAYER_VERSION */ "3.32.1";
92
91
  _this.log = log;
93
92
  _this.state = "STOPPED";
94
93
  _this.videoElement = videoElement;
95
94
  var destroyCanceller = new TaskCanceller();
96
95
  _this._destroyCanceller = destroyCanceller;
97
96
  _this._priv_pictureInPictureRef = getPictureOnPictureStateRef(videoElement, destroyCanceller.signal);
98
- /** @deprecated */
99
- onFullscreenChange(videoElement, function () {
100
- /* eslint-disable import/no-deprecated */
101
- _this.trigger("fullscreenChange", _this.isFullscreen());
102
- /* eslint-enable import/no-deprecated */
103
- }, destroyCanceller.signal);
104
- /** Store last known TextTrack array linked to the media element. */
105
- var prevTextTracks = [];
106
- for (var i = 0; i < ((_a = videoElement.textTracks) === null || _a === void 0 ? void 0 : _a.length); i++) {
107
- var textTrack = (_b = videoElement.textTracks) === null || _b === void 0 ? void 0 : _b[i];
108
- if (!isNullOrUndefined(textTrack)) {
109
- prevTextTracks.push(textTrack);
110
- }
111
- }
112
- /** Callback called when a TextTrack element is added or removed. */
113
- var onTextTrackChanges = function (_evt) {
114
- var evt = _evt;
115
- var target = evt.target;
116
- var textTrackArr = [];
117
- for (var i = 0; i < target.length; i++) {
118
- var textTrack = target[i];
119
- textTrackArr.push(textTrack);
120
- }
121
- var oldTextTracks = prevTextTracks;
122
- prevTextTracks = textTrackArr;
123
- // We can have two consecutive textTrackChanges with the exact same
124
- // payload when we perform multiple texttrack operations before the event
125
- // loop is freed.
126
- if (oldTextTracks.length !== textTrackArr.length) {
127
- _this._priv_onNativeTextTracksNext(textTrackArr);
128
- return;
129
- }
130
- for (var i = 0; i < oldTextTracks.length; i++) {
131
- if (oldTextTracks[i] !== textTrackArr[i]) {
132
- _this._priv_onNativeTextTracksNext(textTrackArr);
133
- return;
134
- }
135
- }
136
- return;
137
- };
138
- if (!isNullOrUndefined(videoElement.textTracks)) {
139
- onTextTrackAdded(videoElement.textTracks, onTextTrackChanges, destroyCanceller.signal);
140
- onTextTrackRemoved(videoElement.textTracks, onTextTrackChanges, destroyCanceller.signal);
141
- }
142
97
  _this._priv_speed = new SharedReference(videoElement.playbackRate, _this._destroyCanceller.signal);
143
98
  _this._priv_preferTrickModeTracks = false;
144
99
  _this._priv_contentLock = new SharedReference(false, _this._destroyCanceller.signal);
@@ -149,27 +104,16 @@ var Player = /** @class */ (function (_super) {
149
104
  maxVideoBufferSize: new SharedReference(maxVideoBufferSize, _this._destroyCanceller.signal),
150
105
  };
151
106
  _this._priv_bitrateInfos = {
152
- lastBitrates: { audio: initialAudioBitrate,
153
- video: initialVideoBitrate },
154
- minAutoBitrates: { audio: new SharedReference(minAudioBitrate, _this._destroyCanceller.signal),
155
- video: new SharedReference(minVideoBitrate, _this._destroyCanceller.signal) },
156
- maxAutoBitrates: { audio: new SharedReference(maxAudioBitrate, _this._destroyCanceller.signal),
157
- video: new SharedReference(maxVideoBitrate, _this._destroyCanceller.signal) },
158
- manualBitrates: { audio: new SharedReference(-1, _this._destroyCanceller.signal),
159
- video: new SharedReference(-1, _this._destroyCanceller.signal) },
107
+ lastBitrates: { audio: baseBandwidth,
108
+ video: baseBandwidth },
160
109
  };
161
- _this._priv_throttleWhenHidden = throttleWhenHidden;
162
110
  _this._priv_throttleVideoBitrateWhenHidden = throttleVideoBitrateWhenHidden;
163
111
  _this._priv_limitVideoWidth = limitVideoWidth;
164
112
  _this._priv_mutedMemory = DEFAULT_UNMUTED_VOLUME;
165
113
  _this._priv_currentError = null;
166
114
  _this._priv_contentInfos = null;
167
115
  _this._priv_contentEventsMemory = {};
168
- _this._priv_stopAtEnd = stopAtEnd;
169
116
  _this._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */);
170
- _this._priv_preferredAudioTracks = preferredAudioTracks;
171
- _this._priv_preferredTextTracks = preferredTextTracks;
172
- _this._priv_preferredVideoTracks = preferredVideoTracks;
173
117
  _this._priv_reloadingMetadata = {};
174
118
  _this._priv_lastAutoPlay = false;
175
119
  return _this;
@@ -283,8 +227,8 @@ var Player = /** @class */ (function (_super) {
283
227
  * @param {Object} reloadOpts
284
228
  */
285
229
  Player.prototype.reload = function (reloadOpts) {
286
- var _a, _b;
287
- var _c = this._priv_reloadingMetadata, options = _c.options, manifest = _c.manifest, reloadPosition = _c.reloadPosition, reloadInPause = _c.reloadInPause;
230
+ var _a, _b, _c;
231
+ var _d = this._priv_reloadingMetadata, options = _d.options, manifest = _d.manifest, reloadPosition = _d.reloadPosition, reloadInPause = _d.reloadInPause;
288
232
  if (options === undefined) {
289
233
  throw new Error("API: Can't reload without having previously loaded a content.");
290
234
  }
@@ -311,6 +255,13 @@ var Player = /** @class */ (function (_super) {
311
255
  else if (reloadInPause !== undefined) {
312
256
  autoPlay = !reloadInPause;
313
257
  }
258
+ var keySystems;
259
+ if ((reloadOpts === null || reloadOpts === void 0 ? void 0 : reloadOpts.keySystems) !== undefined) {
260
+ keySystems = reloadOpts.keySystems;
261
+ }
262
+ else if (((_c = this._priv_reloadingMetadata.options) === null || _c === void 0 ? void 0 : _c.keySystems) !== undefined) {
263
+ keySystems = this._priv_reloadingMetadata.options.keySystems;
264
+ }
314
265
  var newOptions = __assign(__assign({}, options), { initialManifest: manifest });
315
266
  if (startAt !== undefined) {
316
267
  newOptions.startAt = startAt;
@@ -318,6 +269,9 @@ var Player = /** @class */ (function (_super) {
318
269
  if (autoPlay !== undefined) {
319
270
  newOptions.autoPlay = autoPlay;
320
271
  }
272
+ if (keySystems !== undefined) {
273
+ newOptions.keySystems = keySystems;
274
+ }
321
275
  this._priv_initializeContentPlayback(newOptions);
322
276
  };
323
277
  Player.prototype.createDebugElement = function (element) {
@@ -338,7 +292,8 @@ var Player = /** @class */ (function (_super) {
338
292
  */
339
293
  Player.prototype._priv_initializeContentPlayback = function (options) {
340
294
  var _this = this;
341
- var autoPlay = options.autoPlay, audioTrackSwitchingMode = options.audioTrackSwitchingMode, defaultAudioTrack = options.defaultAudioTrack, defaultTextTrack = options.defaultTextTrack, enableFastSwitching = options.enableFastSwitching, initialManifest = options.initialManifest, keySystems = options.keySystems, lowLatencyMode = options.lowLatencyMode, manualBitrateSwitchingMode = options.manualBitrateSwitchingMode, minimumManifestUpdateInterval = options.minimumManifestUpdateInterval, networkConfig = options.networkConfig, onCodecSwitch = options.onCodecSwitch, startAt = options.startAt, transport = options.transport, transportOptions = options.transportOptions, url = options.url;
295
+ var _a, _b, _c, _d;
296
+ var autoPlay = options.autoPlay, defaultAudioTrackSwitchingMode = options.defaultAudioTrackSwitchingMode, enableFastSwitching = options.enableFastSwitching, initialManifest = options.initialManifest, keySystems = options.keySystems, lowLatencyMode = options.lowLatencyMode, minimumManifestUpdateInterval = options.minimumManifestUpdateInterval, requestConfig = options.requestConfig, onCodecSwitch = options.onCodecSwitch, startAt = options.startAt, transport = options.transport, checkMediaSegmentIntegrity = options.checkMediaSegmentIntegrity, manifestLoader = options.manifestLoader, manifestUpdateUrl = options.manifestUpdateUrl, referenceDateTime = options.referenceDateTime, representationFilter = options.representationFilter, segmentLoader = options.segmentLoader, serverSyncInfos = options.serverSyncInfos, __priv_patchLastSegmentInSidx = options.__priv_patchLastSegmentInSidx, url = options.url;
342
297
  // Perform multiple checks on the given options
343
298
  if (this.videoElement === null) {
344
299
  throw new Error("the attached video element is disposed");
@@ -348,7 +303,7 @@ var Player = /** @class */ (function (_super) {
348
303
  var currentContentCanceller = new TaskCanceller();
349
304
  var videoElement = this.videoElement;
350
305
  var initializer;
351
- var mediaElementTrackChoiceManager = null;
306
+ var mediaElementTracksStore = null;
352
307
  if (!isDirectFile) {
353
308
  var transportFn = features.transports[transport];
354
309
  if (typeof transportFn !== "function") {
@@ -360,27 +315,13 @@ var Player = /** @class */ (function (_super) {
360
315
  if (features.mediaSourceInit === null) {
361
316
  throw new Error("MediaSource streaming not supported");
362
317
  }
363
- var transportPipelines = transportFn(transportOptions);
364
- var offlineRetry = networkConfig.offlineRetry, segmentRetry = networkConfig.segmentRetry, manifestRetry = networkConfig.manifestRetry, manifestRequestTimeout = networkConfig.manifestRequestTimeout, segmentRequestTimeout = networkConfig.segmentRequestTimeout;
318
+ var transportPipelines = transportFn({ lowLatencyMode: lowLatencyMode, checkMediaSegmentIntegrity: checkMediaSegmentIntegrity, manifestLoader: manifestLoader, manifestUpdateUrl: manifestUpdateUrl, referenceDateTime: referenceDateTime, representationFilter: representationFilter, segmentLoader: segmentLoader, serverSyncInfos: serverSyncInfos, __priv_patchLastSegmentInSidx: __priv_patchLastSegmentInSidx });
365
319
  /** Interface used to load and refresh the Manifest. */
366
- var manifestRequestSettings = { lowLatencyMode: lowLatencyMode, maxRetryRegular: manifestRetry,
367
- maxRetryOffline: offlineRetry,
368
- requestTimeout: manifestRequestTimeout, minimumManifestUpdateInterval: minimumManifestUpdateInterval, initialManifest: initialManifest };
320
+ var manifestRequestSettings = { lowLatencyMode: lowLatencyMode, maxRetry: (_a = requestConfig.manifest) === null || _a === void 0 ? void 0 : _a.maxRetry,
321
+ requestTimeout: (_b = requestConfig.manifest) === null || _b === void 0 ? void 0 : _b.timeout, minimumManifestUpdateInterval: minimumManifestUpdateInterval, initialManifest: initialManifest };
369
322
  var relyOnVideoVisibilityAndSize = canRelyOnVideoVisibilityAndSize();
370
- var throttlers = { throttle: {},
371
- throttleBitrate: {},
323
+ var throttlers = { throttleBitrate: {},
372
324
  limitWidth: {} };
373
- if (this._priv_throttleWhenHidden) {
374
- if (!relyOnVideoVisibilityAndSize) {
375
- log.warn("API: Can't apply throttleWhenHidden because " +
376
- "browser can't be trusted for visibility.");
377
- }
378
- else {
379
- throttlers.throttle = {
380
- video: createMappedReference(getPageActivityRef(currentContentCanceller.signal), function (isActive) { return isActive ? Infinity : 0; }, currentContentCanceller.signal),
381
- };
382
- }
383
- }
384
325
  if (this._priv_throttleVideoBitrateWhenHidden) {
385
326
  if (!relyOnVideoVisibilityAndSize) {
386
327
  log.warn("API: Can't apply throttleVideoBitrateWhenHidden because " +
@@ -407,21 +348,16 @@ var Player = /** @class */ (function (_super) {
407
348
  var adaptiveOptions = {
408
349
  initialBitrates: this._priv_bitrateInfos.lastBitrates,
409
350
  lowLatencyMode: lowLatencyMode,
410
- manualBitrates: this._priv_bitrateInfos.manualBitrates,
411
- minAutoBitrates: this._priv_bitrateInfos.minAutoBitrates,
412
- maxAutoBitrates: this._priv_bitrateInfos.maxAutoBitrates,
413
351
  throttlers: throttlers,
414
352
  };
415
353
  /** Options used by the TextTrack SegmentBuffer. */
416
354
  var textTrackOptions = options.textTrackMode === "native" ?
417
- { textTrackMode: "native",
418
- hideNativeSubtitle: options.hideNativeSubtitle } :
355
+ { textTrackMode: "native" } :
419
356
  { textTrackMode: "html",
420
357
  textTrackElement: options.textTrackElement };
421
- var bufferOptions = objectAssign({ audioTrackSwitchingMode: audioTrackSwitchingMode, enableFastSwitching: enableFastSwitching, manualBitrateSwitchingMode: manualBitrateSwitchingMode, onCodecSwitch: onCodecSwitch }, this._priv_bufferOptions);
422
- var segmentRequestOptions = { lowLatencyMode: lowLatencyMode, maxRetryRegular: segmentRetry,
423
- requestTimeout: segmentRequestTimeout,
424
- maxRetryOffline: offlineRetry };
358
+ var bufferOptions = objectAssign({ enableFastSwitching: enableFastSwitching, onCodecSwitch: onCodecSwitch }, this._priv_bufferOptions);
359
+ var segmentRequestOptions = { lowLatencyMode: lowLatencyMode, maxRetry: (_c = requestConfig.segment) === null || _c === void 0 ? void 0 : _c.maxRetry,
360
+ requestTimeout: (_d = requestConfig.segment) === null || _d === void 0 ? void 0 : _d.timeout };
425
361
  initializer = new features.mediaSourceInit({
426
362
  adaptiveOptions: adaptiveOptions,
427
363
  autoPlay: autoPlay,
@@ -446,8 +382,8 @@ var Player = /** @class */ (function (_super) {
446
382
  else if (isNullOrUndefined(url)) {
447
383
  throw new Error("No URL for a DirectFile content");
448
384
  }
449
- mediaElementTrackChoiceManager =
450
- this._priv_initializeMediaElementTrackChoiceManager(defaultAudioTrack, defaultTextTrack, currentContentCanceller.signal);
385
+ mediaElementTracksStore =
386
+ this._priv_initializeMediaElementTracksStore(currentContentCanceller.signal);
451
387
  if (currentContentCanceller.isUsed()) {
452
388
  return;
453
389
  }
@@ -458,18 +394,16 @@ var Player = /** @class */ (function (_super) {
458
394
  contentId: generateContentId(),
459
395
  originalUrl: url,
460
396
  currentContentCanceller: currentContentCanceller,
397
+ defaultAudioTrackSwitchingMode: defaultAudioTrackSwitchingMode,
461
398
  initializer: initializer,
462
399
  isDirectFile: isDirectFile,
463
400
  segmentBuffersStore: null,
464
- thumbnails: null,
465
401
  manifest: null,
466
402
  currentPeriod: null,
467
403
  activeAdaptations: null,
468
404
  activeRepresentations: null,
469
- initialAudioTrack: defaultAudioTrack,
470
- initialTextTrack: defaultTextTrack,
471
- trackChoiceManager: null,
472
- mediaElementTrackChoiceManager: mediaElementTrackChoiceManager,
405
+ tracksStore: null,
406
+ mediaElementTracksStore: mediaElementTracksStore,
473
407
  };
474
408
  // Bind events
475
409
  initializer.addEventListener("error", function (error) {
@@ -501,8 +435,8 @@ var Player = /** @class */ (function (_super) {
501
435
  });
502
436
  initializer.addEventListener("reloadingMediaSource", function (payload) {
503
437
  contentInfos.segmentBuffersStore = null;
504
- if (contentInfos.trackChoiceManager !== null) {
505
- contentInfos.trackChoiceManager.resetPeriods();
438
+ if (contentInfos.tracksStore !== null) {
439
+ contentInfos.tracksStore.resetPeriodObjects();
506
440
  }
507
441
  _this._priv_lastAutoPlay = payload.autoPlay;
508
442
  });
@@ -515,9 +449,6 @@ var Player = /** @class */ (function (_super) {
515
449
  initializer.addEventListener("streamEventSkip", function (streamEventSkip) {
516
450
  return _this.trigger("streamEventSkip", streamEventSkip);
517
451
  });
518
- initializer.addEventListener("decipherabilityUpdate", function (decipherabilityUpdate) {
519
- return _this.trigger("decipherabilityUpdate", decipherabilityUpdate);
520
- });
521
452
  initializer.addEventListener("activePeriodChanged", function (periodInfo) {
522
453
  return _this._priv_onActivePeriodChanged(contentInfos, periodInfo);
523
454
  });
@@ -533,8 +464,8 @@ var Player = /** @class */ (function (_super) {
533
464
  initializer.addEventListener("adaptationChange", function (adaptationInfo) {
534
465
  return _this._priv_onAdaptationChange(contentInfos, adaptationInfo);
535
466
  });
536
- initializer.addEventListener("bitrateEstimationChange", function (bitrateEstimationInfo) {
537
- return _this._priv_onBitrateEstimationChange(bitrateEstimationInfo);
467
+ initializer.addEventListener("bitrateEstimateChange", function (bitrateEstimateInfo) {
468
+ return _this._priv_onBitrateEstimateChange(bitrateEstimateInfo);
538
469
  });
539
470
  initializer.addEventListener("manifestReady", function (manifest) {
540
471
  return _this._priv_onManifestReady(contentInfos, manifest);
@@ -542,21 +473,6 @@ var Player = /** @class */ (function (_super) {
542
473
  initializer.addEventListener("loaded", function (evt) {
543
474
  contentInfos.segmentBuffersStore = evt.segmentBuffersStore;
544
475
  });
545
- initializer.addEventListener("addedSegment", function (evt) {
546
- // Manage image tracks
547
- // @deprecated
548
- var content = evt.content, segmentData = evt.segmentData;
549
- if (content.adaptation.type === "image") {
550
- if (!isNullOrUndefined(segmentData) &&
551
- segmentData.type === "bif") {
552
- var imageData = segmentData.data;
553
- /* eslint-disable import/no-deprecated */
554
- contentInfos.thumbnails = imageData;
555
- _this.trigger("imageTrackUpdate", { data: contentInfos.thumbnails });
556
- /* eslint-enable import/no-deprecated */
557
- }
558
- }
559
- });
560
476
  // Now, that most events are linked, prepare the next content.
561
477
  initializer.prepare();
562
478
  // Now that the content is prepared, stop previous content and reset state
@@ -672,11 +588,6 @@ var Player = /** @class */ (function (_super) {
672
588
  seekEventsCanceller.linkToSignal(currentContentCanceller.signal);
673
589
  emitSeekEvents(videoElement, playbackObserver, function () { return _this.trigger("seeking", null); }, function () { return _this.trigger("seeked", null); }, seekEventsCanceller.signal);
674
590
  }
675
- // Previous call could have performed all kind of side-effects, thus,
676
- // we re-check the current state associated to the RxPlayer
677
- if (_this.state === "ENDED" /* PLAYER_STATES.ENDED */ && _this._priv_stopAtEnd) {
678
- _this.stop();
679
- }
680
591
  }, { emitCurrentValue: true, clearSignal: currentContentCanceller.signal });
681
592
  // React to playback conditions change
682
593
  playbackObserver.listen(function (observation) {
@@ -705,53 +616,6 @@ var Player = /** @class */ (function (_super) {
705
616
  Player.prototype.getError = function () {
706
617
  return this._priv_currentError;
707
618
  };
708
- /**
709
- * Returns manifest/playlist object.
710
- * null if the player is STOPPED.
711
- * @deprecated
712
- * @returns {Manifest|null} - The current Manifest (`null` when not known).
713
- */
714
- Player.prototype.getManifest = function () {
715
- warnOnce("getManifest is deprecated." +
716
- " Please open an issue if you used this API.");
717
- if (this._priv_contentInfos === null) {
718
- return null;
719
- }
720
- return this._priv_contentInfos.manifest;
721
- };
722
- /**
723
- * Returns Adaptations (tracks) for every currently playing type
724
- * (audio/video/text...).
725
- * @deprecated
726
- * @returns {Object|null} - The current Adaptation objects, per type (`null`
727
- * when none is known for now.
728
- */
729
- Player.prototype.getCurrentAdaptations = function () {
730
- warnOnce("getCurrentAdaptations is deprecated." +
731
- " Please open an issue if you used this API.");
732
- if (this._priv_contentInfos === null) {
733
- return null;
734
- }
735
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, activeAdaptations = _a.activeAdaptations;
736
- if (currentPeriod === null ||
737
- activeAdaptations === null ||
738
- isNullOrUndefined(activeAdaptations[currentPeriod.id])) {
739
- return null;
740
- }
741
- return activeAdaptations[currentPeriod.id];
742
- };
743
- /**
744
- * Returns representations (qualities) for every currently playing type
745
- * (audio/video/text...).
746
- * @deprecated
747
- * @returns {Object|null} - The current Representation objects, per type
748
- * (`null` when none is known for now.
749
- */
750
- Player.prototype.getCurrentRepresentations = function () {
751
- warnOnce("getCurrentRepresentations is deprecated." +
752
- " Please open an issue if you used this API.");
753
- return this._priv_getCurrentRepresentations();
754
- };
755
619
  /**
756
620
  * Returns the media DOM element used by the player.
757
621
  * You should not its HTML5 API directly and use the player's method instead,
@@ -762,26 +626,6 @@ var Player = /** @class */ (function (_super) {
762
626
  Player.prototype.getVideoElement = function () {
763
627
  return this.videoElement;
764
628
  };
765
- /**
766
- * If one returns the first native text-track element attached to the media element.
767
- * @deprecated
768
- * @returns {TextTrack} - The native TextTrack attached (`null` when none)
769
- */
770
- Player.prototype.getNativeTextTrack = function () {
771
- warnOnce("getNativeTextTrack is deprecated." +
772
- " Please open an issue if you used this API.");
773
- if (this.videoElement === null) {
774
- throw new Error("Disposed player");
775
- }
776
- var videoElement = this.videoElement;
777
- var textTracks = videoElement.textTracks;
778
- if (textTracks.length > 0) {
779
- return videoElement.textTracks[0];
780
- }
781
- else {
782
- return null;
783
- }
784
- };
785
629
  /**
786
630
  * Returns the player's current state.
787
631
  * @returns {string} - The current Player's state
@@ -849,21 +693,22 @@ var Player = /** @class */ (function (_super) {
849
693
  return this._priv_preferTrickModeTracks;
850
694
  };
851
695
  /**
852
- * Returns the url of the currently considered Manifest, or of the content for
696
+ * Returns the URL(s) of the currently considered Manifest, or of the content for
853
697
  * directfile content.
854
- * @returns {string|undefined} - Current URL. `undefined` if not known or no
855
- * URL yet.
698
+ * @returns {Array.<string>|undefined} - Current URL. `undefined` if not known
699
+ * or no URL yet.
856
700
  */
857
- Player.prototype.getUrl = function () {
701
+ Player.prototype.getContentUrls = function () {
858
702
  if (this._priv_contentInfos === null) {
859
703
  return undefined;
860
704
  }
861
705
  var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, manifest = _a.manifest, originalUrl = _a.originalUrl;
862
706
  if (isDirectFile) {
863
- return originalUrl;
707
+ return originalUrl === undefined ? undefined :
708
+ [originalUrl];
864
709
  }
865
710
  if (manifest !== null) {
866
- return manifest.getUrl();
711
+ return manifest.getUrls();
867
712
  }
868
713
  return undefined;
869
714
  };
@@ -887,7 +732,7 @@ var Player = /** @class */ (function (_super) {
887
732
  * NaN if no video is playing.
888
733
  * @returns {Number}
889
734
  */
890
- Player.prototype.getVideoDuration = function () {
735
+ Player.prototype.getMediaDuration = function () {
891
736
  if (this.videoElement === null) {
892
737
  throw new Error("Disposed player");
893
738
  }
@@ -899,43 +744,13 @@ var Player = /** @class */ (function (_super) {
899
744
  * - the current time
900
745
  * @returns {Number}
901
746
  */
902
- Player.prototype.getVideoBufferGap = function () {
747
+ Player.prototype.getCurrentBufferGap = function () {
903
748
  if (this.videoElement === null) {
904
749
  throw new Error("Disposed player");
905
750
  }
906
751
  var videoElement = this.videoElement;
907
752
  return getLeftSizeOfRange(videoElement.buffered, videoElement.currentTime);
908
753
  };
909
- /**
910
- * Returns in seconds the difference between:
911
- * - the end of the current contiguous loaded range.
912
- * - the start of the current contiguous loaded range.
913
- * @returns {Number}
914
- */
915
- Player.prototype.getVideoLoadedTime = function () {
916
- warnOnce("`getVideoLoadedTime` is deprecated and won't be present in the " +
917
- "next major version");
918
- if (this.videoElement === null) {
919
- throw new Error("Disposed player");
920
- }
921
- var videoElement = this.videoElement;
922
- return getSizeOfRange(videoElement.buffered, videoElement.currentTime);
923
- };
924
- /**
925
- * Returns in seconds the difference between:
926
- * - the current time.
927
- * - the start of the current contiguous loaded range.
928
- * @returns {Number}
929
- */
930
- Player.prototype.getVideoPlayedTime = function () {
931
- warnOnce("`getVideoPlayedTime` is deprecated and won't be present in the " +
932
- "next major version");
933
- if (this.videoElement === null) {
934
- throw new Error("Disposed player");
935
- }
936
- var videoElement = this.videoElement;
937
- return getPlayedSizeOfRange(videoElement.buffered, videoElement.currentTime);
938
- };
939
754
  /**
940
755
  * Get the current position, in s, in wall-clock time.
941
756
  * That is:
@@ -1069,115 +884,47 @@ var Player = /** @class */ (function (_super) {
1069
884
  return;
1070
885
  }
1071
886
  this._priv_preferTrickModeTracks = preferTrickModeTracks;
1072
- var trackChoiceManager = (_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.trackChoiceManager;
1073
- if (!isNullOrUndefined(trackChoiceManager)) {
1074
- if (preferTrickModeTracks && !trackChoiceManager.isTrickModeEnabled()) {
1075
- trackChoiceManager.enableVideoTrickModeTracks();
887
+ var tracksStore = (_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.tracksStore;
888
+ if (!isNullOrUndefined(tracksStore)) {
889
+ if (preferTrickModeTracks && !tracksStore.isTrickModeEnabled()) {
890
+ tracksStore.enableVideoTrickModeTracks();
1076
891
  }
1077
- else if (!preferTrickModeTracks && trackChoiceManager.isTrickModeEnabled()) {
1078
- trackChoiceManager.disableVideoTrickModeTracks();
892
+ else if (!preferTrickModeTracks && tracksStore.isTrickModeEnabled()) {
893
+ tracksStore.disableVideoTrickModeTracks();
1079
894
  }
1080
895
  }
1081
896
  };
1082
897
  /**
1083
- * Returns all available bitrates for the current video Adaptation.
1084
- * @returns {Array.<Number>}
1085
- */
1086
- Player.prototype.getAvailableVideoBitrates = function () {
1087
- if (this._priv_contentInfos === null) {
1088
- return [];
1089
- }
1090
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, activeAdaptations = _a.activeAdaptations;
1091
- if (currentPeriod === null || activeAdaptations === null) {
1092
- return [];
1093
- }
1094
- var adaptations = activeAdaptations[currentPeriod.id];
1095
- if (adaptations === undefined || isNullOrUndefined(adaptations.video)) {
1096
- return [];
1097
- }
1098
- return adaptations.video.getAvailableBitrates();
1099
- };
1100
- /**
1101
- * Returns all available bitrates for the current audio Adaptation.
1102
- * @returns {Array.<Number>}
1103
- */
1104
- Player.prototype.getAvailableAudioBitrates = function () {
1105
- if (this._priv_contentInfos === null) {
1106
- return [];
1107
- }
1108
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, activeAdaptations = _a.activeAdaptations;
1109
- if (currentPeriod === null || activeAdaptations === null) {
1110
- return [];
1111
- }
1112
- var adaptations = activeAdaptations[currentPeriod.id];
1113
- if (adaptations === undefined || isNullOrUndefined(adaptations.audio)) {
1114
- return [];
1115
- }
1116
- return adaptations.audio.getAvailableBitrates();
1117
- };
1118
- /**
1119
- * Returns the manual audio bitrate set. -1 if in AUTO mode.
1120
- * @returns {Number}
1121
- */
1122
- Player.prototype.getManualAudioBitrate = function () {
1123
- return this._priv_bitrateInfos.manualBitrates.audio.getValue();
1124
- };
1125
- /**
1126
- * Returns the manual video bitrate set. -1 if in AUTO mode.
1127
- * @returns {Number}
1128
- */
1129
- Player.prototype.getManualVideoBitrate = function () {
1130
- return this._priv_bitrateInfos.manualBitrates.video.getValue();
1131
- };
1132
- /**
1133
- * Returns currently considered bitrate for video segments.
1134
- * @returns {Number|undefined}
898
+ * Returns video Representation currently considered for the current Period.
899
+ *
900
+ * Returns `null` if no video track is playing for the current Period.
901
+ *
902
+ * Returns `undefined` either when are not currently playing any Period or
903
+ * when we don't know which Representation is playing.
904
+ * @returns {Object|null|undefined}
1135
905
  */
1136
- Player.prototype.getVideoBitrate = function () {
1137
- var representations = this._priv_getCurrentRepresentations();
1138
- if (representations === null || isNullOrUndefined(representations.video)) {
906
+ Player.prototype.getVideoRepresentation = function () {
907
+ var representations = this.__priv_getCurrentRepresentations();
908
+ if (representations === null) {
1139
909
  return undefined;
1140
910
  }
1141
- return representations.video.bitrate;
911
+ return representations.video;
1142
912
  };
1143
913
  /**
1144
- * Returns currently considered bitrate for audio segments.
1145
- * @returns {Number|undefined}
914
+ * Returns audio Representation currently considered for the current Period.
915
+ *
916
+ * Returns `null` if no audio track is playing for the current Period.
917
+ *
918
+ * Returns `undefined` either when are not currently playing any Period or
919
+ * when we don't know which Representation is playing.
920
+ * @returns {Object|null|undefined}
1146
921
  */
1147
- Player.prototype.getAudioBitrate = function () {
1148
- var representations = this._priv_getCurrentRepresentations();
1149
- if (representations === null || isNullOrUndefined(representations.audio)) {
922
+ Player.prototype.getAudioRepresentation = function () {
923
+ var representations = this.__priv_getCurrentRepresentations();
924
+ if (representations === null) {
1150
925
  return undefined;
1151
926
  }
1152
- return representations.audio.bitrate;
1153
- };
1154
- /**
1155
- * Returns minimum wanted video bitrate currently set.
1156
- * @returns {Number}
1157
- */
1158
- Player.prototype.getMinVideoBitrate = function () {
1159
- return this._priv_bitrateInfos.minAutoBitrates.video.getValue();
1160
- };
1161
- /**
1162
- * Returns minimum wanted audio bitrate currently set.
1163
- * @returns {Number}
1164
- */
1165
- Player.prototype.getMinAudioBitrate = function () {
1166
- return this._priv_bitrateInfos.minAutoBitrates.audio.getValue();
1167
- };
1168
- /**
1169
- * Returns maximum wanted video bitrate currently set.
1170
- * @returns {Number}
1171
- */
1172
- Player.prototype.getMaxVideoBitrate = function () {
1173
- return this._priv_bitrateInfos.maxAutoBitrates.video.getValue();
1174
- };
1175
- /**
1176
- * Returns maximum wanted audio bitrate currently set.
1177
- * @returns {Number}
1178
- */
1179
- Player.prototype.getMaxAudioBitrate = function () {
1180
- return this._priv_bitrateInfos.maxAutoBitrates.audio.getValue();
927
+ return representations.audio;
1181
928
  };
1182
929
  /**
1183
930
  * Play/Resume the current video.
@@ -1268,44 +1015,6 @@ var Player = /** @class */ (function (_super) {
1268
1015
  this.videoElement.currentTime = positionWanted;
1269
1016
  return positionWanted;
1270
1017
  };
1271
- /**
1272
- * Returns true if the media element is full screen.
1273
- * @deprecated
1274
- * @returns {Boolean}
1275
- */
1276
- Player.prototype.isFullscreen = function () {
1277
- warnOnce("isFullscreen is deprecated." +
1278
- " Fullscreen management should now be managed by the application");
1279
- return isFullscreen();
1280
- };
1281
- /**
1282
- * Set/exit fullScreen.
1283
- * @deprecated
1284
- * @param {Boolean} [goFull=true] - if false, exit full screen.
1285
- */
1286
- Player.prototype.setFullscreen = function (goFull) {
1287
- if (goFull === void 0) { goFull = true; }
1288
- warnOnce("setFullscreen is deprecated." +
1289
- " Fullscreen management should now be managed by the application");
1290
- if (this.videoElement === null) {
1291
- throw new Error("Disposed player");
1292
- }
1293
- if (goFull) {
1294
- requestFullscreen(this.videoElement);
1295
- }
1296
- else {
1297
- exitFullscreen();
1298
- }
1299
- };
1300
- /**
1301
- * Exit from full screen mode.
1302
- * @deprecated
1303
- */
1304
- Player.prototype.exitFullscreen = function () {
1305
- warnOnce("exitFullscreen is deprecated." +
1306
- " Fullscreen management should now be managed by the application");
1307
- exitFullscreen();
1308
- };
1309
1018
  /**
1310
1019
  * Returns the current player's audio volume on the media element.
1311
1020
  * From 0 (no audio) to 1 (maximum volume).
@@ -1357,74 +1066,6 @@ var Player = /** @class */ (function (_super) {
1357
1066
  this._priv_mutedMemory);
1358
1067
  }
1359
1068
  };
1360
- /**
1361
- * Force the video bitrate to a given value. Act as a ceil.
1362
- * -1 to set it on AUTO Mode
1363
- * @param {Number} btr
1364
- */
1365
- Player.prototype.setVideoBitrate = function (btr) {
1366
- this._priv_bitrateInfos.manualBitrates.video.setValue(btr);
1367
- };
1368
- /**
1369
- * Force the audio bitrate to a given value. Act as a ceil.
1370
- * -1 to set it on AUTO Mode
1371
- * @param {Number} btr
1372
- */
1373
- Player.prototype.setAudioBitrate = function (btr) {
1374
- this._priv_bitrateInfos.manualBitrates.audio.setValue(btr);
1375
- };
1376
- /**
1377
- * Update the minimum video bitrate the user can switch to.
1378
- * @param {Number} btr
1379
- */
1380
- Player.prototype.setMinVideoBitrate = function (btr) {
1381
- var maxVideoBitrate = this._priv_bitrateInfos.maxAutoBitrates.video.getValue();
1382
- if (btr > maxVideoBitrate) {
1383
- throw new Error("Invalid minimum video bitrate given. " +
1384
- "Its value, \"".concat(btr, "\" is superior the current maximum ") +
1385
- "video birate, \"".concat(maxVideoBitrate, "\"."));
1386
- }
1387
- this._priv_bitrateInfos.minAutoBitrates.video.setValue(btr);
1388
- };
1389
- /**
1390
- * Update the minimum audio bitrate the user can switch to.
1391
- * @param {Number} btr
1392
- */
1393
- Player.prototype.setMinAudioBitrate = function (btr) {
1394
- var maxAudioBitrate = this._priv_bitrateInfos.maxAutoBitrates.audio.getValue();
1395
- if (btr > maxAudioBitrate) {
1396
- throw new Error("Invalid minimum audio bitrate given. " +
1397
- "Its value, \"".concat(btr, "\" is superior the current maximum ") +
1398
- "audio birate, \"".concat(maxAudioBitrate, "\"."));
1399
- }
1400
- this._priv_bitrateInfos.minAutoBitrates.audio.setValue(btr);
1401
- };
1402
- /**
1403
- * Update the maximum video bitrate the user can switch to.
1404
- * @param {Number} btr
1405
- */
1406
- Player.prototype.setMaxVideoBitrate = function (btr) {
1407
- var minVideoBitrate = this._priv_bitrateInfos.minAutoBitrates.video.getValue();
1408
- if (btr < minVideoBitrate) {
1409
- throw new Error("Invalid maximum video bitrate given. " +
1410
- "Its value, \"".concat(btr, "\" is inferior the current minimum ") +
1411
- "video birate, \"".concat(minVideoBitrate, "\"."));
1412
- }
1413
- this._priv_bitrateInfos.maxAutoBitrates.video.setValue(btr);
1414
- };
1415
- /**
1416
- * Update the maximum audio bitrate the user can switch to.
1417
- * @param {Number} btr
1418
- */
1419
- Player.prototype.setMaxAudioBitrate = function (btr) {
1420
- var minAudioBitrate = this._priv_bitrateInfos.minAutoBitrates.audio.getValue();
1421
- if (btr < minAudioBitrate) {
1422
- throw new Error("Invalid maximum audio bitrate given. " +
1423
- "Its value, \"".concat(btr, "\" is inferior the current minimum ") +
1424
- "audio birate, \"".concat(minAudioBitrate, "\"."));
1425
- }
1426
- this._priv_bitrateInfos.maxAutoBitrates.audio.setValue(btr);
1427
- };
1428
1069
  /**
1429
1070
  * Set the max buffer size for the buffer behind the current position.
1430
1071
  * Every buffer data before will be removed.
@@ -1499,6 +1140,14 @@ var Player = /** @class */ (function (_super) {
1499
1140
  }
1500
1141
  return getCurrentKeySystem(this.videoElement);
1501
1142
  };
1143
+ Player.prototype.getCurrentPeriod = function () {
1144
+ var _a;
1145
+ var currentPeriod = (_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.currentPeriod;
1146
+ if (isNullOrUndefined(currentPeriod)) {
1147
+ return null;
1148
+ }
1149
+ return { id: currentPeriod.id, start: currentPeriod.start, end: currentPeriod.end };
1150
+ };
1502
1151
  /**
1503
1152
  * Returns both the name of the key system (e.g. `"com.widevine.alpha"`) and
1504
1153
  * the `MediaKeySystemConfiguration` currently associated to the
@@ -1518,342 +1167,356 @@ var Player = /** @class */ (function (_super) {
1518
1167
  return { keySystem: values[0], configuration: values[1] };
1519
1168
  };
1520
1169
  /**
1521
- * Returns every available audio tracks for the current Period.
1522
- * @returns {Array.<Object>|null}
1170
+ * Returns the list of available Periods for which the current audio, video or
1171
+ * text track can now be changed.
1172
+ * @returns {Array.<Object>}
1523
1173
  */
1524
- Player.prototype.getAvailableAudioTracks = function () {
1525
- var _a;
1174
+ Player.prototype.getAvailablePeriods = function () {
1526
1175
  if (this._priv_contentInfos === null) {
1527
1176
  return [];
1528
1177
  }
1529
- var _b = this._priv_contentInfos, currentPeriod = _b.currentPeriod, isDirectFile = _b.isDirectFile, trackChoiceManager = _b.trackChoiceManager, mediaElementTrackChoiceManager = _b.mediaElementTrackChoiceManager;
1178
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, tracksStore = _a.tracksStore;
1530
1179
  if (isDirectFile) {
1531
- return (_a = mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.getAvailableAudioTracks()) !== null && _a !== void 0 ? _a : [];
1180
+ return [];
1532
1181
  }
1533
- if (trackChoiceManager === null || currentPeriod === null) {
1182
+ if (tracksStore === null) {
1534
1183
  return [];
1535
1184
  }
1536
- return trackChoiceManager.getAvailableAudioTracks(currentPeriod);
1185
+ return tracksStore.getAvailablePeriods().slice();
1537
1186
  };
1538
1187
  /**
1539
- * Returns every available text tracks for the current Period.
1540
- * @returns {Array.<Object>|null}
1188
+ * Returns every available audio tracks for a given Period - or the current
1189
+ * one if no `periodId` is given.
1190
+ * @param {string|undefined} [periodId]
1191
+ * @returns {Array.<Object>}
1541
1192
  */
1542
- Player.prototype.getAvailableTextTracks = function () {
1193
+ Player.prototype.getAvailableAudioTracks = function (periodId) {
1543
1194
  var _a;
1544
1195
  if (this._priv_contentInfos === null) {
1545
1196
  return [];
1546
1197
  }
1547
- var _b = this._priv_contentInfos, currentPeriod = _b.currentPeriod, isDirectFile = _b.isDirectFile, trackChoiceManager = _b.trackChoiceManager, mediaElementTrackChoiceManager = _b.mediaElementTrackChoiceManager;
1198
+ var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, mediaElementTracksStore = _b.mediaElementTracksStore;
1548
1199
  if (isDirectFile) {
1549
- return (_a = mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.getAvailableTextTracks()) !== null && _a !== void 0 ? _a : [];
1200
+ return (_a = mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.getAvailableAudioTracks()) !== null && _a !== void 0 ? _a : [];
1550
1201
  }
1551
- if (trackChoiceManager === null || currentPeriod === null) {
1202
+ return this._priv_callTracksStoreGetterSetter(periodId, [], function (tcm, periodRef) { var _a; return (_a = tcm.getAvailableAudioTracks(periodRef)) !== null && _a !== void 0 ? _a : []; });
1203
+ };
1204
+ /**
1205
+ * Returns every available text tracks for a given Period - or the current
1206
+ * one if no `periodId` is given.
1207
+ * @param {string|undefined} [periodId]
1208
+ * @returns {Array.<Object>}
1209
+ */
1210
+ Player.prototype.getAvailableTextTracks = function (periodId) {
1211
+ var _a;
1212
+ if (this._priv_contentInfos === null) {
1552
1213
  return [];
1553
1214
  }
1554
- return trackChoiceManager.getAvailableTextTracks(currentPeriod);
1215
+ var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, mediaElementTracksStore = _b.mediaElementTracksStore;
1216
+ if (isDirectFile) {
1217
+ return (_a = mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.getAvailableTextTracks()) !== null && _a !== void 0 ? _a : [];
1218
+ }
1219
+ return this._priv_callTracksStoreGetterSetter(periodId, [], function (tcm, periodRef) { var _a; return (_a = tcm.getAvailableTextTracks(periodRef)) !== null && _a !== void 0 ? _a : []; });
1555
1220
  };
1556
1221
  /**
1557
1222
  * Returns every available video tracks for the current Period.
1558
- * @returns {Array.<Object>|null}
1223
+ * @param {string|undefined} [periodId]
1224
+ * @returns {Array.<Object>}
1559
1225
  */
1560
- Player.prototype.getAvailableVideoTracks = function () {
1226
+ Player.prototype.getAvailableVideoTracks = function (periodId) {
1561
1227
  var _a;
1562
1228
  if (this._priv_contentInfos === null) {
1563
1229
  return [];
1564
1230
  }
1565
- var _b = this._priv_contentInfos, currentPeriod = _b.currentPeriod, isDirectFile = _b.isDirectFile, trackChoiceManager = _b.trackChoiceManager, mediaElementTrackChoiceManager = _b.mediaElementTrackChoiceManager;
1231
+ var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, mediaElementTracksStore = _b.mediaElementTracksStore;
1566
1232
  if (isDirectFile) {
1567
- return (_a = mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.getAvailableVideoTracks()) !== null && _a !== void 0 ? _a : [];
1233
+ return (_a = mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.getAvailableVideoTracks()) !== null && _a !== void 0 ? _a : [];
1568
1234
  }
1569
- if (trackChoiceManager === null || currentPeriod === null) {
1570
- return [];
1571
- }
1572
- return trackChoiceManager.getAvailableVideoTracks(currentPeriod);
1235
+ return this._priv_callTracksStoreGetterSetter(periodId, [], function (tcm, periodRef) { var _a; return (_a = tcm.getAvailableVideoTracks(periodRef)) !== null && _a !== void 0 ? _a : []; });
1573
1236
  };
1574
1237
  /**
1575
1238
  * Returns currently chosen audio language for the current Period.
1576
- * @returns {string}
1239
+ * @param {string|undefined} [periodId]
1240
+ * @returns {Object|null|undefined}
1577
1241
  */
1578
- Player.prototype.getAudioTrack = function () {
1242
+ Player.prototype.getAudioTrack = function (periodId) {
1579
1243
  if (this._priv_contentInfos === null) {
1580
1244
  return undefined;
1581
1245
  }
1582
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1246
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, mediaElementTracksStore = _a.mediaElementTracksStore;
1583
1247
  if (isDirectFile) {
1584
- if (mediaElementTrackChoiceManager === null) {
1248
+ if (mediaElementTracksStore === null) {
1585
1249
  return undefined;
1586
1250
  }
1587
- return mediaElementTrackChoiceManager.getChosenAudioTrack();
1588
- }
1589
- if (trackChoiceManager === null || currentPeriod === null) {
1590
- return undefined;
1251
+ return mediaElementTracksStore.getChosenAudioTrack();
1591
1252
  }
1592
- return trackChoiceManager.getChosenAudioTrack(currentPeriod);
1253
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.getChosenAudioTrack(periodRef); });
1593
1254
  };
1594
1255
  /**
1595
1256
  * Returns currently chosen subtitle for the current Period.
1596
- * @returns {string}
1257
+ * @param {string|undefined} [periodId]
1258
+ * @returns {Object|null|undefined}
1597
1259
  */
1598
- Player.prototype.getTextTrack = function () {
1260
+ Player.prototype.getTextTrack = function (periodId) {
1599
1261
  if (this._priv_contentInfos === null) {
1600
1262
  return undefined;
1601
1263
  }
1602
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1264
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, mediaElementTracksStore = _a.mediaElementTracksStore;
1603
1265
  if (isDirectFile) {
1604
- if (mediaElementTrackChoiceManager === null) {
1266
+ if (mediaElementTracksStore === null) {
1605
1267
  return undefined;
1606
1268
  }
1607
- return mediaElementTrackChoiceManager.getChosenTextTrack();
1608
- }
1609
- if (trackChoiceManager === null || currentPeriod === null) {
1610
- return undefined;
1269
+ return mediaElementTracksStore.getChosenTextTrack();
1611
1270
  }
1612
- return trackChoiceManager.getChosenTextTrack(currentPeriod);
1271
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.getChosenTextTrack(periodRef); });
1613
1272
  };
1614
1273
  /**
1615
1274
  * Returns currently chosen video track for the current Period.
1616
- * @returns {string}
1275
+ * @param {string|undefined} [periodId]
1276
+ * @returns {Object|null|undefined}
1617
1277
  */
1618
- Player.prototype.getVideoTrack = function () {
1278
+ Player.prototype.getVideoTrack = function (periodId) {
1619
1279
  if (this._priv_contentInfos === null) {
1620
1280
  return undefined;
1621
1281
  }
1622
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1282
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, mediaElementTracksStore = _a.mediaElementTracksStore;
1623
1283
  if (isDirectFile) {
1624
- if (mediaElementTrackChoiceManager === null) {
1284
+ if (mediaElementTracksStore === null) {
1625
1285
  return undefined;
1626
1286
  }
1627
- return mediaElementTrackChoiceManager.getChosenVideoTrack();
1287
+ return mediaElementTracksStore.getChosenVideoTrack();
1628
1288
  }
1629
- if (trackChoiceManager === null || currentPeriod === null) {
1630
- return undefined;
1631
- }
1632
- return trackChoiceManager.getChosenVideoTrack(currentPeriod);
1289
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.getChosenVideoTrack(periodRef); });
1633
1290
  };
1634
1291
  /**
1635
1292
  * Update the audio language for the current Period.
1636
- * @param {string} audioId
1637
- * @throws Error - the current content has no TrackChoiceManager.
1293
+ * @param {string | object} arg
1294
+ * @throws Error - the current content has no TracksStore.
1638
1295
  * @throws Error - the given id is linked to no audio track.
1639
1296
  */
1640
- Player.prototype.setAudioTrack = function (audioId) {
1297
+ Player.prototype.setAudioTrack = function (arg) {
1298
+ var _a;
1641
1299
  if (this._priv_contentInfos === null) {
1642
1300
  throw new Error("No content loaded");
1643
1301
  }
1644
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1302
+ var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, mediaElementTracksStore = _b.mediaElementTracksStore;
1645
1303
  if (isDirectFile) {
1646
1304
  try {
1647
- mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.setAudioTrackById(audioId);
1305
+ var audioId = typeof arg === "string" ? arg :
1306
+ arg.trackId;
1307
+ mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.setAudioTrackById(audioId);
1648
1308
  return;
1649
1309
  }
1650
1310
  catch (e) {
1651
1311
  throw new Error("player: unknown audio track");
1652
1312
  }
1653
1313
  }
1654
- if (trackChoiceManager === null || currentPeriod === null) {
1655
- throw new Error("No compatible content launched.");
1314
+ var periodId;
1315
+ var trackId;
1316
+ var switchingMode;
1317
+ var reprsToLock = null;
1318
+ if (typeof arg === "string") {
1319
+ trackId = arg;
1656
1320
  }
1657
- try {
1658
- trackChoiceManager.setAudioTrackByID(currentPeriod, audioId);
1659
- }
1660
- catch (e) {
1661
- throw new Error("player: unknown audio track");
1321
+ else {
1322
+ trackId = arg.trackId;
1323
+ periodId = arg.periodId;
1324
+ switchingMode = arg.switchingMode;
1325
+ reprsToLock = (_a = arg.lockedRepresentations) !== null && _a !== void 0 ? _a : null;
1662
1326
  }
1327
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) {
1328
+ return tcm.setAudioTrack(periodRef, trackId, switchingMode, reprsToLock);
1329
+ });
1663
1330
  };
1664
1331
  /**
1665
1332
  * Update the text language for the current Period.
1666
- * @param {string} sub
1667
- * @throws Error - the current content has no TrackChoiceManager.
1333
+ * @param {string | Object} arg
1334
+ * @throws Error - the current content has no TracksStore.
1668
1335
  * @throws Error - the given id is linked to no text track.
1669
1336
  */
1670
- Player.prototype.setTextTrack = function (textId) {
1337
+ Player.prototype.setTextTrack = function (arg) {
1671
1338
  if (this._priv_contentInfos === null) {
1672
1339
  throw new Error("No content loaded");
1673
1340
  }
1674
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1341
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, mediaElementTracksStore = _a.mediaElementTracksStore;
1675
1342
  if (isDirectFile) {
1676
1343
  try {
1677
- mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.setTextTrackById(textId);
1344
+ var textId = typeof arg === "string" ? arg :
1345
+ arg.trackId;
1346
+ mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.setTextTrackById(textId);
1678
1347
  return;
1679
1348
  }
1680
1349
  catch (e) {
1681
1350
  throw new Error("player: unknown text track");
1682
1351
  }
1683
1352
  }
1684
- if (trackChoiceManager === null || currentPeriod === null) {
1685
- throw new Error("No compatible content launched.");
1353
+ var periodId;
1354
+ var trackId;
1355
+ if (typeof arg === "string") {
1356
+ trackId = arg;
1686
1357
  }
1687
- try {
1688
- trackChoiceManager.setTextTrackByID(currentPeriod, textId);
1689
- }
1690
- catch (e) {
1691
- throw new Error("player: unknown text track");
1358
+ else {
1359
+ trackId = arg.trackId;
1360
+ periodId = arg.periodId;
1692
1361
  }
1362
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.setTextTrack(periodRef, trackId); });
1693
1363
  };
1694
1364
  /**
1695
1365
  * Disable subtitles for the current content.
1366
+ * @param {string|undefined} [periodId]
1696
1367
  */
1697
- Player.prototype.disableTextTrack = function () {
1368
+ Player.prototype.disableTextTrack = function (periodId) {
1698
1369
  if (this._priv_contentInfos === null) {
1699
1370
  return;
1700
1371
  }
1701
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1372
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, mediaElementTracksStore = _a.mediaElementTracksStore;
1702
1373
  if (isDirectFile) {
1703
- mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.disableTextTrack();
1704
- return;
1705
- }
1706
- if (trackChoiceManager === null || currentPeriod === null) {
1374
+ mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.disableTextTrack();
1707
1375
  return;
1708
1376
  }
1709
- return trackChoiceManager.disableTextTrack(currentPeriod);
1377
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.disableTrack(periodRef, "text"); });
1710
1378
  };
1711
1379
  /**
1712
1380
  * Update the video track for the current Period.
1713
- * @param {string} videoId
1714
- * @throws Error - the current content has no TrackChoiceManager.
1381
+ * @param {string | Object} arg
1382
+ * @throws Error - the current content has no TracksStore.
1715
1383
  * @throws Error - the given id is linked to no video track.
1716
1384
  */
1717
- Player.prototype.setVideoTrack = function (videoId) {
1385
+ Player.prototype.setVideoTrack = function (arg) {
1386
+ var _a;
1718
1387
  if (this._priv_contentInfos === null) {
1719
1388
  throw new Error("No content loaded");
1720
1389
  }
1721
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1390
+ var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, mediaElementTracksStore = _b.mediaElementTracksStore;
1722
1391
  if (isDirectFile) {
1723
1392
  try {
1724
- mediaElementTrackChoiceManager === null || mediaElementTrackChoiceManager === void 0 ? void 0 : mediaElementTrackChoiceManager.setVideoTrackById(videoId);
1393
+ var videoId = typeof arg === "string" ? arg :
1394
+ arg.trackId;
1395
+ mediaElementTracksStore === null || mediaElementTracksStore === void 0 ? void 0 : mediaElementTracksStore.setVideoTrackById(videoId);
1725
1396
  return;
1726
1397
  }
1727
1398
  catch (e) {
1728
1399
  throw new Error("player: unknown video track");
1729
1400
  }
1730
1401
  }
1731
- if (trackChoiceManager === null || currentPeriod === null) {
1732
- throw new Error("No compatible content launched.");
1733
- }
1734
- try {
1735
- trackChoiceManager.setVideoTrackByID(currentPeriod, videoId);
1402
+ var periodId;
1403
+ var trackId;
1404
+ var switchingMode;
1405
+ var reprsToLock = null;
1406
+ if (typeof arg === "string") {
1407
+ trackId = arg;
1736
1408
  }
1737
- catch (e) {
1738
- throw new Error("player: unknown video track");
1409
+ else {
1410
+ trackId = arg.trackId;
1411
+ periodId = arg.periodId;
1412
+ switchingMode = arg.switchingMode;
1413
+ reprsToLock = (_a = arg.lockedRepresentations) !== null && _a !== void 0 ? _a : null;
1739
1414
  }
1415
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) {
1416
+ return tcm.setVideoTrack(periodRef, trackId, switchingMode, reprsToLock);
1417
+ });
1740
1418
  };
1741
1419
  /**
1742
1420
  * Disable video track for the current content.
1421
+ * @param {string|undefined} [periodId]
1743
1422
  */
1744
- Player.prototype.disableVideoTrack = function () {
1423
+ Player.prototype.disableVideoTrack = function (periodId) {
1745
1424
  if (this._priv_contentInfos === null) {
1746
1425
  return;
1747
1426
  }
1748
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, isDirectFile = _a.isDirectFile, trackChoiceManager = _a.trackChoiceManager, mediaElementTrackChoiceManager = _a.mediaElementTrackChoiceManager;
1749
- if (isDirectFile && mediaElementTrackChoiceManager !== null) {
1750
- return mediaElementTrackChoiceManager.disableVideoTrack();
1751
- }
1752
- if (trackChoiceManager === null || currentPeriod === null) {
1753
- return;
1427
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, mediaElementTracksStore = _a.mediaElementTracksStore;
1428
+ if (isDirectFile && mediaElementTracksStore !== null) {
1429
+ return mediaElementTracksStore.disableVideoTrack();
1754
1430
  }
1755
- return trackChoiceManager.disableVideoTrack(currentPeriod);
1431
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.disableTrack(periodRef, "video"); });
1756
1432
  };
1757
- /**
1758
- * Returns the current list of preferred audio tracks, in preference order.
1759
- * @returns {Array.<Object>}
1760
- */
1761
- Player.prototype.getPreferredAudioTracks = function () {
1762
- return this._priv_preferredAudioTracks;
1763
- };
1764
- /**
1765
- * Returns the current list of preferred text tracks, in preference order.
1766
- * @returns {Array.<Object>}
1767
- */
1768
- Player.prototype.getPreferredTextTracks = function () {
1769
- return this._priv_preferredTextTracks;
1770
- };
1771
- /**
1772
- * Returns the current list of preferred text tracks, in preference order.
1773
- * @returns {Array.<Object>}
1774
- */
1775
- Player.prototype.getPreferredVideoTracks = function () {
1776
- return this._priv_preferredVideoTracks;
1777
- };
1778
- /**
1779
- * Set the list of preferred audio tracks, in preference order.
1780
- * @param {Array.<Object>} tracks
1781
- * @param {boolean} shouldApply - `true` if those preferences should be
1782
- * applied on the currently loaded Period. `false` if it should only
1783
- * be applied to new content.
1784
- */
1785
- Player.prototype.setPreferredAudioTracks = function (tracks, shouldApply) {
1786
- if (shouldApply === void 0) { shouldApply = false; }
1787
- if (!Array.isArray(tracks)) {
1788
- throw new Error("Invalid `setPreferredAudioTracks` argument. " +
1789
- "Should have been an Array.");
1433
+ Player.prototype.lockVideoRepresentations = function (arg) {
1434
+ if (this._priv_contentInfos === null) {
1435
+ throw new Error("No content loaded");
1790
1436
  }
1791
- this._priv_preferredAudioTracks = tracks;
1792
- var contentInfos = this._priv_contentInfos;
1793
- if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.trackChoiceManager)) {
1794
- contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.trackChoiceManager.setPreferredAudioTracks(tracks, shouldApply);
1437
+ var isDirectFile = this._priv_contentInfos.isDirectFile;
1438
+ if (isDirectFile) {
1439
+ throw new Error("Cannot lock video Representations in directfile mode.");
1440
+ }
1441
+ var repsId;
1442
+ var periodId;
1443
+ var switchingMode;
1444
+ if (Array.isArray(arg)) {
1445
+ repsId = arg;
1446
+ periodId = undefined;
1795
1447
  }
1796
- else if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.mediaElementTrackChoiceManager)) {
1797
- contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.mediaElementTrackChoiceManager.setPreferredAudioTracks(tracks, shouldApply);
1448
+ else {
1449
+ repsId = arg.representations;
1450
+ periodId = arg.periodId;
1451
+ switchingMode = arg.switchingMode;
1798
1452
  }
1453
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) {
1454
+ return tcm.lockVideoRepresentations(periodRef, { representations: repsId, switchingMode: switchingMode });
1455
+ });
1799
1456
  };
1800
- /**
1801
- * Set the list of preferred text tracks, in preference order.
1802
- * @param {Array.<Object>} tracks
1803
- * @param {boolean} shouldApply - `true` if those preferences should be
1804
- * applied on the currently loaded Periods. `false` if it should only
1805
- * be applied to new content.
1806
- */
1807
- Player.prototype.setPreferredTextTracks = function (tracks, shouldApply) {
1808
- if (shouldApply === void 0) { shouldApply = false; }
1809
- if (!Array.isArray(tracks)) {
1810
- throw new Error("Invalid `setPreferredTextTracks` argument. " +
1811
- "Should have been an Array.");
1457
+ Player.prototype.lockAudioRepresentations = function (arg) {
1458
+ if (this._priv_contentInfos === null) {
1459
+ throw new Error("No content loaded");
1460
+ }
1461
+ var isDirectFile = this._priv_contentInfos.isDirectFile;
1462
+ if (isDirectFile) {
1463
+ throw new Error("Cannot lock audio Representations in directfile mode.");
1812
1464
  }
1813
- this._priv_preferredTextTracks = tracks;
1814
- var contentInfos = this._priv_contentInfos;
1815
- if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.trackChoiceManager)) {
1816
- contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.trackChoiceManager.setPreferredTextTracks(tracks, shouldApply);
1465
+ var repsId;
1466
+ var periodId;
1467
+ var switchingMode;
1468
+ if (Array.isArray(arg)) {
1469
+ repsId = arg;
1470
+ periodId = undefined;
1817
1471
  }
1818
- else if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.mediaElementTrackChoiceManager)) {
1819
- contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.mediaElementTrackChoiceManager.setPreferredTextTracks(tracks, shouldApply);
1472
+ else {
1473
+ repsId = arg.representations;
1474
+ periodId = arg.periodId;
1475
+ switchingMode = arg.switchingMode;
1820
1476
  }
1477
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) {
1478
+ return tcm.lockAudioRepresentations(periodRef, { representations: repsId, switchingMode: switchingMode });
1479
+ });
1821
1480
  };
1822
- /**
1823
- * Set the list of preferred text tracks, in preference order.
1824
- * @param {Array.<Object>} tracks
1825
- * @param {boolean} shouldApply - `true` if those preferences should be
1826
- * applied on the currently loaded Period. `false` if it should only
1827
- * be applied to new content.
1828
- */
1829
- Player.prototype.setPreferredVideoTracks = function (tracks, shouldApply) {
1830
- if (shouldApply === void 0) { shouldApply = false; }
1831
- if (!Array.isArray(tracks)) {
1832
- throw new Error("Invalid `setPreferredVideoTracks` argument. " +
1833
- "Should have been an Array.");
1834
- }
1835
- this._priv_preferredVideoTracks = tracks;
1836
- var contentInfos = this._priv_contentInfos;
1837
- if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.trackChoiceManager)) {
1838
- contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.trackChoiceManager.setPreferredVideoTracks(tracks, shouldApply);
1481
+ Player.prototype.getLockedVideoRepresentations = function (periodId) {
1482
+ if (this._priv_contentInfos === null) {
1483
+ return null;
1839
1484
  }
1840
- else if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.mediaElementTrackChoiceManager)) {
1841
- contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.mediaElementTrackChoiceManager.setPreferredVideoTracks(tracks, shouldApply);
1485
+ var isDirectFile = this._priv_contentInfos.isDirectFile;
1486
+ if (isDirectFile) {
1487
+ return null;
1842
1488
  }
1489
+ return this._priv_callTracksStoreGetterSetter(periodId, null, function (tcm, periodRef) { return tcm.getLockedVideoRepresentations(periodRef); });
1843
1490
  };
1844
- /**
1845
- * @returns {Array.<Object>|null}
1846
- * @deprecated
1847
- */
1848
- Player.prototype.getImageTrackData = function () {
1849
- warnOnce("`getImageTrackData` is deprecated." +
1850
- "Please use the `parseBifThumbnails` tool instead.");
1491
+ Player.prototype.getLockedAudioRepresentations = function (periodId) {
1851
1492
  if (this._priv_contentInfos === null) {
1852
1493
  return null;
1853
1494
  }
1854
- /* eslint-disable import/no-deprecated */
1855
- return this._priv_contentInfos.thumbnails;
1856
- /* eslint-enable import/no-deprecated */
1495
+ var isDirectFile = this._priv_contentInfos.isDirectFile;
1496
+ if (isDirectFile) {
1497
+ return null;
1498
+ }
1499
+ return this._priv_callTracksStoreGetterSetter(periodId, null, function (tcm, periodRef) { return tcm.getLockedAudioRepresentations(periodRef); });
1500
+ };
1501
+ Player.prototype.unlockVideoRepresentations = function (periodId) {
1502
+ if (this._priv_contentInfos === null) {
1503
+ return;
1504
+ }
1505
+ var isDirectFile = this._priv_contentInfos.isDirectFile;
1506
+ if (isDirectFile) {
1507
+ return;
1508
+ }
1509
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.unlockVideoRepresentations(periodRef); });
1510
+ };
1511
+ Player.prototype.unlockAudioRepresentations = function (periodId) {
1512
+ if (this._priv_contentInfos === null) {
1513
+ return;
1514
+ }
1515
+ var isDirectFile = this._priv_contentInfos.isDirectFile;
1516
+ if (isDirectFile) {
1517
+ return;
1518
+ }
1519
+ return this._priv_callTracksStoreGetterSetter(periodId, undefined, function (tcm, periodRef) { return tcm.unlockAudioRepresentations(periodRef); });
1857
1520
  };
1858
1521
  /**
1859
1522
  * Get minimum seek-able position.
@@ -1895,6 +1558,12 @@ var Player = /** @class */ (function (_super) {
1895
1558
  }
1896
1559
  return null;
1897
1560
  };
1561
+ // ---- Undocumented Private methods. ----
1562
+ //
1563
+ // Those methods are just here either to allow some tools relying on the
1564
+ // RxPlayer instance to work or to improve the RxPlayer's demo.
1565
+ //
1566
+ // They should not be used by any external code.
1898
1567
  /**
1899
1568
  * /!\ For demo use only! Do not touch!
1900
1569
  *
@@ -1910,20 +1579,64 @@ var Player = /** @class */ (function (_super) {
1910
1579
  }
1911
1580
  var segmentBufferStatus = this._priv_contentInfos
1912
1581
  .segmentBuffersStore.getStatus(bufferType);
1913
- return segmentBufferStatus.type === "initialized" ?
1914
- segmentBufferStatus.value.getInventory() :
1915
- null;
1582
+ if (segmentBufferStatus.type === "initialized") {
1583
+ segmentBufferStatus.value.synchronizeInventory();
1584
+ return segmentBufferStatus.value.getInventory();
1585
+ }
1586
+ return null;
1916
1587
  };
1588
+ /**
1589
+ * /!\ For tools use only! Do not touch!
1590
+ *
1591
+ * Returns manifest/playlist object.
1592
+ * null if the player is STOPPED.
1593
+ * @returns {Manifest|null} - The current Manifest (`null` when not known).
1594
+ */
1595
+ // TODO remove the need for that public method
1596
+ Player.prototype.__priv_getManifest = function () {
1597
+ if (this._priv_contentInfos === null) {
1598
+ return null;
1599
+ }
1600
+ return this._priv_contentInfos.manifest;
1601
+ };
1602
+ // TODO remove the need for that public method
1603
+ Player.prototype.__priv_getCurrentAdaptation = function () {
1604
+ if (this._priv_contentInfos === null) {
1605
+ return null;
1606
+ }
1607
+ var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, activeAdaptations = _a.activeAdaptations;
1608
+ if (currentPeriod === null ||
1609
+ activeAdaptations === null ||
1610
+ isNullOrUndefined(activeAdaptations[currentPeriod.id])) {
1611
+ return null;
1612
+ }
1613
+ return activeAdaptations[currentPeriod.id];
1614
+ };
1615
+ // TODO remove the need for that public method
1616
+ Player.prototype.__priv_getCurrentRepresentations = function () {
1617
+ if (this._priv_contentInfos === null) {
1618
+ return null;
1619
+ }
1620
+ var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, activeRepresentations = _a.activeRepresentations;
1621
+ if (currentPeriod === null ||
1622
+ activeRepresentations === null ||
1623
+ isNullOrUndefined(activeRepresentations[currentPeriod.id])) {
1624
+ return null;
1625
+ }
1626
+ return activeRepresentations[currentPeriod.id];
1627
+ };
1628
+ // ---- Private methods ----
1917
1629
  /**
1918
1630
  * Reset all state properties relative to a playing content.
1919
1631
  */
1920
1632
  Player.prototype._priv_cleanUpCurrentContentState = function () {
1921
1633
  var _this = this;
1922
- var _a, _b;
1634
+ var _a, _b, _c, _d;
1923
1635
  log.debug("Locking `contentLock` to clean-up the current content.");
1924
1636
  // lock playback of new contents while cleaning up is pending
1925
1637
  this._priv_contentLock.setValue(true);
1926
- (_b = (_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.mediaElementTrackChoiceManager) === null || _b === void 0 ? void 0 : _b.dispose();
1638
+ (_b = (_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.tracksStore) === null || _b === void 0 ? void 0 : _b.dispose();
1639
+ (_d = (_c = this._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.mediaElementTracksStore) === null || _d === void 0 ? void 0 : _d.dispose();
1927
1640
  this._priv_contentInfos = null;
1928
1641
  this._priv_contentEventsMemory = {};
1929
1642
  // DRM-related clean-up
@@ -1963,29 +1676,29 @@ var Player = /** @class */ (function (_super) {
1963
1676
  contentInfos.manifest = manifest;
1964
1677
  var cancelSignal = contentInfos.currentContentCanceller.signal;
1965
1678
  this._priv_reloadingMetadata.manifest = manifest;
1966
- var initialAudioTrack = contentInfos.initialAudioTrack, initialTextTrack = contentInfos.initialTextTrack;
1967
- contentInfos.trackChoiceManager = new TrackChoiceManager({
1679
+ contentInfos.tracksStore = new TracksStore({
1968
1680
  preferTrickModeTracks: this._priv_preferTrickModeTracks,
1681
+ defaultAudioTrackSwitchingMode: contentInfos.defaultAudioTrackSwitchingMode,
1682
+ });
1683
+ contentInfos.tracksStore.addEventListener("newAvailablePeriods", function (p) {
1684
+ _this.trigger("newAvailablePeriods", p);
1969
1685
  });
1970
- var preferredAudioTracks = initialAudioTrack === undefined ?
1971
- this._priv_preferredAudioTracks :
1972
- [initialAudioTrack];
1973
- contentInfos.trackChoiceManager.setPreferredAudioTracks(preferredAudioTracks, true);
1974
- var preferredTextTracks = initialTextTrack === undefined ?
1975
- this._priv_preferredTextTracks :
1976
- [initialTextTrack];
1977
- contentInfos.trackChoiceManager.setPreferredTextTracks(preferredTextTracks, true);
1978
- contentInfos.trackChoiceManager
1979
- .setPreferredVideoTracks(this._priv_preferredVideoTracks, true);
1686
+ contentInfos.tracksStore.addEventListener("brokenRepresentationsLock", function (e) {
1687
+ _this.trigger("brokenRepresentationsLock", e);
1688
+ });
1689
+ contentInfos.tracksStore.addEventListener("trackUpdate", function (e) {
1690
+ _this.trigger("trackUpdate", e);
1691
+ });
1692
+ contentInfos.tracksStore.updatePeriodList(manifest);
1980
1693
  manifest.addEventListener("manifestUpdate", function (updates) {
1981
1694
  var _a, _b, _c;
1982
1695
  // Update the tracks chosen if it changed
1983
- if (contentInfos.trackChoiceManager !== null) {
1984
- contentInfos.trackChoiceManager.update();
1696
+ if (!isNullOrUndefined(contentInfos === null || contentInfos === void 0 ? void 0 : contentInfos.tracksStore)) {
1697
+ contentInfos.tracksStore.updatePeriodList(manifest);
1985
1698
  }
1986
1699
  var currentPeriod = (_b = (_a = _this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.currentPeriod) !== null && _b !== void 0 ? _b : undefined;
1987
- var trackChoiceManager = (_c = _this._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.trackChoiceManager;
1988
- if (currentPeriod === undefined || isNullOrUndefined(trackChoiceManager)) {
1700
+ var tracksStore = (_c = _this._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.tracksStore;
1701
+ if (currentPeriod === undefined || isNullOrUndefined(tracksStore)) {
1989
1702
  return;
1990
1703
  }
1991
1704
  for (var _i = 0, _d = updates.updatedPeriods; _i < _d.length; _i++) {
@@ -1994,11 +1707,15 @@ var Player = /** @class */ (function (_super) {
1994
1707
  if (update.result.addedAdaptations.length > 0 ||
1995
1708
  update.result.removedAdaptations.length > 0) {
1996
1709
  // We might have new (or less) tracks, send events just to be sure
1997
- var audioTracks = trackChoiceManager.getAvailableAudioTracks(currentPeriod);
1710
+ var periodRef = tracksStore.getPeriodObjectFromPeriod(currentPeriod);
1711
+ if (periodRef === undefined) {
1712
+ return;
1713
+ }
1714
+ var audioTracks = tracksStore.getAvailableAudioTracks(periodRef);
1998
1715
  _this._priv_triggerEventIfNotStopped("availableAudioTracksChange", audioTracks !== null && audioTracks !== void 0 ? audioTracks : [], cancelSignal);
1999
- var textTracks = trackChoiceManager.getAvailableTextTracks(currentPeriod);
1716
+ var textTracks = tracksStore.getAvailableTextTracks(periodRef);
2000
1717
  _this._priv_triggerEventIfNotStopped("availableTextTracksChange", textTracks !== null && textTracks !== void 0 ? textTracks : [], cancelSignal);
2001
- var videoTracks = trackChoiceManager.getAvailableVideoTracks(currentPeriod);
1718
+ var videoTracks = tracksStore.getAvailableVideoTracks(periodRef);
2002
1719
  _this._priv_triggerEventIfNotStopped("availableVideoTracksChange", videoTracks !== null && videoTracks !== void 0 ? videoTracks : [], cancelSignal);
2003
1720
  }
2004
1721
  }
@@ -2014,7 +1731,7 @@ var Player = /** @class */ (function (_super) {
2014
1731
  * @param {Object} periodInfo
2015
1732
  */
2016
1733
  Player.prototype._priv_onActivePeriodChanged = function (contentInfos, _a) {
2017
- var _b, _c, _d, _e, _f, _g, _h, _j;
1734
+ var _b, _c, _d, _e, _f, _g;
2018
1735
  var period = _a.period;
2019
1736
  if (contentInfos.contentId !== ((_b = this._priv_contentInfos) === null || _b === void 0 ? void 0 : _b.contentId)) {
2020
1737
  return; // Event for another content
@@ -2023,41 +1740,35 @@ var Player = /** @class */ (function (_super) {
2023
1740
  var cancelSignal = contentInfos.currentContentCanceller.signal;
2024
1741
  if (this._priv_contentEventsMemory.periodChange !== period) {
2025
1742
  this._priv_contentEventsMemory.periodChange = period;
2026
- this._priv_triggerEventIfNotStopped("periodChange", period, cancelSignal);
1743
+ this._priv_triggerEventIfNotStopped("periodChange", { start: period.start,
1744
+ end: period.end,
1745
+ id: period.id }, cancelSignal);
2027
1746
  }
2028
1747
  this._priv_triggerEventIfNotStopped("availableAudioTracksChange", this.getAvailableAudioTracks(), cancelSignal);
2029
1748
  this._priv_triggerEventIfNotStopped("availableTextTracksChange", this.getAvailableTextTracks(), cancelSignal);
2030
1749
  this._priv_triggerEventIfNotStopped("availableVideoTracksChange", this.getAvailableVideoTracks(), cancelSignal);
2031
- var trackChoiceManager = (_c = this._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.trackChoiceManager;
2032
- // Emit intial events for the Period
2033
- if (!isNullOrUndefined(trackChoiceManager)) {
2034
- var audioTrack = trackChoiceManager.getChosenAudioTrack(period);
2035
- this._priv_triggerEventIfNotStopped("audioTrackChange", audioTrack, cancelSignal);
2036
- var textTrack = trackChoiceManager.getChosenTextTrack(period);
2037
- this._priv_triggerEventIfNotStopped("textTrackChange", textTrack, cancelSignal);
2038
- var videoTrack = trackChoiceManager.getChosenVideoTrack(period);
2039
- this._priv_triggerEventIfNotStopped("videoTrackChange", videoTrack, cancelSignal);
1750
+ var tracksStore = (_c = this._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.tracksStore;
1751
+ // Emit initial events for the Period
1752
+ if (!isNullOrUndefined(tracksStore)) {
1753
+ var periodRef = tracksStore.getPeriodObjectFromPeriod(period);
1754
+ if (periodRef) {
1755
+ var audioTrack = tracksStore.getChosenAudioTrack(periodRef);
1756
+ this._priv_triggerEventIfNotStopped("audioTrackChange", audioTrack, cancelSignal);
1757
+ var textTrack = tracksStore.getChosenTextTrack(periodRef);
1758
+ this._priv_triggerEventIfNotStopped("textTrackChange", textTrack, cancelSignal);
1759
+ var videoTrack = tracksStore.getChosenVideoTrack(periodRef);
1760
+ this._priv_triggerEventIfNotStopped("videoTrackChange", videoTrack, cancelSignal);
1761
+ }
2040
1762
  }
2041
1763
  else {
2042
1764
  this._priv_triggerEventIfNotStopped("audioTrackChange", null, cancelSignal);
2043
1765
  this._priv_triggerEventIfNotStopped("textTrackChange", null, cancelSignal);
2044
1766
  this._priv_triggerEventIfNotStopped("videoTrackChange", null, cancelSignal);
2045
1767
  }
2046
- this._priv_triggerAvailableBitratesChangeEvent("availableAudioBitratesChange", this.getAvailableAudioBitrates(), cancelSignal);
2047
- if (contentInfos.currentContentCanceller.isUsed()) {
2048
- return;
2049
- }
2050
- this._priv_triggerAvailableBitratesChangeEvent("availableVideoBitratesChange", this.getAvailableVideoBitrates(), cancelSignal);
2051
- if (contentInfos.currentContentCanceller.isUsed()) {
2052
- return;
2053
- }
2054
- var audioBitrate = (_f = (_e = (_d = this._priv_getCurrentRepresentations()) === null || _d === void 0 ? void 0 : _d.audio) === null || _e === void 0 ? void 0 : _e.bitrate) !== null && _f !== void 0 ? _f : -1;
2055
- this._priv_triggerCurrentBitrateChangeEvent("audioBitrateChange", audioBitrate, cancelSignal);
2056
- if (contentInfos.currentContentCanceller.isUsed()) {
2057
- return;
2058
- }
2059
- var videoBitrate = (_j = (_h = (_g = this._priv_getCurrentRepresentations()) === null || _g === void 0 ? void 0 : _g.video) === null || _h === void 0 ? void 0 : _h.bitrate) !== null && _j !== void 0 ? _j : -1;
2060
- this._priv_triggerCurrentBitrateChangeEvent("videoBitrateChange", videoBitrate, cancelSignal);
1768
+ var audioRepresentation = (_e = (_d = this.__priv_getCurrentRepresentations()) === null || _d === void 0 ? void 0 : _d.audio) !== null && _e !== void 0 ? _e : null;
1769
+ this._priv_triggerEventIfNotStopped("audioRepresentationChange", audioRepresentation, cancelSignal);
1770
+ var videoRepresentation = (_g = (_f = this.__priv_getCurrentRepresentations()) === null || _f === void 0 ? void 0 : _f.video) !== null && _g !== void 0 ? _g : null;
1771
+ this._priv_triggerEventIfNotStopped("videoRepresentationChange", videoRepresentation, cancelSignal);
2061
1772
  };
2062
1773
  /**
2063
1774
  * Triggered each times a new "PeriodStream" is ready.
@@ -2070,48 +1781,22 @@ var Player = /** @class */ (function (_super) {
2070
1781
  if (contentInfos.contentId !== ((_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.contentId)) {
2071
1782
  return; // Event for another content
2072
1783
  }
2073
- var type = value.type, period = value.period, adaptationRef = value.adaptationRef;
2074
- var trackChoiceManager = contentInfos.trackChoiceManager;
1784
+ var type = value.type, manifest = value.manifest, period = value.period, adaptationRef = value.adaptationRef;
1785
+ var tracksStore = contentInfos.tracksStore;
2075
1786
  switch (type) {
2076
1787
  case "video":
2077
- if (isNullOrUndefined(trackChoiceManager)) {
2078
- log.error("API: TrackChoiceManager not instanciated for a new video period");
2079
- adaptationRef.setValue(null);
2080
- }
2081
- else {
2082
- trackChoiceManager.addPeriod(type, period, adaptationRef);
2083
- trackChoiceManager.setInitialVideoTrack(period);
2084
- }
2085
- break;
2086
1788
  case "audio":
2087
- if (isNullOrUndefined(trackChoiceManager)) {
2088
- log.error("API: TrackChoiceManager not instanciated for a new ".concat(type, " period"));
2089
- adaptationRef.setValue(null);
2090
- }
2091
- else {
2092
- trackChoiceManager.addPeriod(type, period, adaptationRef);
2093
- trackChoiceManager.setInitialAudioTrack(period);
2094
- }
2095
- break;
2096
1789
  case "text":
2097
- if (isNullOrUndefined(trackChoiceManager)) {
2098
- log.error("API: TrackChoiceManager not instanciated for a new ".concat(type, " period"));
1790
+ if (isNullOrUndefined(tracksStore)) {
1791
+ log.error("API: TracksStore not instanciated for a new ".concat(type, " period"));
2099
1792
  adaptationRef.setValue(null);
2100
1793
  }
2101
1794
  else {
2102
- trackChoiceManager.addPeriod(type, period, adaptationRef);
2103
- trackChoiceManager.setInitialTextTrack(period);
1795
+ tracksStore.addTrackReference(type, manifest, period, adaptationRef);
2104
1796
  }
2105
1797
  break;
2106
1798
  default:
2107
- var adaptations = period.adaptations[type];
2108
- if (!isNullOrUndefined(adaptations) && adaptations.length > 0) {
2109
- adaptationRef.setValue(adaptations[0]);
2110
- }
2111
- else {
2112
- adaptationRef.setValue(null);
2113
- }
2114
- break;
1799
+ assertUnreachable(type);
2115
1800
  }
2116
1801
  };
2117
1802
  /**
@@ -2125,14 +1810,14 @@ var Player = /** @class */ (function (_super) {
2125
1810
  return; // Event for another content
2126
1811
  }
2127
1812
  var type = value.type, period = value.period;
2128
- var trackChoiceManager = contentInfos.trackChoiceManager;
2129
- // Clean-up track choice from TrackChoiceManager
1813
+ var tracksStore = contentInfos.tracksStore;
1814
+ // Clean-up track choices from TracksStore
2130
1815
  switch (type) {
2131
1816
  case "audio":
2132
1817
  case "text":
2133
1818
  case "video":
2134
- if (!isNullOrUndefined(trackChoiceManager)) {
2135
- trackChoiceManager.removePeriod(type, period);
1819
+ if (!isNullOrUndefined(tracksStore)) {
1820
+ tracksStore.removeTrackReference(type, period);
2136
1821
  }
2137
1822
  break;
2138
1823
  }
@@ -2181,27 +1866,27 @@ var Player = /** @class */ (function (_super) {
2181
1866
  else {
2182
1867
  activePeriodAdaptations[type] = adaptation;
2183
1868
  }
2184
- var trackChoiceManager = contentInfos.trackChoiceManager;
1869
+ var tracksStore = contentInfos.tracksStore;
2185
1870
  var cancelSignal = contentInfos.currentContentCanceller.signal;
2186
- if (trackChoiceManager !== null &&
1871
+ if (tracksStore !== null &&
2187
1872
  currentPeriod !== null && !isNullOrUndefined(period) &&
2188
1873
  period.id === currentPeriod.id) {
1874
+ var periodRef = tracksStore.getPeriodObjectFromPeriod(period);
1875
+ if (periodRef === undefined) {
1876
+ return;
1877
+ }
2189
1878
  switch (type) {
2190
1879
  case "audio":
2191
- var audioTrack = trackChoiceManager.getChosenAudioTrack(currentPeriod);
1880
+ var audioTrack = tracksStore.getChosenAudioTrack(periodRef);
2192
1881
  this._priv_triggerEventIfNotStopped("audioTrackChange", audioTrack, cancelSignal);
2193
- var availableAudioBitrates = this.getAvailableAudioBitrates();
2194
- this._priv_triggerAvailableBitratesChangeEvent("availableAudioBitratesChange", availableAudioBitrates, cancelSignal);
2195
1882
  break;
2196
1883
  case "text":
2197
- var textTrack = trackChoiceManager.getChosenTextTrack(currentPeriod);
1884
+ var textTrack = tracksStore.getChosenTextTrack(periodRef);
2198
1885
  this._priv_triggerEventIfNotStopped("textTrackChange", textTrack, cancelSignal);
2199
1886
  break;
2200
1887
  case "video":
2201
- var videoTrack = trackChoiceManager.getChosenVideoTrack(currentPeriod);
1888
+ var videoTrack = tracksStore.getChosenVideoTrack(periodRef);
2202
1889
  this._priv_triggerEventIfNotStopped("videoTrackChange", videoTrack, cancelSignal);
2203
- var availableVideoBitrates = this.getAvailableVideoBitrates();
2204
- this._priv_triggerAvailableBitratesChangeEvent("availableVideoBitratesChange", availableVideoBitrates, cancelSignal);
2205
1890
  break;
2206
1891
  }
2207
1892
  }
@@ -2216,7 +1901,7 @@ var Player = /** @class */ (function (_super) {
2216
1901
  */
2217
1902
  Player.prototype._priv_onRepresentationChange = function (contentInfos, _a) {
2218
1903
  var _b;
2219
- var _c, _d;
1904
+ var _c;
2220
1905
  var type = _a.type, period = _a.period, representation = _a.representation;
2221
1906
  if (contentInfos.contentId !== ((_c = this._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.contentId)) {
2222
1907
  return; // Event for another content
@@ -2233,16 +1918,15 @@ var Player = /** @class */ (function (_super) {
2233
1918
  else {
2234
1919
  activePeriodRepresentations[type] = representation;
2235
1920
  }
2236
- var bitrate = (_d = representation === null || representation === void 0 ? void 0 : representation.bitrate) !== null && _d !== void 0 ? _d : -1;
2237
1921
  if (!isNullOrUndefined(period) &&
2238
1922
  currentPeriod !== null &&
2239
1923
  currentPeriod.id === period.id) {
2240
1924
  var cancelSignal = this._priv_contentInfos.currentContentCanceller.signal;
2241
1925
  if (type === "video") {
2242
- this._priv_triggerCurrentBitrateChangeEvent("videoBitrateChange", bitrate, cancelSignal);
1926
+ this._priv_triggerEventIfNotStopped("videoRepresentationChange", representation, cancelSignal);
2243
1927
  }
2244
1928
  else if (type === "audio") {
2245
- this._priv_triggerCurrentBitrateChangeEvent("audioBitrateChange", bitrate, cancelSignal);
1929
+ this._priv_triggerEventIfNotStopped("audioRepresentationChange", representation, cancelSignal);
2246
1930
  }
2247
1931
  }
2248
1932
  };
@@ -2253,22 +1937,14 @@ var Player = /** @class */ (function (_super) {
2253
1937
  *
2254
1938
  * @param {Object} value
2255
1939
  */
2256
- Player.prototype._priv_onBitrateEstimationChange = function (_a) {
1940
+ Player.prototype._priv_onBitrateEstimateChange = function (_a) {
2257
1941
  var type = _a.type, bitrate = _a.bitrate;
2258
1942
  if (bitrate !== undefined) {
2259
1943
  this._priv_bitrateInfos.lastBitrates[type] = bitrate;
2260
1944
  }
2261
- this.trigger("bitrateEstimationChange", { type: type, bitrate: bitrate });
2262
- };
2263
- /**
2264
- * Triggered each time a textTrack is added to the video DOM Element.
2265
- *
2266
- * Trigger the right Player Event.
2267
- *
2268
- * @param {Array.<TextTrackElement>} tracks
2269
- */
2270
- Player.prototype._priv_onNativeTextTracksNext = function (tracks) {
2271
- this.trigger("nativeTextTracksChange", tracks);
1945
+ // !!! undocumented API :O !!!
1946
+ /* eslint-disable-next-line */
1947
+ this.trigger("__priv_bitrateEstimateChange", { type: type, bitrate: bitrate });
2272
1948
  };
2273
1949
  /**
2274
1950
  * Triggered each time the player state updates.
@@ -2307,7 +1983,7 @@ var Player = /** @class */ (function (_super) {
2307
1983
  position: observation.position,
2308
1984
  duration: observation.duration,
2309
1985
  playbackRate: observation.playbackRate,
2310
- maximumBufferTime: maximumPosition,
1986
+ maximumPosition: maximumPosition,
2311
1987
  // TODO bufferGap may be undefined
2312
1988
  bufferGap: observation.bufferGap === undefined ||
2313
1989
  !isFinite(observation.bufferGap) ?
@@ -2332,47 +2008,6 @@ var Player = /** @class */ (function (_super) {
2332
2008
  }
2333
2009
  this.trigger("positionUpdate", positionData);
2334
2010
  };
2335
- /**
2336
- * Trigger one of the "availableBitratesChange" event only if it changed from
2337
- * the previously stored value.
2338
- * @param {string} event
2339
- * @param {Array.<number>} newVal
2340
- * @param {Object} currentContentCancelSignal
2341
- */
2342
- Player.prototype._priv_triggerAvailableBitratesChangeEvent = function (event, newVal, currentContentCancelSignal) {
2343
- var prevVal = this._priv_contentEventsMemory[event];
2344
- if (!currentContentCancelSignal.isCancelled() &&
2345
- (prevVal === undefined || !areArraysOfNumbersEqual(newVal, prevVal))) {
2346
- this._priv_contentEventsMemory[event] = newVal;
2347
- this.trigger(event, newVal);
2348
- }
2349
- };
2350
- /**
2351
- * Trigger one of the "bitrateChange" event only if it changed from the
2352
- * previously stored value.
2353
- * @param {string} event
2354
- * @param {number} newVal
2355
- * @param {Object} currentContentCancelSignal
2356
- */
2357
- Player.prototype._priv_triggerCurrentBitrateChangeEvent = function (event, newVal, currentContentCancelSignal) {
2358
- if (!currentContentCancelSignal.isCancelled() &&
2359
- newVal !== this._priv_contentEventsMemory[event]) {
2360
- this._priv_contentEventsMemory[event] = newVal;
2361
- this.trigger(event, newVal);
2362
- }
2363
- };
2364
- Player.prototype._priv_getCurrentRepresentations = function () {
2365
- if (this._priv_contentInfos === null) {
2366
- return null;
2367
- }
2368
- var _a = this._priv_contentInfos, currentPeriod = _a.currentPeriod, activeRepresentations = _a.activeRepresentations;
2369
- if (currentPeriod === null ||
2370
- activeRepresentations === null ||
2371
- isNullOrUndefined(activeRepresentations[currentPeriod.id])) {
2372
- return null;
2373
- }
2374
- return activeRepresentations[currentPeriod.id];
2375
- };
2376
2011
  /**
2377
2012
  * @param {string} evt
2378
2013
  * @param {*} arg
@@ -2384,60 +2019,69 @@ var Player = /** @class */ (function (_super) {
2384
2019
  }
2385
2020
  };
2386
2021
  /**
2387
- * @param {Object} defaultAudioTrack
2388
- * @param {Object} defaultTextTrack
2389
2022
  * @param {Object} cancelSignal
2390
2023
  * @returns {Object}
2391
2024
  */
2392
- Player.prototype._priv_initializeMediaElementTrackChoiceManager = function (defaultAudioTrack, defaultTextTrack, cancelSignal) {
2025
+ Player.prototype._priv_initializeMediaElementTracksStore = function (cancelSignal) {
2393
2026
  var _this = this;
2394
2027
  var _a, _b, _c;
2395
- assert(features.directfile !== null, "Initializing `MediaElementTrackChoiceManager` without Directfile feature");
2396
- assert(this.videoElement !== null, "Initializing `MediaElementTrackChoiceManager` on a disposed RxPlayer");
2397
- var mediaElementTrackChoiceManager = new features.directfile.mediaElementTrackChoiceManager(this.videoElement);
2398
- var preferredAudioTracks = defaultAudioTrack === undefined ?
2399
- this._priv_preferredAudioTracks :
2400
- [defaultAudioTrack];
2401
- mediaElementTrackChoiceManager.setPreferredAudioTracks(preferredAudioTracks, true);
2402
- var preferredTextTracks = defaultTextTrack === undefined ?
2403
- this._priv_preferredTextTracks :
2404
- [defaultTextTrack];
2405
- mediaElementTrackChoiceManager.setPreferredTextTracks(preferredTextTracks, true);
2406
- mediaElementTrackChoiceManager
2407
- .setPreferredVideoTracks(this._priv_preferredVideoTracks, true);
2408
- this._priv_triggerEventIfNotStopped("availableAudioTracksChange", mediaElementTrackChoiceManager.getAvailableAudioTracks(), cancelSignal);
2409
- this._priv_triggerEventIfNotStopped("availableVideoTracksChange", mediaElementTrackChoiceManager.getAvailableVideoTracks(), cancelSignal);
2410
- this._priv_triggerEventIfNotStopped("availableTextTracksChange", mediaElementTrackChoiceManager.getAvailableTextTracks(), cancelSignal);
2411
- this._priv_triggerEventIfNotStopped("audioTrackChange", (_a = mediaElementTrackChoiceManager.getChosenAudioTrack()) !== null && _a !== void 0 ? _a : null, cancelSignal);
2412
- this._priv_triggerEventIfNotStopped("textTrackChange", (_b = mediaElementTrackChoiceManager.getChosenTextTrack()) !== null && _b !== void 0 ? _b : null, cancelSignal);
2413
- this._priv_triggerEventIfNotStopped("videoTrackChange", (_c = mediaElementTrackChoiceManager.getChosenVideoTrack()) !== null && _c !== void 0 ? _c : null, cancelSignal);
2414
- mediaElementTrackChoiceManager
2028
+ assert(features.directfile !== null, "Initializing `MediaElementTracksStore` without Directfile feature");
2029
+ assert(this.videoElement !== null, "Initializing `MediaElementTracksStore` on a disposed RxPlayer");
2030
+ var mediaElementTracksStore = new features.directfile.mediaElementTracksStore(this.videoElement);
2031
+ this._priv_triggerEventIfNotStopped("availableAudioTracksChange", mediaElementTracksStore.getAvailableAudioTracks(), cancelSignal);
2032
+ this._priv_triggerEventIfNotStopped("availableVideoTracksChange", mediaElementTracksStore.getAvailableVideoTracks(), cancelSignal);
2033
+ this._priv_triggerEventIfNotStopped("availableTextTracksChange", mediaElementTracksStore.getAvailableTextTracks(), cancelSignal);
2034
+ this._priv_triggerEventIfNotStopped("audioTrackChange", (_a = mediaElementTracksStore.getChosenAudioTrack()) !== null && _a !== void 0 ? _a : null, cancelSignal);
2035
+ this._priv_triggerEventIfNotStopped("textTrackChange", (_b = mediaElementTracksStore.getChosenTextTrack()) !== null && _b !== void 0 ? _b : null, cancelSignal);
2036
+ this._priv_triggerEventIfNotStopped("videoTrackChange", (_c = mediaElementTracksStore.getChosenVideoTrack()) !== null && _c !== void 0 ? _c : null, cancelSignal);
2037
+ mediaElementTracksStore
2415
2038
  .addEventListener("availableVideoTracksChange", function (val) {
2416
2039
  return _this.trigger("availableVideoTracksChange", val);
2417
2040
  });
2418
- mediaElementTrackChoiceManager
2041
+ mediaElementTracksStore
2419
2042
  .addEventListener("availableAudioTracksChange", function (val) {
2420
2043
  return _this.trigger("availableAudioTracksChange", val);
2421
2044
  });
2422
- mediaElementTrackChoiceManager
2045
+ mediaElementTracksStore
2423
2046
  .addEventListener("availableTextTracksChange", function (val) {
2424
2047
  return _this.trigger("availableTextTracksChange", val);
2425
2048
  });
2426
- mediaElementTrackChoiceManager
2049
+ mediaElementTracksStore
2427
2050
  .addEventListener("audioTrackChange", function (val) {
2428
2051
  return _this.trigger("audioTrackChange", val);
2429
2052
  });
2430
- mediaElementTrackChoiceManager
2053
+ mediaElementTracksStore
2431
2054
  .addEventListener("videoTrackChange", function (val) {
2432
2055
  return _this.trigger("videoTrackChange", val);
2433
2056
  });
2434
- mediaElementTrackChoiceManager
2057
+ mediaElementTracksStore
2435
2058
  .addEventListener("textTrackChange", function (val) {
2436
2059
  return _this.trigger("textTrackChange", val);
2437
2060
  });
2438
- return mediaElementTrackChoiceManager;
2061
+ return mediaElementTracksStore;
2062
+ };
2063
+ Player.prototype._priv_callTracksStoreGetterSetter = function (periodId, defaultValue, cb) {
2064
+ var _a, _b;
2065
+ if (this._priv_contentInfos === null ||
2066
+ this._priv_contentInfos.tracksStore === null) {
2067
+ log.warn("API: Trying to call track API too soon");
2068
+ return defaultValue;
2069
+ }
2070
+ var tracksStore = this._priv_contentInfos.tracksStore;
2071
+ var currentPeriod = (_b = (_a = this._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.currentPeriod) !== null && _b !== void 0 ? _b : undefined;
2072
+ var wantedPeriodId = periodId !== null && periodId !== void 0 ? periodId : currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.id;
2073
+ if (wantedPeriodId === undefined) {
2074
+ return defaultValue;
2075
+ }
2076
+ var periodRef = wantedPeriodId === (currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.id) ?
2077
+ tracksStore.getPeriodObjectFromPeriod(currentPeriod) :
2078
+ tracksStore.getPeriodObjectFromId(wantedPeriodId);
2079
+ if (periodRef === undefined) {
2080
+ return defaultValue;
2081
+ }
2082
+ return cb(tracksStore, periodRef);
2439
2083
  };
2440
2084
  return Player;
2441
2085
  }(EventEmitter));
2442
- Player.version = /* PLAYER_VERSION */ "3.32.2-canal.2023110700";
2086
+ Player.version = /* PLAYER_VERSION */ "3.32.1";
2443
2087
  export default Player;