rx-player 4.0.0-beta.0 → 4.0.0-beta.1

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 (186) hide show
  1. package/.eslintrc.js +8 -0
  2. package/CHANGELOG.md +53 -0
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/browser_detection.d.ts +23 -12
  5. package/dist/_esm5.processed/compat/browser_detection.js +80 -38
  6. package/dist/_esm5.processed/compat/can_reuse_media_keys.js +2 -2
  7. package/dist/_esm5.processed/compat/eme/close_session.js +2 -2
  8. package/dist/_esm5.processed/compat/event_listeners.js +1 -1
  9. package/dist/_esm5.processed/config.d.ts +2 -0
  10. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +4 -2
  11. package/dist/_esm5.processed/core/api/debug/buffer_graph.d.ts +28 -0
  12. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +175 -0
  13. package/dist/_esm5.processed/core/api/debug/buffer_size_graph.d.ts +10 -0
  14. package/dist/_esm5.processed/core/api/debug/buffer_size_graph.js +104 -0
  15. package/dist/_esm5.processed/core/api/debug/constants.d.ts +2 -0
  16. package/dist/_esm5.processed/core/api/debug/constants.js +2 -0
  17. package/dist/_esm5.processed/core/api/debug/index.d.ts +2 -0
  18. package/dist/_esm5.processed/core/api/debug/index.js +2 -0
  19. package/dist/_esm5.processed/core/api/debug/modules/general_info.d.ts +3 -0
  20. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +180 -0
  21. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.d.ts +4 -0
  22. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +121 -0
  23. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.d.ts +3 -0
  24. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +35 -0
  25. package/dist/_esm5.processed/core/api/debug/render.d.ts +3 -0
  26. package/dist/_esm5.processed/core/api/debug/render.js +32 -0
  27. package/dist/_esm5.processed/core/api/debug/utils.d.ts +39 -0
  28. package/dist/_esm5.processed/core/api/debug/utils.js +57 -0
  29. package/dist/_esm5.processed/core/api/playback_observer.js +3 -2
  30. package/dist/_esm5.processed/core/api/public_api.d.ts +6 -2
  31. package/dist/_esm5.processed/core/api/public_api.js +50 -27
  32. package/dist/_esm5.processed/core/api/utils.js +3 -3
  33. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +27 -8
  34. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +28 -7
  35. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +1 -1
  36. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +1 -1
  37. package/dist/_esm5.processed/core/decrypt/find_key_system.js +29 -6
  38. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +35 -31
  39. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.js +4 -0
  40. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.d.ts +17 -8
  41. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +10 -6
  42. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +5 -4
  43. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +22 -5
  44. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +37 -21
  45. package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.js +21 -23
  46. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +17 -7
  47. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  48. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +27 -31
  49. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +2 -2
  50. package/dist/_esm5.processed/core/init/utils/create_media_source.js +3 -12
  51. package/dist/_esm5.processed/core/init/utils/end_of_stream.js +6 -3
  52. package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +2 -1
  53. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +9 -5
  54. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +2 -1
  55. package/dist/_esm5.processed/core/init/utils/media_duration_updater.js +24 -20
  56. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +1 -1
  57. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +6 -4
  58. package/dist/_esm5.processed/core/init/utils/throw_on_media_error.js +1 -1
  59. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +7 -10
  60. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +4 -2
  61. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +13 -9
  62. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +30 -16
  63. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +26 -12
  64. package/dist/_esm5.processed/core/stream/period/period_stream.js +11 -10
  65. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +15 -15
  66. package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +1 -1
  67. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +16 -6
  68. package/dist/_esm5.processed/core/stream/utils/create_reload_request.js +1 -1
  69. package/dist/_esm5.processed/default_config.d.ts +16 -0
  70. package/dist/_esm5.processed/default_config.js +19 -0
  71. package/dist/_esm5.processed/experimental/features/debug_element.d.ts +8 -0
  72. package/dist/_esm5.processed/experimental/features/debug_element.js +10 -0
  73. package/dist/_esm5.processed/experimental/features/index.d.ts +1 -0
  74. package/dist/_esm5.processed/experimental/features/index.js +1 -0
  75. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +7 -4
  76. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +8 -4
  77. package/dist/_esm5.processed/features/features_object.js +1 -0
  78. package/dist/_esm5.processed/features/initialize_features.js +13 -10
  79. package/dist/_esm5.processed/features/types.d.ts +3 -0
  80. package/dist/_esm5.processed/manifest/adaptation.js +4 -0
  81. package/dist/_esm5.processed/manifest/manifest.js +2 -0
  82. package/dist/_esm5.processed/manifest/representation.js +11 -4
  83. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +105 -137
  84. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +25 -5
  85. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +15 -11
  86. package/dist/_esm5.processed/transports/dash/low_latency_segment_loader.js +2 -2
  87. package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
  88. package/dist/_esm5.processed/transports/dash/segment_loader.js +4 -4
  89. package/dist/_esm5.processed/transports/local/segment_loader.js +13 -26
  90. package/dist/_esm5.processed/transports/smooth/segment_loader.js +4 -4
  91. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
  92. package/dist/_esm5.processed/utils/cancellable_sleep.js +4 -10
  93. package/dist/_esm5.processed/utils/create_cancellable_promise.d.ts +26 -0
  94. package/dist/_esm5.processed/utils/create_cancellable_promise.js +52 -0
  95. package/dist/_esm5.processed/utils/reference.js +6 -0
  96. package/dist/_esm5.processed/utils/request/xhr.js +1 -1
  97. package/dist/_esm5.processed/utils/task_canceller.d.ts +34 -15
  98. package/dist/_esm5.processed/utils/task_canceller.js +55 -22
  99. package/dist/rx-player.js +882 -661
  100. package/dist/rx-player.min.js +1 -1
  101. package/jest.config.js +1 -5
  102. package/package.json +17 -19
  103. package/scripts/build/constants.d.ts +1 -0
  104. package/scripts/fast_demo_build.js +38 -39
  105. package/sonar-project.properties +1 -1
  106. package/src/compat/browser_detection.ts +99 -52
  107. package/src/compat/can_reuse_media_keys.ts +5 -2
  108. package/src/compat/eme/close_session.ts +2 -2
  109. package/src/compat/event_listeners.ts +1 -1
  110. package/src/core/adaptive/adaptive_representation_selector.ts +4 -2
  111. package/src/core/api/debug/buffer_graph.ts +247 -0
  112. package/src/core/api/debug/buffer_size_graph.ts +130 -0
  113. package/src/core/api/debug/constants.ts +2 -0
  114. package/src/core/api/debug/index.ts +3 -0
  115. package/src/core/api/debug/modules/general_info.ts +184 -0
  116. package/src/core/api/debug/modules/segment_buffer_content.ts +155 -0
  117. package/src/core/api/debug/modules/segment_buffer_size.ts +48 -0
  118. package/src/core/api/debug/render.ts +40 -0
  119. package/src/core/api/debug/utils.ts +103 -0
  120. package/src/core/api/playback_observer.ts +4 -2
  121. package/src/core/api/public_api.ts +59 -31
  122. package/src/core/api/utils.ts +3 -3
  123. package/src/core/decrypt/__tests__/__global__/utils.ts +61 -40
  124. package/src/core/decrypt/attach_media_keys.ts +1 -1
  125. package/src/core/decrypt/content_decryptor.ts +1 -1
  126. package/src/core/decrypt/find_key_system.ts +25 -11
  127. package/src/core/decrypt/session_events_listener.ts +39 -38
  128. package/src/core/decrypt/utils/check_key_statuses.ts +6 -0
  129. package/src/core/fetchers/cdn_prioritizer.ts +18 -9
  130. package/src/core/fetchers/manifest/manifest_fetcher.ts +5 -4
  131. package/src/core/fetchers/segment/segment_fetcher.ts +36 -14
  132. package/src/core/fetchers/segment/task_prioritizer.ts +25 -30
  133. package/src/core/fetchers/utils/schedule_request.ts +18 -7
  134. package/src/core/init/directfile_content_initializer.ts +1 -1
  135. package/src/core/init/media_source_content_initializer.ts +37 -41
  136. package/src/core/init/utils/content_time_boundaries_observer.ts +2 -2
  137. package/src/core/init/utils/create_media_source.ts +4 -16
  138. package/src/core/init/utils/end_of_stream.ts +6 -3
  139. package/src/core/init/utils/get_loaded_reference.ts +2 -1
  140. package/src/core/init/utils/initial_seek_and_play.ts +9 -5
  141. package/src/core/init/utils/initialize_content_decryption.ts +2 -1
  142. package/src/core/init/utils/media_duration_updater.ts +26 -21
  143. package/src/core/init/utils/rebuffering_controller.ts +1 -1
  144. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +6 -4
  145. package/src/core/init/utils/throw_on_media_error.ts +1 -1
  146. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +7 -11
  147. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +4 -2
  148. package/src/core/segment_buffers/segment_buffers_store.ts +16 -13
  149. package/src/core/stream/adaptation/adaptation_stream.ts +33 -19
  150. package/src/core/stream/orchestrator/stream_orchestrator.ts +26 -12
  151. package/src/core/stream/period/period_stream.ts +11 -10
  152. package/src/core/stream/representation/representation_stream.ts +15 -15
  153. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +1 -1
  154. package/src/core/stream/representation/utils/downloading_queue.ts +16 -4
  155. package/src/core/stream/utils/create_reload_request.ts +1 -1
  156. package/src/default_config.ts +30 -9
  157. package/src/experimental/features/__tests__/debug_element.test.ts +26 -0
  158. package/src/experimental/features/debug_element.ts +13 -0
  159. package/src/experimental/features/index.ts +1 -0
  160. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +7 -4
  161. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +8 -4
  162. package/src/features/__tests__/initialize_features.test.ts +11 -0
  163. package/src/features/features_object.ts +1 -0
  164. package/src/features/initialize_features.ts +15 -10
  165. package/src/features/types.ts +9 -0
  166. package/src/manifest/adaptation.ts +7 -0
  167. package/src/manifest/manifest.ts +4 -0
  168. package/src/manifest/representation.ts +10 -4
  169. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +116 -151
  170. package/src/parsers/manifest/dash/common/parse_representations.ts +21 -4
  171. package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +31 -22
  172. package/src/transports/dash/low_latency_segment_loader.ts +2 -2
  173. package/src/transports/dash/manifest_parser.ts +1 -1
  174. package/src/transports/dash/segment_loader.ts +4 -4
  175. package/src/transports/local/segment_loader.ts +14 -30
  176. package/src/transports/smooth/segment_loader.ts +4 -4
  177. package/src/transports/utils/call_custom_manifest_loader.ts +3 -3
  178. package/src/typings/globals.d.ts +2 -0
  179. package/src/utils/cancellable_sleep.ts +5 -14
  180. package/src/utils/create_cancellable_promise.ts +69 -0
  181. package/src/utils/reference.ts +6 -0
  182. package/src/utils/request/xhr.ts +1 -1
  183. package/src/utils/task_canceller.ts +63 -34
  184. package/tsconfig.json +1 -1
  185. package/tsconfig.modules.json +1 -1
  186. package/locked_reps.js +0 -46
package/.eslintrc.js CHANGED
@@ -16,10 +16,18 @@ module.exports = {
16
16
  "plugins": [
17
17
  "eslint-plugin-import",
18
18
  "eslint-plugin-jsdoc",
19
+ "ban",
19
20
  "@typescript-eslint",
20
21
  "@typescript-eslint/tslint"
21
22
  ],
22
23
  "rules": {
24
+ "ban/ban": [
25
+ 2,
26
+ {
27
+ "name": ["*", "finally"],
28
+ "message": "Promise.prototype.finally is forbidden due to poor support from older devices.\nNote that this linting rule just bans naively all \"finally\" method calls, if in this case it wasn't called on a Promise, you can safely ignore this error",
29
+ }
30
+ ],
23
31
  "@typescript-eslint/adjacent-overload-signatures": "error",
24
32
  "@typescript-eslint/array-type": [
25
33
  "error",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # Changelog
2
2
 
3
+ ## v4.0.0-beta.1 (2023-03-08)
4
+
5
+ ### Bug fixes
6
+
7
+ - (v4.0.0-beta.0-only issue) Fix memory leak
8
+ - (v4.0.0-beta.0-only issue) Fix MediaSource duration when maxBufferedEnd is inferior to current duration but superior to calculated duration
9
+ - (v4.0.0-beta.0-only issue) Fix stopAtEnd option by also switching to STOPPED state on ended
10
+ - (v4.0.0-beta.0-only issue) Fix some target's support by not relying on Promise.prototype.finally anymore [#1224]
11
+ - (v4.0.0-beta.0-only issue) For dynamic contents, always set a very high duration [#1220]
12
+ - (v4.0.0-beta.0-only issue) DRM: Fix fallbacking for an already-played content by checking key statuses initially linked to a MediaKeySession
13
+
14
+ ### Other improvements
15
+
16
+ - Based on the v3.30.0 of which it inherits all the features, bug fixes and other improvments
17
+
18
+
19
+ ## v3.30.0 (2023-03-07)
20
+
21
+ ### Features
22
+
23
+ - Add `updateContentUrls` API, allowing to update the Manifest's URL during playback [#1182]
24
+ - DASH: implement forced-subtitles, adding the `forced` property to the audio tracks API and selecting by default a forced text track linked to the audio track's language if present [#1187]
25
+ - DRM: add the `getKeySystemConfiguration` method to the RxPlayer [#1202]
26
+ - add experimental `DEBUG_ELEMENT` feature and `createDebugElement` method to render a default debugging HTML element [#1200]
27
+
28
+ ### Deprecated
29
+
30
+ - Deprecate the `getVideoLoadedTime` method which can be easily replaced (see Deprecated method documentation)
31
+ - Deprecate the `getVideoPlayedTime` method which can be easily replaced (see Deprecated method documentation)
32
+ - Deprecate the `transportOptions.aggressiveMode` option
33
+ - DRM: Deprecate the `keySystems[].onKeyStatusesChange` callback as no good use case was found for it.
34
+
35
+ ### Bug fixes
36
+
37
+ - Fix segment requesting error when playing a DASH content without an url and without BaseURL elements [#1192]
38
+ - API: Stop sending events if the content is stopped due to a side-effect of one of the event handler [#1197]
39
+ - text-tracks/ttml: fix inconsistent line spacing when resizing the `textTrackElement` [#1191]
40
+ - DRM: Fix race condition leading to a JS error instead of a `NO_PLAYABLE_REPRESENTATION` [#1201]
41
+ - DRM/Compat: Renew MediaKeys at each `loadVideo` on all WebOS (LG TV) platforms to work around issues [#1188]
42
+
43
+ ### Other improvements
44
+
45
+ - DASH: better detect closed captions [#1187]
46
+ - DASH: handle `endNumber` DASH attribute [#1186]
47
+ - DASH: Do not merge AdaptationSet with role "main" anymore [#1214]
48
+ - DASH: parse `transferCharacteristics` property in the MPD to better detect hdr [#1212]
49
+ - Support encrypted contents on Panasonic 2019 TVs [#1226]
50
+ - Better handle SourceBuffer's QuotaExceededError, responsible for `MediaError` with the `BUFFER_FULL_ERROR` code [#1221]
51
+ - API: send available...TracksChange events in the very unlikely scenario where tracks are added after a manifest update [#1197]
52
+ - Completely remove RxJS dependency from the RxPlayer's source code [#1193]
53
+ - DRM: Request PR recommendation when PlayReady is asked and try default recommendation robustnesses [#1189]
54
+
55
+
3
56
  ## v4.0.0-beta.0 (2023-01-27)
4
57
 
5
58
  ### Changes
package/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.0-beta.0
1
+ 4.0.0-beta.1
@@ -13,17 +13,28 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- declare const isIE11: boolean;
17
- declare const isIEOrEdge: boolean;
18
- declare const isEdgeChromium: boolean;
19
- declare const isFirefox: boolean;
20
- declare const isSamsungBrowser: boolean;
21
- declare const isTizen: boolean;
22
- declare const isWebOs: boolean;
23
- declare const isWebOs2021: boolean;
24
- declare const isWebOs2022: boolean;
16
+ /** Edge Chromium, regardless of the device */
17
+ declare let isEdgeChromium: boolean;
18
+ /** IE11, regardless of the device */
19
+ declare let isIE11: boolean;
20
+ /** IE11 or Edge __Legacy__ (not Edge Chromium), regardless of the device */
21
+ declare let isIEOrEdge: boolean;
22
+ /** Firefox, regardless of the device */
23
+ declare let isFirefox: boolean;
25
24
  /** `true` on Safari on a PC platform (i.e. not iPhone / iPad etc.) */
26
- declare const isSafariDesktop: boolean;
25
+ declare let isSafariDesktop: boolean;
27
26
  /** `true` on Safari on an iPhone, iPad & iPod platform */
28
- declare const isSafariMobile: boolean;
29
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
27
+ declare let isSafariMobile: boolean;
28
+ /** Samsung's own browser application */
29
+ declare let isSamsungBrowser: boolean;
30
+ /** `true` on devices where Tizen is the OS (e.g. Samsung TVs). */
31
+ declare let isTizen: boolean;
32
+ /** `true` on devices where WebOS is the OS (e.g. LG TVs). */
33
+ declare let isWebOs: boolean;
34
+ /** `true` specifically for WebOS 2021 version. */
35
+ declare let isWebOs2021: boolean;
36
+ /** `true` specifically for WebOS 2022 version. */
37
+ declare let isWebOs2022: boolean;
38
+ /** `true` for Panasonic devices. */
39
+ declare let isPanasonic: boolean;
40
+ export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
@@ -13,44 +13,86 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- var _a, _b;
17
16
  import isNode from "./is_node";
18
- // true on IE11
19
- // false on Edge and other IEs/browsers.
20
- var isIE11 = !isNode &&
21
- typeof window.MSInputMethodContext !== "undefined" &&
22
- typeof document.documentMode !== "undefined";
23
- // true for IE / Edge
24
- var isIEOrEdge = isNode ?
25
- false :
26
- navigator.appName === "Microsoft Internet Explorer" ||
27
- navigator.appName === "Netscape" &&
28
- /(Trident|Edge)\//.test(navigator.userAgent);
29
- var isEdgeChromium = !isNode &&
30
- navigator.userAgent.toLowerCase().indexOf("edg/") !== -1;
31
- var isFirefox = !isNode &&
32
- navigator.userAgent.toLowerCase().indexOf("firefox") !== -1;
33
- var isSamsungBrowser = !isNode &&
34
- /SamsungBrowser/.test(navigator.userAgent);
35
- var isTizen = !isNode &&
36
- /Tizen/.test(navigator.userAgent);
37
- var isWebOs = !isNode &&
38
- navigator.userAgent.indexOf("Web0S") >= 0;
39
- // Inspired form: http://webostv.developer.lge.com/discover/specifications/web-engine/
40
- // Note: even that page doesn't correspond to what we've actually seen in the
41
- // wild
42
- var isWebOs2021 = isWebOs &&
43
- (/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent) ||
44
- /[Cc]hr[o0]me\/79/.test(navigator.userAgent));
45
- var isWebOs2022 = isWebOs &&
46
- (/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent) ||
47
- /[Cc]hr[o0]me\/87/.test(navigator.userAgent));
17
+ /** Edge Chromium, regardless of the device */
18
+ var isEdgeChromium = false;
19
+ /** IE11, regardless of the device */
20
+ var isIE11 = false;
21
+ /** IE11 or Edge __Legacy__ (not Edge Chromium), regardless of the device */
22
+ var isIEOrEdge = false;
23
+ /** Firefox, regardless of the device */
24
+ var isFirefox = false;
48
25
  /** `true` on Safari on a PC platform (i.e. not iPhone / iPad etc.) */
49
- var isSafariDesktop = !isNode && (Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") >= 0 ||
50
- ((_b = (_a = window.safari) === null || _a === void 0 ? void 0 : _a.pushNotification) === null || _b === void 0 ? void 0 : _b.toString()) ===
51
- "[object SafariRemoteNotification]");
26
+ var isSafariDesktop = false;
52
27
  /** `true` on Safari on an iPhone, iPad & iPod platform */
53
- var isSafariMobile = !isNode &&
54
- typeof navigator.platform === "string" &&
55
- /iPad|iPhone|iPod/.test(navigator.platform);
56
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
28
+ var isSafariMobile = false;
29
+ /** Samsung's own browser application */
30
+ var isSamsungBrowser = false;
31
+ /** `true` on devices where Tizen is the OS (e.g. Samsung TVs). */
32
+ var isTizen = false;
33
+ /** `true` on devices where WebOS is the OS (e.g. LG TVs). */
34
+ var isWebOs = false;
35
+ /** `true` specifically for WebOS 2021 version. */
36
+ var isWebOs2021 = false;
37
+ /** `true` specifically for WebOS 2022 version. */
38
+ var isWebOs2022 = false;
39
+ /** `true` for Panasonic devices. */
40
+ var isPanasonic = false;
41
+ ((function findCurrentBrowser() {
42
+ var _a, _b;
43
+ if (isNode) {
44
+ return;
45
+ }
46
+ // 1 - Find out browser between IE/Edge Legacy/Edge Chromium/Firefox/Safari
47
+ if (typeof window.MSInputMethodContext !== "undefined" &&
48
+ typeof document.documentMode !== "undefined") {
49
+ isIE11 = true;
50
+ isIEOrEdge = true;
51
+ }
52
+ else if (navigator.appName === "Microsoft Internet Explorer" ||
53
+ navigator.appName === "Netscape" &&
54
+ /(Trident|Edge)\//.test(navigator.userAgent)) {
55
+ isIEOrEdge = true;
56
+ }
57
+ else if (navigator.userAgent.toLowerCase().indexOf("edg/") !== -1) {
58
+ isEdgeChromium = true;
59
+ }
60
+ else if (navigator.userAgent.toLowerCase().indexOf("firefox") !== -1) {
61
+ isFirefox = true;
62
+ }
63
+ else if (typeof navigator.platform === "string" &&
64
+ /iPad|iPhone|iPod/.test(navigator.platform)) {
65
+ isSafariMobile = true;
66
+ }
67
+ else if (Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") >= 0 ||
68
+ ((_b = (_a = window.safari) === null || _a === void 0 ? void 0 : _a.pushNotification) === null || _b === void 0 ? void 0 : _b.toString()) ===
69
+ "[object SafariRemoteNotification]") {
70
+ isSafariDesktop = true;
71
+ }
72
+ // 2 - Find out specific device/platform information
73
+ // Samsung browser e.g. on Android
74
+ if (/SamsungBrowser/.test(navigator.userAgent)) {
75
+ isSamsungBrowser = true;
76
+ }
77
+ if (/Tizen/.test(navigator.userAgent)) {
78
+ isTizen = true;
79
+ // Inspired form: http://webostv.developer.lge.com/discover/specifications/web-engine/
80
+ // Note: even that page doesn't correspond to what we've actually seen in the
81
+ // wild
82
+ }
83
+ else if (/[Ww]eb[O0]S/.test(navigator.userAgent)) {
84
+ isWebOs = true;
85
+ if (/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent) ||
86
+ /[Cc]hr[o0]me\/87/.test(navigator.userAgent)) {
87
+ isWebOs2022 = true;
88
+ }
89
+ else if (/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent) ||
90
+ /[Cc]hr[o0]me\/79/.test(navigator.userAgent)) {
91
+ isWebOs2021 = true;
92
+ }
93
+ }
94
+ else if (/[Pp]anasonic/.test(navigator.userAgent)) {
95
+ isPanasonic = true;
96
+ }
97
+ })());
98
+ export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
@@ -1,4 +1,4 @@
1
- import { isWebOs } from "./browser_detection";
1
+ import { isPanasonic, isWebOs, } from "./browser_detection";
2
2
  /**
3
3
  * Returns `true` if a `MediaKeys` instance (the `Encrypted Media Extension`
4
4
  * concept) can be reused between contents.
@@ -12,5 +12,5 @@ import { isWebOs } from "./browser_detection";
12
12
  * @returns {boolean}
13
13
  */
14
14
  export default function canReuseMediaKeys() {
15
- return !isWebOs;
15
+ return !isWebOs && !isPanasonic;
16
16
  }
@@ -136,7 +136,7 @@ export default function closeSession(session) {
136
136
  return [3 /*break*/, 4];
137
137
  case 2:
138
138
  err_2 = _a.sent();
139
- if (timeoutCanceller.isUsed) { // Reminder: cancelled == session closed
139
+ if (timeoutCanceller.isUsed()) { // Reminder: cancelled == session closed
140
140
  return [2 /*return*/];
141
141
  }
142
142
  // The caught error can tell if session is closed
@@ -151,7 +151,7 @@ export default function closeSession(session) {
151
151
  _a.sent();
152
152
  return [3 /*break*/, 4];
153
153
  case 4:
154
- if (timeoutCanceller.isUsed) { // Reminder: cancelled == session closed
154
+ if (timeoutCanceller.isUsed()) { // Reminder: cancelled == session closed
155
155
  return [2 /*return*/];
156
156
  }
157
157
  throw new Error("Compat: Couldn't know if session is closed");
@@ -75,7 +75,7 @@ function createCompatibleEventListener(eventNames, prefixes) {
75
75
  var mem;
76
76
  var prefixedEvents = eventPrefixed(eventNames, prefixes);
77
77
  return function (element, listener, cancelSignal) {
78
- if (cancelSignal.isCancelled) {
78
+ if (cancelSignal.isCancelled()) {
79
79
  return;
80
80
  }
81
81
  // if the element is a HTMLElement we can detect
@@ -124,6 +124,8 @@ declare class ConfigHandler {
124
124
  SEGMENT_PRIORITIES_STEPS: number[];
125
125
  MAX_HIGH_PRIORITY_LEVEL: number;
126
126
  MIN_CANCELABLE_PRIORITY: number;
127
+ EME_DEFAULT_VIDEO_CODECS: string[];
128
+ EME_DEFAULT_AUDIO_CODECS: string[];
127
129
  EME_DEFAULT_WIDEVINE_ROBUSTNESSES: string[];
128
130
  EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES: string[];
129
131
  EME_KEY_SYSTEMS: Partial<Record<string, string[]>>;
@@ -124,7 +124,8 @@ function getEstimateReference(_a, stopAllEstimates) {
124
124
  * This TaskCanceller is used both for restarting estimates with a new
125
125
  * configuration and to cancel them altogether.
126
126
  */
127
- var currentEstimatesCanceller = new TaskCanceller({ cancelOn: stopAllEstimates });
127
+ var currentEstimatesCanceller = new TaskCanceller();
128
+ currentEstimatesCanceller.linkToSignal(stopAllEstimates);
128
129
  // Create `ISharedReference` on which estimates will be emitted.
129
130
  var estimateRef = createEstimateReference(representationsRef.getValue(), currentEstimatesCanceller.signal);
130
131
  representationsRef.onUpdate(restartEstimatesProductionFromCurrentConditions, { clearSignal: stopAllEstimates });
@@ -296,7 +297,8 @@ function getEstimateReference(_a, stopAllEstimates) {
296
297
  function restartEstimatesProductionFromCurrentConditions() {
297
298
  var representations = representationsRef.getValue();
298
299
  currentEstimatesCanceller.cancel();
299
- currentEstimatesCanceller = new TaskCanceller({ cancelOn: stopAllEstimates });
300
+ currentEstimatesCanceller = new TaskCanceller();
301
+ currentEstimatesCanceller.linkToSignal(stopAllEstimates);
300
302
  var newRef = createEstimateReference(representations, currentEstimatesCanceller.signal);
301
303
  newRef.onUpdate(function onNewEstimate(newEstimate) {
302
304
  estimateRef.setValue(newEstimate);
@@ -0,0 +1,28 @@
1
+ import { IBufferedChunk } from "../../segment_buffers";
2
+ export interface ISegmentBufferGrapUpdateData {
3
+ currentTime: number;
4
+ inventory: IBufferedChunk[];
5
+ width: number;
6
+ height: number;
7
+ minimumPosition: number | undefined;
8
+ maximumPosition: number | undefined;
9
+ }
10
+ export default class SegmentBufferGraph {
11
+ /** Link buffered Representation to their corresponding color. */
12
+ private readonly _colorMap;
13
+ /** Current amount of colors chosen to represent the various Representation. */
14
+ private _currNbColors;
15
+ /** Canvas that will contain the buffer graph itself. */
16
+ private readonly _canvasElt;
17
+ private readonly _canvasCtxt;
18
+ constructor(canvasElt: HTMLCanvasElement);
19
+ clear(): void;
20
+ update(data: ISegmentBufferGrapUpdateData): void;
21
+ /**
22
+ * Paint a given range in the canvas
23
+ * @param {Object} rangeScaled - Buffered segment information with added
24
+ * "scaling" information to know where it fits in the canvas.
25
+ */
26
+ private _paintRange;
27
+ private _getColorForRepresentation;
28
+ }
@@ -0,0 +1,175 @@
1
+ var BUFFER_WIDTH_IN_SECONDS = 10000;
2
+ var COLORS = [
3
+ "#2ab7ca",
4
+ "#fed766",
5
+ "#4dd248",
6
+ "#a22c28",
7
+ "#556b2f",
8
+ "#add8e6",
9
+ "#90ee90",
10
+ "#444444",
11
+ "#40bfc1",
12
+ "#57557e",
13
+ "#fbe555",
14
+ ];
15
+ var SegmentBufferGraph = /** @class */ (function () {
16
+ function SegmentBufferGraph(canvasElt) {
17
+ this._colorMap = new WeakMap();
18
+ this._currNbColors = 0;
19
+ this._canvasElt = canvasElt;
20
+ this._canvasCtxt = this._canvasElt.getContext("2d");
21
+ this.clear();
22
+ }
23
+ SegmentBufferGraph.prototype.clear = function () {
24
+ if (this._canvasCtxt !== null) {
25
+ this._canvasCtxt.clearRect(0, 0, this._canvasElt.width, this._canvasElt.height);
26
+ }
27
+ };
28
+ SegmentBufferGraph.prototype.update = function (data) {
29
+ var _a, _b, _c, _d;
30
+ if (this._canvasCtxt === null) {
31
+ return;
32
+ }
33
+ var inventory = data.inventory, currentTime = data.currentTime, width = data.width, height = data.height;
34
+ this._canvasElt.style.width = "".concat(width, "px");
35
+ this._canvasElt.style.height = "".concat(height, "px");
36
+ this._canvasElt.width = width;
37
+ this._canvasElt.height = height;
38
+ this.clear();
39
+ var minimumPoint;
40
+ if (data.minimumPosition !== undefined) {
41
+ if (inventory.length > 0) {
42
+ minimumPoint = Math.min(data.minimumPosition, inventory[0].start);
43
+ }
44
+ else {
45
+ minimumPoint = data.minimumPosition;
46
+ }
47
+ }
48
+ else {
49
+ minimumPoint = (_b = (_a = inventory[0]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
50
+ }
51
+ var maximumPoint;
52
+ if (data.maximumPosition !== undefined) {
53
+ if (inventory.length > 0) {
54
+ maximumPoint = Math.max(data.maximumPosition, inventory[inventory.length - 1].end);
55
+ }
56
+ else {
57
+ maximumPoint = data.maximumPosition;
58
+ }
59
+ }
60
+ else {
61
+ maximumPoint = (_d = (_c = inventory[inventory.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 1000;
62
+ }
63
+ minimumPoint = Math.min(currentTime, minimumPoint);
64
+ maximumPoint = Math.max(currentTime, maximumPoint);
65
+ var minimumPosition;
66
+ var maximumPosition;
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) {
73
+ maximumPosition = maximumPoint;
74
+ minimumPosition = maximumPoint - BUFFER_WIDTH_IN_SECONDS;
75
+ }
76
+ else if (currentTime - minimumPoint < BUFFER_WIDTH_IN_SECONDS / 2) {
77
+ minimumPosition = minimumPoint;
78
+ maximumPosition = minimumPoint + BUFFER_WIDTH_IN_SECONDS;
79
+ }
80
+ else {
81
+ minimumPosition = currentTime - BUFFER_WIDTH_IN_SECONDS / 2;
82
+ maximumPosition = currentTime + BUFFER_WIDTH_IN_SECONDS / 2;
83
+ }
84
+ }
85
+ else {
86
+ minimumPosition = minimumPoint;
87
+ maximumPosition = maximumPoint;
88
+ }
89
+ if (minimumPosition >= maximumPosition) {
90
+ this.clear();
91
+ return;
92
+ }
93
+ var currentRangesScaled = scaleSegments(inventory, minimumPosition, maximumPosition);
94
+ for (var i = 0; i < currentRangesScaled.length; i++) {
95
+ this._paintRange(currentRangesScaled[i], width, height);
96
+ }
97
+ if (currentTime !== undefined) {
98
+ paintCurrentPosition(currentTime, minimumPosition, maximumPosition, this._canvasCtxt, width, height);
99
+ }
100
+ };
101
+ /**
102
+ * Paint a given range in the canvas
103
+ * @param {Object} rangeScaled - Buffered segment information with added
104
+ * "scaling" information to know where it fits in the canvas.
105
+ */
106
+ SegmentBufferGraph.prototype._paintRange = function (rangeScaled, width, height) {
107
+ if (this._canvasCtxt === null) {
108
+ return;
109
+ }
110
+ var startX = rangeScaled.scaledStart * width;
111
+ var endX = rangeScaled.scaledEnd * width;
112
+ this._canvasCtxt.fillStyle = this._getColorForRepresentation(rangeScaled.info.infos.representation);
113
+ this._canvasCtxt.fillRect(Math.ceil(startX), 0, Math.ceil(endX - startX), height);
114
+ };
115
+ SegmentBufferGraph.prototype._getColorForRepresentation = function (representation) {
116
+ var color = this._colorMap.get(representation);
117
+ if (color !== undefined) {
118
+ return color;
119
+ }
120
+ var newColor = COLORS[this._currNbColors % COLORS.length];
121
+ this._currNbColors++;
122
+ this._colorMap.set(representation, newColor);
123
+ return newColor;
124
+ };
125
+ return SegmentBufferGraph;
126
+ }());
127
+ export default SegmentBufferGraph;
128
+ /**
129
+ * Represent the current position in the canvas.
130
+ * @param {number|undefined} position - The current position
131
+ * @param {number} minimumPosition - minimum possible position represented in
132
+ * the canvas.
133
+ * @param {number} maximumPosition - maximum possible position represented in
134
+ * the canvas.
135
+ * @param {Object} canvasCtx - The canvas' 2D context
136
+ */
137
+ function paintCurrentPosition(position, minimumPosition, maximumPosition, canvasCtx, width, height) {
138
+ if (typeof position === "number" &&
139
+ position >= minimumPosition &&
140
+ position < maximumPosition) {
141
+ var lengthCanvas = maximumPosition - minimumPosition;
142
+ canvasCtx.fillStyle = "#FF0000";
143
+ canvasCtx.fillRect(Math.ceil((position - minimumPosition) /
144
+ lengthCanvas * width) - 1, 5, 5, height);
145
+ }
146
+ }
147
+ /**
148
+ * Scale given bufferedData in terms of percentage between the minimum and
149
+ * maximum position. Filter out ranges which are not part of it.
150
+ * @param {Array.<Object>} bufferedData
151
+ * @param {number} minimumPosition
152
+ * @param {number} maximumPosition
153
+ * @returns {Array.<Object>}
154
+ */
155
+ function scaleSegments(bufferedData, minimumPosition, maximumPosition) {
156
+ var scaledSegments = [];
157
+ var wholeDuration = maximumPosition - minimumPosition;
158
+ for (var i = 0; i < bufferedData.length; i++) {
159
+ var info = bufferedData[i];
160
+ var start = info.bufferedStart === undefined ?
161
+ info.start :
162
+ info.bufferedStart;
163
+ var end = info.bufferedEnd === undefined ?
164
+ info.end :
165
+ info.bufferedEnd;
166
+ if (end > minimumPosition && start < maximumPosition) {
167
+ var startPoint = Math.max(start - minimumPosition, 0);
168
+ var endPoint = Math.min(end - minimumPosition, maximumPosition);
169
+ var scaledStart = startPoint / wholeDuration;
170
+ var scaledEnd = endPoint / wholeDuration;
171
+ scaledSegments.push({ scaledStart: scaledStart, scaledEnd: scaledEnd, info: info });
172
+ }
173
+ }
174
+ return scaledSegments;
175
+ }
@@ -0,0 +1,10 @@
1
+ export default class BufferSizeGraph {
2
+ private _history;
3
+ /** Canvas that will contain the buffer size graph itself. */
4
+ private readonly _canvasElt;
5
+ private readonly _canvasCtxt;
6
+ constructor(canvasElt: HTMLCanvasElement);
7
+ pushBufferSize(bufferSize: number): void;
8
+ clear(): void;
9
+ reRender(width: number, height: number): void;
10
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Maximum history of the buffer size that will be displayed, in milliseconds.
3
+ * For example, a value of `3000` indicates that we will just show at most the
4
+ * buffer size evolution during the last 3 seconds.
5
+ */
6
+ var TIME_SAMPLES_MS = 30000;
7
+ /**
8
+ * At minimum, that value will be taken in the chart as a maximum buffer size,
9
+ * in seconds.
10
+ * If samples go higher than this size, the chart will adapt automatically to
11
+ * a higher scale.
12
+ * However if values go below that value, the chart won't scale down more than
13
+ * this.
14
+ */
15
+ var MINIMUM_MAX_BUFFER_SIZE = 20;
16
+ var BufferSizeGraph = /** @class */ (function () {
17
+ function BufferSizeGraph(canvasElt) {
18
+ this._canvasElt = canvasElt;
19
+ this._canvasCtxt = this._canvasElt.getContext("2d");
20
+ this._history = [];
21
+ }
22
+ BufferSizeGraph.prototype.pushBufferSize = function (bufferSize) {
23
+ var now = performance.now();
24
+ this._history.push({ timestamp: now, bufferSize: bufferSize });
25
+ if (this._history.length > 0) {
26
+ var minimumTime = now - TIME_SAMPLES_MS;
27
+ var i = void 0;
28
+ for (i = this._history.length - 1; i >= 1; i--) {
29
+ if (this._history[i].timestamp <= minimumTime) {
30
+ break;
31
+ }
32
+ }
33
+ this._history = this._history.slice(i);
34
+ }
35
+ else {
36
+ this._history = [];
37
+ }
38
+ };
39
+ BufferSizeGraph.prototype.clear = function () {
40
+ if (this._canvasCtxt !== null) {
41
+ this._canvasCtxt.clearRect(0, 0, this._canvasElt.width, this._canvasElt.height);
42
+ }
43
+ };
44
+ BufferSizeGraph.prototype.reRender = function (width, height) {
45
+ this._canvasElt.style.width = "".concat(width, "px");
46
+ this._canvasElt.style.height = "".concat(height, "px");
47
+ this._canvasElt.width = width;
48
+ this._canvasElt.height = height;
49
+ this.clear();
50
+ var history = this._history;
51
+ var canvasCtx = this._canvasCtxt;
52
+ if (history.length === 0) {
53
+ return;
54
+ }
55
+ var currentMaxSize = getNewMaxBufferSize();
56
+ var minDate = history[0].timestamp;
57
+ var gridHeight = height / currentMaxSize;
58
+ var gridWidth = width / TIME_SAMPLES_MS;
59
+ drawData();
60
+ /**
61
+ * Get more appropriate maximum buffer size to put on top of the graph
62
+ * according to current history.
63
+ */
64
+ function getNewMaxBufferSize() {
65
+ var maxPoint = Math.max.apply(Math, history.map(function (d) { return d.bufferSize; }));
66
+ return Math.max(maxPoint + 5, MINIMUM_MAX_BUFFER_SIZE);
67
+ }
68
+ /**
69
+ * Draw all data contained in `history` in the canvas given.
70
+ */
71
+ function drawData() {
72
+ if (canvasCtx === null) {
73
+ return;
74
+ }
75
+ canvasCtx.beginPath();
76
+ canvasCtx.fillStyle = "rgb(200, 100, 200)";
77
+ for (var i = 1; i < history.length; i++) {
78
+ var diff = dateToX(history[i].timestamp) -
79
+ dateToX(history[i - 1].timestamp);
80
+ var y = height - bufferValueToHeight(history[i].bufferSize);
81
+ canvasCtx.fillRect(dateToX(history[i - 1].timestamp), y, diff, height);
82
+ }
83
+ canvasCtx.stroke();
84
+ }
85
+ /**
86
+ * Convert a value of a given data point, to a u coordinate in the canvas.
87
+ * @param {number} bufferVal - Value to convert
88
+ * @returns {number} - y coordinate
89
+ */
90
+ function bufferValueToHeight(bufferVal) {
91
+ return height - (currentMaxSize - bufferVal) * gridHeight;
92
+ }
93
+ /**
94
+ * Convert a date of a given data point, to a x coordinate in the canvas.
95
+ * @param {number} date - Date to convert, in milliseconds
96
+ * @returns {number} - x coordinate
97
+ */
98
+ function dateToX(date) {
99
+ return (date - minDate) * gridWidth;
100
+ }
101
+ };
102
+ return BufferSizeGraph;
103
+ }());
104
+ export default BufferSizeGraph;
@@ -0,0 +1,2 @@
1
+ /** Interval at which the various debug metrics will be refreshed. */
2
+ export declare const DEFAULT_REFRESH_INTERVAL = 1000;
@@ -0,0 +1,2 @@
1
+ /** Interval at which the various debug metrics will be refreshed. */
2
+ export var DEFAULT_REFRESH_INTERVAL = 1000;
@@ -0,0 +1,2 @@
1
+ import renderDebugElement from "./render";
2
+ export default renderDebugElement;
@@ -0,0 +1,2 @@
1
+ import renderDebugElement from "./render";
2
+ export default renderDebugElement;