rx-player 3.33.0-dev.2023111400 → 3.33.0-dev.2024011500

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 (142) hide show
  1. package/CHANGELOG.md +19 -4
  2. package/FILES.md +1 -1
  3. package/README.md +2 -33
  4. package/VERSION +1 -1
  5. package/dist/_esm5.processed/compat/browser_detection.d.ts +3 -1
  6. package/dist/_esm5.processed/compat/browser_detection.js +24 -4
  7. package/dist/_esm5.processed/compat/should_prevent_seeking_at_0_initially.d.ts +14 -0
  8. package/dist/_esm5.processed/compat/should_prevent_seeking_at_0_initially.js +17 -0
  9. package/dist/_esm5.processed/config.d.ts +1 -0
  10. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
  11. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +20 -10
  12. package/dist/_esm5.processed/core/api/option_utils.d.ts +2 -0
  13. package/dist/_esm5.processed/core/api/option_utils.js +2 -3
  14. package/dist/_esm5.processed/core/api/public_api.d.ts +9 -0
  15. package/dist/_esm5.processed/core/api/public_api.js +28 -5
  16. package/dist/_esm5.processed/core/decrypt/attach_media_keys.d.ts +2 -1
  17. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +2 -1
  18. package/dist/_esm5.processed/core/decrypt/init_media_keys.js +13 -5
  19. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +25 -8
  20. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +4 -6
  21. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  22. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +16 -17
  23. package/dist/_esm5.processed/core/init/utils/get_initial_time.d.ts +17 -3
  24. package/dist/_esm5.processed/core/init/utils/get_initial_time.js +9 -7
  25. package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +7 -5
  26. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.d.ts +2 -1
  27. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +59 -6
  28. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
  29. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +1 -1
  30. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
  31. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
  32. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +6 -1
  33. package/dist/_esm5.processed/core/segment_buffers/implementations/types.js +7 -2
  34. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  35. package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +2 -2
  36. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +31 -9
  37. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +27 -12
  38. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +16 -11
  39. package/dist/_esm5.processed/core/stream/representation/utils/get_buffer_status.js +6 -5
  40. package/dist/_esm5.processed/core/stream/representation/utils/get_needed_segments.js +1 -1
  41. package/dist/_esm5.processed/default_config.d.ts +7 -0
  42. package/dist/_esm5.processed/default_config.js +16 -0
  43. package/dist/_esm5.processed/manifest/manifest.js +8 -4
  44. package/dist/_esm5.processed/manifest/period.d.ts +3 -1
  45. package/dist/_esm5.processed/manifest/period.js +16 -3
  46. package/dist/_esm5.processed/manifest/representation_index/static.d.ts +1 -1
  47. package/dist/_esm5.processed/manifest/representation_index/static.js +2 -2
  48. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +4 -4
  49. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  50. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +4 -3
  51. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  52. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  53. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  54. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  55. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +2 -2
  56. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +12 -11
  57. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +43 -34
  58. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  59. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  60. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +247 -51
  61. package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  62. package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  63. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -11
  64. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +27 -14
  65. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  66. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +16 -17
  67. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -8
  68. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +21 -8
  69. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +7 -3
  70. package/dist/_esm5.processed/parsers/manifest/local/representation_index.d.ts +1 -1
  71. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +3 -3
  72. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  73. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +2 -2
  74. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +5 -5
  75. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +25 -9
  76. package/dist/_esm5.processed/parsers/manifest/utils/index_helpers.js +1 -1
  77. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
  78. package/dist/_esm5.processed/public_types.d.ts +14 -2
  79. package/dist/mpd-parser.wasm +0 -0
  80. package/dist/rx-player.js +860 -442
  81. package/dist/rx-player.min.js +1 -1
  82. package/package.json +7 -4
  83. package/scripts/canal-release.patch +316 -0
  84. package/scripts/make-dev-releases +90 -0
  85. package/scripts/update-version +7 -0
  86. package/sonar-project.properties +1 -1
  87. package/src/compat/browser_detection.ts +21 -1
  88. package/src/compat/should_prevent_seeking_at_0_initially.ts +19 -0
  89. package/src/core/api/debug/buffer_graph.ts +2 -5
  90. package/src/core/api/debug/modules/general_info.ts +15 -6
  91. package/src/core/api/option_utils.ts +3 -3
  92. package/src/core/api/public_api.ts +30 -5
  93. package/src/core/decrypt/attach_media_keys.ts +5 -2
  94. package/src/core/decrypt/init_media_keys.ts +10 -1
  95. package/src/core/init/directfile_content_initializer.ts +24 -7
  96. package/src/core/init/media_source_content_initializer.ts +7 -6
  97. package/src/core/init/utils/content_time_boundaries_observer.ts +23 -22
  98. package/src/core/init/utils/get_initial_time.ts +25 -12
  99. package/src/core/init/utils/get_loaded_reference.ts +7 -5
  100. package/src/core/init/utils/initial_seek_and_play.ts +59 -5
  101. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +10 -2
  102. package/src/core/segment_buffers/implementations/image/image_segment_buffer.ts +1 -1
  103. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +1 -1
  104. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +1 -1
  105. package/src/core/segment_buffers/implementations/types.ts +7 -2
  106. package/src/core/segment_buffers/index.ts +2 -0
  107. package/src/core/segment_buffers/inventory/index.ts +2 -0
  108. package/src/core/segment_buffers/inventory/segment_inventory.ts +56 -19
  109. package/src/core/stream/orchestrator/stream_orchestrator.ts +19 -15
  110. package/src/core/stream/representation/utils/get_buffer_status.ts +7 -5
  111. package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
  112. package/src/default_config.ts +17 -0
  113. package/src/manifest/manifest.ts +8 -4
  114. package/src/manifest/period.ts +16 -3
  115. package/src/manifest/representation_index/static.ts +2 -2
  116. package/src/manifest/representation_index/types.ts +4 -4
  117. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
  118. package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
  119. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
  120. package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
  121. package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
  122. package/src/parsers/manifest/dash/common/indexes/template.ts +53 -43
  123. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
  124. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
  125. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
  126. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -5
  127. package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
  128. package/src/parsers/manifest/dash/common/parse_periods.ts +14 -20
  129. package/src/parsers/manifest/dash/common/parse_representation_index.ts +51 -31
  130. package/src/parsers/manifest/dash/common/parse_representations.ts +9 -3
  131. package/src/parsers/manifest/local/representation_index.ts +3 -3
  132. package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
  133. package/src/parsers/manifest/smooth/representation_index.ts +23 -9
  134. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
  135. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
  136. package/src/parsers/manifest/utils/index_helpers.ts +1 -1
  137. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +3 -1
  138. package/src/public_types.ts +15 -2
  139. package/dist/_esm5.processed/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  140. package/dist/_esm5.processed/parsers/manifest/utils/is_segment_still_available.js +0 -51
  141. package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
  142. package/src/typings/object-assign.d.ts +0 -48
package/CHANGELOG.md CHANGED
@@ -1,20 +1,35 @@
1
1
  # Changelog
2
2
 
3
- ## v3.33.0-canal.2023111400 (2023-11-14)
3
+ ## v3.33.0-dev.2024011500 (2024-01-15)
4
4
 
5
5
  ### Features
6
6
 
7
- - Add the possibility to set a new `keySystems` option on the `reload` API [#1308]
7
+ - Add `getLivePosition` RxPlayer method [#1300]
8
+ - Add `startAt.fromLivePosition` `loadVideo` option [#1300]
9
+ - Add the possibility to set a new `keySystems` option on the `reload` API [#1308]
8
10
 
9
- ### Bug Fixes
11
+ ### Bug fixes
10
12
 
11
13
  - Fix subtitles "blinking" in some specific conditions, especially with some DASH low-latency contents [#1314]
12
14
  - DASH: Fix Period overlap resolution logic for when the first Period is removed [#1311]
13
- - Fix export of the `LOCAL_MANIFEST` experimental feature [#1305]
15
+ - TTML: Fix handling of the `tts:lineHeight` attribute [#1320]
16
+ - Fix import of the `LOCAL_MANIFEST` experimental feature
17
+ - Avoid very rarely skipping segments which initially were too big to be pushed due to memory limitations [#1323]
18
+ - Fix issue arising when using track APIs at the exact last possible position of a Period with no consecutive Period [#1337]
19
+ - Starting at the end (through a `startAt` `loadVideo` option) or reloading at the end led to the restart of the content [#1338]
20
+ - DRM/Safari: also perform Safari DRM work-arounds when the page is launched from the dock [#1351, #1356]
14
21
 
15
22
  ### Other improvements
16
23
 
17
24
  - DASH: rely on SCTE214 `supplementalCodecs` instead of `codecs` if it's supported to better support backward compatible Dolby Vision contents [#1307]
25
+ - DASH: Provide better support of the `availabilityTimeOffset` attribute [#1300]
26
+ - DEBUG_ELEMENT: Add unsupported and undecipherable bitrates to the debug element [#1321]
27
+ - DEBUG_ELEMENT: update buffer graph maximum size so it becomes more readable for lengthy contents [#1316]
28
+ - DEBUG_ELEMENT: always synchronize inventory of segments before rendering it [#1317]
29
+ - Remove remaining RxPlayer dependency removing possibility of some application-side bundling errors [#1312]
30
+ - Add exception to text Garbage collection logic to avoid unnecessarily reload text segments frequently [#1325]
31
+ - Avoid logging too much the buffer's content when our debugging UI or the demo is used [#1341]
32
+ - Demo: Fix reporting of live position in demo page [#1313]
18
33
 
19
34
 
20
35
  ## v3.32.1 (2023-10-19)
package/FILES.md CHANGED
@@ -20,7 +20,7 @@ At the time of writing, there are two distinct demos:
20
20
 
21
21
  ## `dist/`: Builds
22
22
 
23
- The `demo/` directory stores the player builds of the last version released.
23
+ The `dist/` directory stores the player builds of the last version released.
24
24
 
25
25
  Contains the minified (``rx-player.min.js``) and the non-minified files
26
26
  (``rx-player.js``). Both are automatically generated with scripts at every new
package/README.md CHANGED
@@ -179,21 +179,11 @@ Demo pages for our previous versions are also available
179
179
 
180
180
 
181
181
 
182
- ## Your questions ##############################################################
183
-
184
- You can ask directly your questions about the project on [our
185
- gitter](https://gitter.im/canalplus/rx-player).
186
- We will try our best to answer them as quickly as possible.
187
-
188
-
189
-
190
182
  ## Contribute ##################################################################
191
183
 
192
184
  Details on how to contribute is written in the [CONTRIBUTING.md
193
185
  file](./CONTRIBUTING.md) at the root of this repository.
194
186
 
195
- If you need more information, you can contact us via our [gitter
196
- room](https://gitter.im/canalplus/rx-player).
197
187
 
198
188
 
199
189
  ### Dependencies ###############################################################
@@ -238,7 +228,7 @@ Canal+ Group is a media company with many advanced needs when it comes to media
238
228
  playback: it provides both live and VoD stream with multiple encryption
239
229
  requirements, supports a very large panel of devices and has many other
240
230
  specificities (like adult content restrictions, ad-insertion, Peer-To-Peer
241
- integration...).
231
+ integration, low-latency live streaming...).
242
232
 
243
233
  When the time came to switch from a plugin-based web player approach to an HTML5
244
234
  one back in 2015, no media player had the key features we wanted, and including
@@ -249,7 +239,7 @@ The R&D department of Canal+ Group thus started to work on a new featureful
249
239
  media-player: the RxPlayer. To both help and profit from the community, it also
250
240
  decided to share it to everyone under a permissive open-source licence.
251
241
 
252
- Now, more than 6 years later, the RxPlayer continues to evolve at the same fast
242
+ Now, more than 8 years later, the RxPlayer continues to evolve at the same fast
253
243
  pace to include a lot of features and improvements you may not find in other
254
244
  media players.
255
245
  You can look at our
@@ -296,24 +286,3 @@ them. Amongst those:
296
286
  risks always low.
297
287
 
298
288
  \* In "directfile" mode, on compatible browsers
299
-
300
-
301
- ## Target support ##############################################################
302
-
303
- Here is a basic list of supported platforms:
304
-
305
- | | Chrome | IE [1] | Edge | Firefox | Safari | Opera |
306
- |-------------|:-------:|:-------:|:------:|:---------:|:--------:|:-------:|
307
- | Windows | >= 30 | >= 11 | >= 12 | >= 42 | >= 8 | >= 25 |
308
- | OSX | >= 30 | - | - | >= 42 | >= 8 | >= 25 |
309
- | Linux | >= 37 | - | - | >= 42 | - | >= 25 |
310
- | Android [2] | >= 30 | - | - | >= 42 | - | >= 15 |
311
- | iOS | No | - | - | No | No | No |
312
-
313
- [1] Only on Windows >= 8.
314
-
315
- [2] Android version >= 4.2
316
-
317
- And more. A good way to know if the browser should be supported by our player is
318
- to go on the page https://www.youtube.com/html5 and check for "Media Source
319
- Extensions" support.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 3.33.0-dev.2023111400
1
+ 3.33.0-dev.2024011500
@@ -39,4 +39,6 @@ declare let isWebOs2022: boolean;
39
39
  declare let isPanasonic: boolean;
40
40
  /** `true` for the PlayStation 5 game console. */
41
41
  declare let isPlayStation5: boolean;
42
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPlayStation5, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
42
+ /** `true` for the Xbox game consoles. */
43
+ declare let isXbox: boolean;
44
+ export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPlayStation5, isXbox, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
@@ -40,8 +40,10 @@ var isWebOs2022 = false;
40
40
  var isPanasonic = false;
41
41
  /** `true` for the PlayStation 5 game console. */
42
42
  var isPlayStation5 = false;
43
+ /** `true` for the Xbox game consoles. */
44
+ var isXbox = false;
43
45
  ((function findCurrentBrowser() {
44
- var _a, _b;
46
+ var _a, _b, _c;
45
47
  if (isNode) {
46
48
  return;
47
49
  }
@@ -66,9 +68,24 @@ var isPlayStation5 = false;
66
68
  /iPad|iPhone|iPod/.test(navigator.platform)) {
67
69
  isSafariMobile = true;
68
70
  }
69
- else if (Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") >= 0 ||
71
+ else if (
72
+ // the following statement check if the window.safari contains the method
73
+ // "pushNotification", this condition is not met when using web app from the dock
74
+ // on macOS, this is why we also check userAgent.
75
+ Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") >= 0 ||
70
76
  ((_b = (_a = window.safari) === null || _a === void 0 ? void 0 : _a.pushNotification) === null || _b === void 0 ? void 0 : _b.toString()) ===
71
- "[object SafariRemoteNotification]") {
77
+ "[object SafariRemoteNotification]" ||
78
+ // browsers are lying: Chrome reports both as Chrome and Safari in user
79
+ // agent string, So to detect Safari we have to check for the Safari string
80
+ // and the absence of the Chrome string
81
+ // eslint-disable-next-line max-len
82
+ // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#which_part_of_the_user_agent_contains_the_information_you_are_looking_for
83
+ ((/Safari\/(\d+)/).test(navigator.userAgent) &&
84
+ // Safari should contain Version/ in userAgent
85
+ (/Version\/(\d+)/).test(navigator.userAgent) &&
86
+ (((_c = navigator.vendor) === null || _c === void 0 ? void 0 : _c.indexOf("Apple")) !== -1) &&
87
+ !(/Chrome\/(\d+)/).test(navigator.userAgent) &&
88
+ !(/Chromium\/(\d+)/).test(navigator.userAgent))) {
72
89
  isSafariDesktop = true;
73
90
  }
74
91
  // 2 - Find out specific device/platform information
@@ -99,5 +116,8 @@ var isPlayStation5 = false;
99
116
  else if (/[Pp]anasonic/.test(navigator.userAgent)) {
100
117
  isPanasonic = true;
101
118
  }
119
+ else if (navigator.userAgent.indexOf("Xbox") !== -1) {
120
+ isXbox = true;
121
+ }
102
122
  })());
103
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPlayStation5, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
123
+ export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPlayStation5, isXbox, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * We noticed that on Xbox game consoles and Universal windows platforms
3
+ * (presumably an Edge version is in cause here), the browser didn't send
4
+ * a "seeking" event if we were seeking at a 0 position initially.
5
+ *
6
+ * We could theoretically never seek at 0 initially as the initial position of
7
+ * an HTMLMediaElement should be at 0 anyway, but we still do it as a safe
8
+ * solution, as many devices have a buggy integration of HTML5 media API.
9
+ *
10
+ * This function returns `true` when we should avoid doing so, for now only for
11
+ * the non-standard behavior of those Edge platforms.
12
+ * @returns {number}
13
+ */
14
+ export default function shouldPreventSeekingAt0Initially(): boolean;
@@ -0,0 +1,17 @@
1
+ import { isIEOrEdge, isXbox } from "./browser_detection";
2
+ /**
3
+ * We noticed that on Xbox game consoles and Universal windows platforms
4
+ * (presumably an Edge version is in cause here), the browser didn't send
5
+ * a "seeking" event if we were seeking at a 0 position initially.
6
+ *
7
+ * We could theoretically never seek at 0 initially as the initial position of
8
+ * an HTMLMediaElement should be at 0 anyway, but we still do it as a safe
9
+ * solution, as many devices have a buggy integration of HTML5 media API.
10
+ *
11
+ * This function returns `true` when we should avoid doing so, for now only for
12
+ * the non-standard behavior of those Edge platforms.
13
+ * @returns {number}
14
+ */
15
+ export default function shouldPreventSeekingAt0Initially() {
16
+ return isXbox || isIEOrEdge;
17
+ }
@@ -39,6 +39,7 @@ declare class ConfigHandler {
39
39
  DEFAULT_MAX_BUFFER_BEHIND: number;
40
40
  DEFAULT_MAX_VIDEO_BUFFER_SIZE: number;
41
41
  MAXIMUM_MAX_BUFFER_AHEAD: Partial<Record<"audio" | "video" | "image" | "text", number>>;
42
+ MINIMUM_MAX_BUFFER_AHEAD: Partial<Record<"audio" | "video" | "image" | "text", number>>;
42
43
  MAXIMUM_MAX_BUFFER_BEHIND: Partial<Record<"audio" | "video" | "image" | "text", number>>;
43
44
  DEFAULT_INITIAL_BITRATES: {
44
45
  audio: number;
@@ -1,4 +1,4 @@
1
- var BUFFER_WIDTH_IN_SECONDS = 10000;
1
+ var BUFFER_WIDTH_IN_SECONDS = 30 * 60;
2
2
  var COLORS = [
3
3
  "#2ab7ca",
4
4
  "#fed766",
@@ -65,11 +65,7 @@ var SegmentBufferGraph = /** @class */ (function () {
65
65
  var minimumPosition;
66
66
  var maximumPosition;
67
67
  if (maximumPoint - minimumPoint > BUFFER_WIDTH_IN_SECONDS) {
68
- if (currentTime === undefined) {
69
- minimumPosition = minimumPoint;
70
- maximumPosition = maximumPoint;
71
- }
72
- else if (maximumPoint - currentTime < BUFFER_WIDTH_IN_SECONDS / 2) {
68
+ if (maximumPoint - currentTime < BUFFER_WIDTH_IN_SECONDS / 2) {
73
69
  maximumPosition = maximumPoint;
74
70
  minimumPosition = maximumPoint - BUFFER_WIDTH_IN_SECONDS;
75
71
  }
@@ -17,6 +17,7 @@ export default function constructDebugGeneralInfo(instance, parentElt, cancelSig
17
17
  representationsElt,
18
18
  ]);
19
19
  function updateGeneralInfo() {
20
+ var _a, _b, _c, _d;
20
21
  var videoElement = instance.getVideoElement();
21
22
  if (videoElement === null) {
22
23
  // disposed player. Clean-up everything
@@ -99,12 +100,12 @@ export default function constructDebugGeneralInfo(instance, parentElt, cancelSig
99
100
  valuesLine3.push(["er", "\"".concat(String(error), "\"")]);
100
101
  }
101
102
  generalInfoElt.innerHTML = "";
102
- for (var _i = 0, _a = [valuesLine1, valuesLine2, valuesLine3]; _i < _a.length; _i++) {
103
- var valueSet = _a[_i];
103
+ for (var _i = 0, _e = [valuesLine1, valuesLine2, valuesLine3]; _i < _e.length; _i++) {
104
+ var valueSet = _e[_i];
104
105
  if (valueSet.length > 0) {
105
106
  var lineInfoElt = createElement("div");
106
- for (var _b = 0, valueSet_1 = valueSet; _b < valueSet_1.length; _b++) {
107
- var value = valueSet_1[_b];
107
+ for (var _f = 0, valueSet_1 = valueSet; _f < valueSet_1.length; _f++) {
108
+ var value = valueSet_1[_f];
108
109
  lineInfoElt.appendChild(createMetricTitle(value[0]));
109
110
  lineInfoElt.appendChild(createElement("span", {
110
111
  textContent: value[1] + " ",
@@ -175,19 +176,28 @@ export default function constructDebugGeneralInfo(instance, parentElt, cancelSig
175
176
  ]);
176
177
  adaptationsElt.appendChild(textAdaps);
177
178
  }
178
- var videoBitrates = instance.getAvailableVideoBitrates();
179
- var audioBitrates = instance.getAvailableAudioBitrates();
179
+ var adaptations = instance.getCurrentAdaptations();
180
+ var videoBitratesStr = (_b = (_a = adaptations === null || adaptations === void 0 ? void 0 : adaptations.video) === null || _a === void 0 ? void 0 : _a.representations.map(function (r) {
181
+ return String(r.bitrate) +
182
+ (r.isSupported ? "" : " U!") +
183
+ (r.decipherable !== false ? "" : " E!");
184
+ })) !== null && _b !== void 0 ? _b : [];
185
+ var audioBitratesStr = (_d = (_c = adaptations === null || adaptations === void 0 ? void 0 : adaptations.video) === null || _c === void 0 ? void 0 : _c.representations.map(function (r) {
186
+ return String(r.bitrate) +
187
+ (r.isSupported ? "" : " U!") +
188
+ (r.decipherable !== false ? "" : " E!");
189
+ })) !== null && _d !== void 0 ? _d : [];
180
190
  representationsElt.innerHTML = "";
181
- if (videoBitrates.length > 0) {
191
+ if (videoBitratesStr.length > 0) {
182
192
  representationsElt.appendChild(createMetricTitle("vb"));
183
193
  representationsElt.appendChild(createElement("span", {
184
- textContent: videoBitrates.join(" ") + " ",
194
+ textContent: videoBitratesStr.join(" ") + " ",
185
195
  }));
186
196
  }
187
- if (audioBitrates.length > 0) {
197
+ if (audioBitratesStr.length > 0) {
188
198
  representationsElt.appendChild(createMetricTitle("ab"));
189
199
  representationsElt.appendChild(createElement("span", {
190
- textContent: audioBitrates.join(" ") + " ",
200
+ textContent: audioBitratesStr.join(" ") + " ",
191
201
  }));
192
202
  }
193
203
  }
@@ -24,6 +24,8 @@ export type IParsedStartAtOption = {
24
24
  percentage: number;
25
25
  } | {
26
26
  fromLastPosition: number;
27
+ } | {
28
+ fromLivePosition: number;
27
29
  } | {
28
30
  fromFirstPosition: number;
29
31
  };
@@ -462,9 +462,8 @@ function parseLoadVideoOptions(options) {
462
462
  "an \"html\" textTrackMode. It will be ignored.");
463
463
  }
464
464
  if (!isNullOrUndefined(options.startAt)) {
465
- // TODO Better way to express that in TypeScript?
466
- if (options.startAt.wallClockTime
467
- instanceof Date) {
465
+ if ("wallClockTime" in options.startAt
466
+ && options.startAt.wallClockTime instanceof Date) {
468
467
  var wallClockTime = options.startAt
469
468
  .wallClockTime.getTime() / 1000;
470
469
  startAt = objectAssign({}, options.startAt, { wallClockTime: wallClockTime });
@@ -717,6 +717,15 @@ declare class Player extends EventEmitter<IPublicAPIEvent> {
717
717
  * @returns {number}
718
718
  */
719
719
  getMinimumPosition(): number | null;
720
+ /**
721
+ * Returns the current position for live contents.
722
+ *
723
+ * Returns `null` if no content is loaded or if the current loaded content is
724
+ * not considered as a live content.
725
+ * Returns `undefined` if that live position is currently unknown.
726
+ * @returns {number}
727
+ */
728
+ getLivePosition(): number | undefined | null;
720
729
  /**
721
730
  * Get maximum seek-able position.
722
731
  * @returns {number}
@@ -88,7 +88,7 @@ var Player = /** @class */ (function (_super) {
88
88
  // Workaround to support Firefox autoplay on FF 42.
89
89
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
90
90
  videoElement.preload = "auto";
91
- _this.version = /* PLAYER_VERSION */ "3.33.0-dev.2023111400";
91
+ _this.version = /* PLAYER_VERSION */ "3.33.0-dev.2024011500";
92
92
  _this.log = log;
93
93
  _this.state = "STOPPED";
94
94
  _this.videoElement = videoElement;
@@ -1882,6 +1882,27 @@ var Player = /** @class */ (function (_super) {
1882
1882
  }
1883
1883
  return null;
1884
1884
  };
1885
+ /**
1886
+ * Returns the current position for live contents.
1887
+ *
1888
+ * Returns `null` if no content is loaded or if the current loaded content is
1889
+ * not considered as a live content.
1890
+ * Returns `undefined` if that live position is currently unknown.
1891
+ * @returns {number}
1892
+ */
1893
+ Player.prototype.getLivePosition = function () {
1894
+ if (this._priv_contentInfos === null) {
1895
+ return null;
1896
+ }
1897
+ var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, manifest = _a.manifest;
1898
+ if (isDirectFile) {
1899
+ return undefined;
1900
+ }
1901
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.isLive) !== true) {
1902
+ return null;
1903
+ }
1904
+ return manifest.getLivePosition();
1905
+ };
1885
1906
  /**
1886
1907
  * Get maximum seek-able position.
1887
1908
  * @returns {number}
@@ -1920,9 +1941,11 @@ var Player = /** @class */ (function (_super) {
1920
1941
  }
1921
1942
  var segmentBufferStatus = this._priv_contentInfos
1922
1943
  .segmentBuffersStore.getStatus(bufferType);
1923
- return segmentBufferStatus.type === "initialized" ?
1924
- segmentBufferStatus.value.getInventory() :
1925
- null;
1944
+ if (segmentBufferStatus.type === "initialized") {
1945
+ segmentBufferStatus.value.synchronizeInventory(true);
1946
+ return segmentBufferStatus.value.getInventory();
1947
+ }
1948
+ return null;
1926
1949
  };
1927
1950
  /**
1928
1951
  * Reset all state properties relative to a playing content.
@@ -2449,5 +2472,5 @@ var Player = /** @class */ (function (_super) {
2449
2472
  };
2450
2473
  return Player;
2451
2474
  }(EventEmitter));
2452
- Player.version = /* PLAYER_VERSION */ "3.33.0-dev.2023111400";
2475
+ Player.version = /* PLAYER_VERSION */ "3.33.0-dev.2024011500";
2453
2476
  export default Player;
@@ -21,8 +21,9 @@ import LoadedSessionsStore from "./utils/loaded_sessions_store";
21
21
  * Dispose of the MediaKeys instance attached to the given media element, if
22
22
  * one.
23
23
  * @param {Object} mediaElement
24
+ * @returns {Promise}
24
25
  */
25
- export declare function disableMediaKeys(mediaElement: HTMLMediaElement): void;
26
+ export declare function disableMediaKeys(mediaElement: HTMLMediaElement): Promise<unknown>;
26
27
  /**
27
28
  * Attach MediaKeys and its associated state to an HTMLMediaElement.
28
29
  *
@@ -56,10 +56,11 @@ import MediaKeysInfosStore from "./utils/media_keys_infos_store";
56
56
  * Dispose of the MediaKeys instance attached to the given media element, if
57
57
  * one.
58
58
  * @param {Object} mediaElement
59
+ * @returns {Promise}
59
60
  */
60
61
  export function disableMediaKeys(mediaElement) {
61
62
  MediaKeysInfosStore.setState(mediaElement, null);
62
- eme.setMediaKeys(mediaElement, null)
63
+ return eme.setMediaKeys(mediaElement, null)
63
64
  .then(function () {
64
65
  log.info("DRM: MediaKeys disabled with success");
65
66
  })
@@ -49,7 +49,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
50
  }
51
51
  };
52
+ import { isWebOs } from "../../compat/browser_detection";
52
53
  import log from "../../log";
54
+ import noop from "../../utils/noop";
53
55
  import { disableMediaKeys } from "./attach_media_keys";
54
56
  import getMediaKeysInfos from "./get_media_keys";
55
57
  /**
@@ -71,11 +73,17 @@ export default function initMediaKeys(mediaElement, keySystemsConfigs, cancelSig
71
73
  shouldDisableOldMediaKeys = mediaElement.mediaKeys !== null &&
72
74
  mediaElement.mediaKeys !== undefined &&
73
75
  mediaKeys !== mediaElement.mediaKeys;
74
- if (shouldDisableOldMediaKeys) {
75
- log.debug("DRM: Disabling old MediaKeys");
76
- disableMediaKeys(mediaElement);
77
- }
78
- return [2 /*return*/, mediaKeysInfo];
76
+ if (!shouldDisableOldMediaKeys) return [3 /*break*/, 4];
77
+ log.debug("DRM: Disabling old MediaKeys");
78
+ if (!isWebOs) return [3 /*break*/, 3];
79
+ return [4 /*yield*/, disableMediaKeys(mediaElement)];
80
+ case 2:
81
+ _a.sent();
82
+ return [3 /*break*/, 4];
83
+ case 3:
84
+ disableMediaKeys(mediaElement).catch(noop);
85
+ _a.label = 4;
86
+ case 4: return [2 /*return*/, mediaKeysInfo];
79
87
  }
80
88
  });
81
89
  });
@@ -35,6 +35,7 @@ var __extends = (this && this.__extends) || (function () {
35
35
  import { clearElementSrc } from "../../compat";
36
36
  import log from "../../log";
37
37
  import assert from "../../utils/assert";
38
+ import isNullOrUndefined from "../../utils/is_null_or_undefined";
38
39
  import SharedReference from "../../utils/reference";
39
40
  import TaskCanceller from "../../utils/task_canceller";
40
41
  import { ContentInitializer } from "./types";
@@ -177,7 +178,7 @@ var DirectFileContentInitializer = /** @class */ (function (_super) {
177
178
  log.debug("Init: Initial time calculated:", initTime);
178
179
  return initTime;
179
180
  };
180
- performInitialSeekAndPlay(mediaElement, playbackObserver, initialTime, autoPlay, function (err) { return _this.trigger("warning", err); }, cancelSignal).autoPlayResult
181
+ performInitialSeekAndPlay(mediaElement, playbackObserver, initialTime, autoPlay, function (err) { return _this.trigger("warning", err); }, true, cancelSignal).autoPlayResult
181
182
  .then(function () {
182
183
  return getLoadedReference(playbackObserver, mediaElement, true, cancelSignal)
183
184
  .onUpdate(function (isLoaded, stopListening) {
@@ -203,10 +204,10 @@ export default DirectFileContentInitializer;
203
204
  * @returns {number}
204
205
  */
205
206
  function getDirectFileInitialTime(mediaElement, startAt) {
206
- if (startAt == null) {
207
+ if (isNullOrUndefined(startAt)) {
207
208
  return 0;
208
209
  }
209
- if (startAt.position != null) {
210
+ if (!isNullOrUndefined(startAt.position)) {
210
211
  return startAt.position;
211
212
  }
212
213
  else if (startAt.wallClockTime != null) {
@@ -216,15 +217,31 @@ function getDirectFileInitialTime(mediaElement, startAt) {
216
217
  return startAt.fromFirstPosition;
217
218
  }
218
219
  var duration = mediaElement.duration;
219
- if (duration == null || !isFinite(duration)) {
220
- log.warn("startAt.fromLastPosition set but no known duration, " +
221
- "beginning at 0.");
222
- return 0;
223
- }
224
220
  if (typeof startAt.fromLastPosition === "number") {
221
+ if (isNullOrUndefined(duration) || !isFinite(duration)) {
222
+ log.warn("startAt.fromLastPosition set but no known duration, " +
223
+ "beginning at 0.");
224
+ return 0;
225
+ }
225
226
  return Math.max(0, duration + startAt.fromLastPosition);
226
227
  }
228
+ else if (typeof startAt.fromLivePosition === "number") {
229
+ var livePosition = mediaElement.seekable.length > 0 ?
230
+ mediaElement.seekable.end(0) :
231
+ duration;
232
+ if (isNullOrUndefined(livePosition)) {
233
+ log.warn("startAt.fromLivePosition set but no known live position, " +
234
+ "beginning at 0.");
235
+ return 0;
236
+ }
237
+ return Math.max(0, livePosition + startAt.fromLivePosition);
238
+ }
227
239
  else if (startAt.percentage != null) {
240
+ if (isNullOrUndefined(duration) || !isFinite(duration)) {
241
+ log.warn("startAt.percentage set but no known duration, " +
242
+ "beginning at 0.");
243
+ return 0;
244
+ }
228
245
  var percentage = startAt.percentage;
229
246
  if (percentage >= 100) {
230
247
  return duration;
@@ -331,7 +331,7 @@ var MediaSourceContentInitializer = /** @class */ (function (_super) {
331
331
  cancelSignal.register(function () {
332
332
  segmentBuffersStore.disposeAll();
333
333
  });
334
- var _b = performInitialSeekAndPlay(mediaElement, playbackObserver, initialTime, autoPlay, function (err) { return _this.trigger("warning", err); }, cancelSignal), autoPlayResult = _b.autoPlayResult, initialPlayPerformed = _b.initialPlayPerformed, initialSeekPerformed = _b.initialSeekPerformed;
334
+ var _b = performInitialSeekAndPlay(mediaElement, playbackObserver, initialTime, autoPlay, function (err) { return _this.trigger("warning", err); }, true, cancelSignal), autoPlayResult = _b.autoPlayResult, initialPlayPerformed = _b.initialPlayPerformed, initialSeekPerformed = _b.initialSeekPerformed;
335
335
  if (cancelSignal.isCancelled()) {
336
336
  return;
337
337
  }
@@ -569,9 +569,7 @@ var MediaSourceContentInitializer = /** @class */ (function (_super) {
569
569
  contentTimeBoundariesObserver.addEventListener("periodChange", function (period) {
570
570
  _this.trigger("activePeriodChanged", { period: period });
571
571
  });
572
- contentTimeBoundariesObserver.addEventListener("durationUpdate", function (newDuration) {
573
- mediaSourceDurationUpdater.updateDuration(newDuration.duration, newDuration.isEnd);
574
- });
572
+ contentTimeBoundariesObserver.addEventListener("endingPositionChange", function (x) { return mediaSourceDurationUpdater.updateDuration(x.endingPosition, x.isEnd); });
575
573
  contentTimeBoundariesObserver.addEventListener("endOfStream", function () {
576
574
  if (endOfStreamCanceller === null) {
577
575
  endOfStreamCanceller = new TaskCanceller();
@@ -587,8 +585,8 @@ var MediaSourceContentInitializer = /** @class */ (function (_super) {
587
585
  endOfStreamCanceller = null;
588
586
  }
589
587
  });
590
- var currentDuration = contentTimeBoundariesObserver.getCurrentDuration();
591
- mediaSourceDurationUpdater.updateDuration(currentDuration.duration, currentDuration.isEnd);
588
+ var endInfo = contentTimeBoundariesObserver.getCurrentEndingTime();
589
+ mediaSourceDurationUpdater.updateDuration(endInfo.endingPosition, endInfo.isEnd);
592
590
  return contentTimeBoundariesObserver;
593
591
  };
594
592
  /**
@@ -22,8 +22,8 @@ import { IStreamOrchestratorPlaybackObservation } from "../../stream";
22
22
  /**
23
23
  * Observes what's being played and take care of media events relating to time
24
24
  * boundaries:
25
- * - Emits a `durationUpdate` when the duration of the current content is
26
- * known and every time it changes.
25
+ * - Emits a `endingPositionChange` when the known maximum playable position
26
+ * of the current content is known and every time it changes.
27
27
  * - Emits `endOfStream` API once segments have been pushed until the end and
28
28
  * `resumeStream` if downloads starts back.
29
29
  * - Emits a `periodChange` event when the currently-playing Period seemed to
@@ -56,10 +56,11 @@ export default class ContentTimeBoundariesObserver extends EventEmitter<IContent
56
56
  */
57
57
  constructor(manifest: Manifest, playbackObserver: IReadOnlyPlaybackObserver<IStreamOrchestratorPlaybackObservation>, bufferTypes: IBufferType[]);
58
58
  /**
59
- * Returns an estimate of the current duration of the content.
59
+ * Returns an estimate of the current last position which may be played in
60
+ * the content at the moment.
60
61
  * @returns {Object}
61
62
  */
62
- getCurrentDuration(): IDurationItem;
63
+ getCurrentEndingTime(): IEndingPositionInformation;
63
64
  /**
64
65
  * Method to call any time an Adaptation has been selected.
65
66
  *
@@ -126,20 +127,20 @@ export default class ContentTimeBoundariesObserver extends EventEmitter<IContent
126
127
  private _addActivelyLoadedPeriod;
127
128
  private _removeActivelyLoadedPeriod;
128
129
  private _checkCurrentPeriod;
129
- private _getManifestDuration;
130
+ private _getManifestEndTime;
130
131
  private _lazilyCreateActiveStreamInfo;
131
132
  private _checkEndOfStream;
132
133
  }
133
- export interface IDurationItem {
134
+ export interface IEndingPositionInformation {
134
135
  /**
135
136
  * The new maximum known position (note that this is the ending position
136
137
  * currently known of the current content, it might be superior to the last
137
138
  * position at which segments are available and it might also evolve over
138
139
  * time), in seconds.
139
140
  */
140
- duration: number;
141
+ endingPosition: number;
141
142
  /**
142
- * If `true`, the communicated `duration` is the actual end of the content.
143
+ * If `true`, the communicated `endingPosition` is the actual end of the content.
143
144
  * It may still be updated due to a track change or to add precision, but it
144
145
  * is still a (rough) estimate of the maximum position that content should
145
146
  * have.
@@ -147,7 +148,7 @@ export interface IDurationItem {
147
148
  * If `false`, this is the currently known maximum position associated to
148
149
  * the content, but the content is still evolving (typically, new media
149
150
  * segments are still being generated) and as such it can still have a
150
- * longer duration in the future.
151
+ * longer `endingPosition` in the future.
151
152
  */
152
153
  isEnd: boolean;
153
154
  }
@@ -161,10 +162,10 @@ export interface IContentTimeBoundariesObserverEvent {
161
162
  /** Triggered when a new `Period` is currently playing. */
162
163
  periodChange: Period;
163
164
  /**
164
- * Triggered when the duration of the currently-playing content became known
165
- * or changed.
165
+ * Triggered when the ending position of the currently-playing content became
166
+ * known or changed.
166
167
  */
167
- durationUpdate: IDurationItem;
168
+ endingPositionChange: IEndingPositionInformation;
168
169
  /**
169
170
  * Triggered when the last possible chronological segment for all types of
170
171
  * buffers has either been pushed or is being pushed to the corresponding