rx-player 4.0.0-beta.0 → 4.0.0-beta.2
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.
- package/.eslintrc.js +8 -0
- package/CHANGELOG.md +93 -0
- package/CONTRIBUTING.md +48 -168
- package/FILES.md +40 -92
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/browser_detection.d.ts +25 -12
- package/dist/_esm5.processed/compat/browser_detection.js +85 -38
- package/dist/_esm5.processed/compat/can_reuse_media_keys.js +2 -2
- package/dist/_esm5.processed/compat/eme/close_session.js +2 -2
- package/dist/_esm5.processed/compat/eme/load_session.js +1 -1
- package/dist/_esm5.processed/compat/event_listeners.js +1 -1
- package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.d.ts +21 -0
- package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.js +26 -0
- package/dist/_esm5.processed/config.d.ts +4 -0
- package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +9 -6
- package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.d.ts +18 -1
- package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.js +106 -25
- package/dist/_esm5.processed/core/adaptive/guess_based_chooser.js +6 -6
- package/dist/_esm5.processed/core/adaptive/network_analyzer.js +8 -5
- package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.d.ts +19 -1
- package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.js +1 -1
- package/dist/_esm5.processed/core/api/debug/buffer_graph.d.ts +28 -0
- package/dist/_esm5.processed/core/api/debug/buffer_graph.js +175 -0
- package/dist/_esm5.processed/core/api/debug/buffer_size_graph.d.ts +10 -0
- package/dist/_esm5.processed/core/api/debug/buffer_size_graph.js +104 -0
- package/dist/_esm5.processed/core/api/debug/constants.d.ts +2 -0
- package/dist/_esm5.processed/core/api/debug/constants.js +2 -0
- package/dist/_esm5.processed/core/api/debug/index.d.ts +2 -0
- package/dist/_esm5.processed/core/api/debug/index.js +2 -0
- package/dist/_esm5.processed/core/api/debug/modules/general_info.d.ts +3 -0
- package/dist/_esm5.processed/core/api/debug/modules/general_info.js +180 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.d.ts +4 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +121 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.d.ts +3 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +35 -0
- package/dist/_esm5.processed/core/api/debug/render.d.ts +3 -0
- package/dist/_esm5.processed/core/api/debug/render.js +32 -0
- package/dist/_esm5.processed/core/api/debug/utils.d.ts +39 -0
- package/dist/_esm5.processed/core/api/debug/utils.js +57 -0
- package/dist/_esm5.processed/core/api/playback_observer.js +4 -2
- package/dist/_esm5.processed/core/api/public_api.d.ts +60 -3
- package/dist/_esm5.processed/core/api/public_api.js +280 -60
- package/dist/_esm5.processed/core/api/track_management/media_element_tracks_store.js +10 -1
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +13 -1
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +30 -15
- package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +3 -1
- package/dist/_esm5.processed/core/api/track_management/tracks_store.js +67 -152
- package/dist/_esm5.processed/core/api/utils.d.ts +10 -0
- package/dist/_esm5.processed/core/api/utils.js +23 -3
- package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +27 -8
- package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +28 -7
- package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +1 -1
- package/dist/_esm5.processed/core/decrypt/content_decryptor.js +1 -1
- package/dist/_esm5.processed/core/decrypt/find_key_system.js +29 -6
- package/dist/_esm5.processed/core/decrypt/session_events_listener.js +42 -32
- package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.js +4 -0
- package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +2 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +5 -1
- package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.d.ts +17 -8
- package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +10 -6
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +5 -4
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +22 -5
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +37 -21
- package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.js +21 -23
- package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +17 -7
- package/dist/_esm5.processed/core/init/directfile_content_initializer.js +2 -2
- package/dist/_esm5.processed/core/init/media_source_content_initializer.js +74 -41
- package/dist/_esm5.processed/core/init/types.d.ts +9 -1
- package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.d.ts +28 -1
- package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +24 -11
- package/dist/_esm5.processed/core/init/utils/create_media_source.js +3 -12
- package/dist/_esm5.processed/core/init/utils/end_of_stream.js +6 -3
- package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +2 -1
- package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +9 -5
- package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +2 -1
- package/dist/_esm5.processed/core/init/utils/media_source_duration_updater.d.ts +58 -0
- package/dist/_esm5.processed/core/init/utils/{media_duration_updater.js → media_source_duration_updater.js} +87 -86
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +36 -2
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +83 -3
- package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +6 -4
- package/dist/_esm5.processed/core/init/utils/throw_on_media_error.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +18 -7
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +38 -50
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +8 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +16 -2
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +8 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +12 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +11 -4
- package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +13 -9
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +30 -16
- package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.d.ts +47 -0
- package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.js +70 -0
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +41 -20
- package/dist/_esm5.processed/core/stream/period/period_stream.js +12 -11
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +37 -28
- package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.d.ts +4 -2
- package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +16 -6
- package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.d.ts +3 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +8 -8
- package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.d.ts +2 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +2 -3
- package/dist/_esm5.processed/core/stream/utils/create_reload_request.js +1 -1
- package/dist/_esm5.processed/default_config.d.ts +41 -0
- package/dist/_esm5.processed/default_config.js +46 -2
- package/dist/_esm5.processed/errors/index.d.ts +2 -2
- package/dist/_esm5.processed/errors/media_error.d.ts +23 -1
- package/dist/_esm5.processed/errors/media_error.js +18 -5
- package/dist/_esm5.processed/experimental/features/debug_element.d.ts +8 -0
- package/dist/_esm5.processed/experimental/features/debug_element.js +10 -0
- package/dist/_esm5.processed/experimental/features/index.d.ts +1 -0
- package/dist/_esm5.processed/experimental/features/index.js +1 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +1 -1
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +8 -7
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +7 -4
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +24 -12
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/index.js +0 -2
- package/dist/_esm5.processed/features/features_object.js +1 -0
- package/dist/_esm5.processed/features/initialize_features.js +13 -10
- package/dist/_esm5.processed/features/types.d.ts +3 -0
- package/dist/_esm5.processed/manifest/adaptation.d.ts +21 -2
- package/dist/_esm5.processed/manifest/adaptation.js +80 -1
- package/dist/_esm5.processed/manifest/manifest.js +2 -0
- package/dist/_esm5.processed/manifest/period.js +2 -2
- package/dist/_esm5.processed/manifest/representation.d.ts +33 -2
- package/dist/_esm5.processed/manifest/representation.js +32 -4
- package/dist/_esm5.processed/manifest/utils.js +1 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +105 -137
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +25 -5
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -0
- package/dist/_esm5.processed/public_types.d.ts +13 -3
- package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +1 -1
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +15 -11
- package/dist/_esm5.processed/transports/dash/low_latency_segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
- package/dist/_esm5.processed/transports/dash/segment_loader.js +4 -4
- package/dist/_esm5.processed/transports/local/segment_loader.js +13 -26
- package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.d.ts +4 -6
- package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.js +4 -6
- package/dist/_esm5.processed/transports/smooth/segment_loader.js +4 -4
- package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
- package/dist/_esm5.processed/utils/cancellable_sleep.js +4 -10
- package/dist/_esm5.processed/utils/create_cancellable_promise.d.ts +26 -0
- package/dist/_esm5.processed/utils/create_cancellable_promise.js +52 -0
- package/dist/_esm5.processed/utils/is_null_or_undefined.d.ts +1 -1
- package/dist/_esm5.processed/utils/is_null_or_undefined.js +1 -1
- package/dist/_esm5.processed/utils/reference.js +6 -0
- package/dist/_esm5.processed/utils/request/xhr.js +1 -1
- package/dist/_esm5.processed/utils/task_canceller.d.ts +34 -15
- package/dist/_esm5.processed/utils/task_canceller.js +55 -22
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +5424 -4712
- package/dist/rx-player.min.js +1 -1
- package/jest.config.js +1 -5
- package/package.json +44 -40
- package/scripts/build/constants.d.ts +1 -0
- package/scripts/build/generate_build.js +1 -1
- package/scripts/fast_demo_build.js +40 -40
- package/scripts/generate_full_demo.js +1 -1
- package/sonar-project.properties +1 -1
- package/src/compat/browser_detection.ts +105 -52
- package/src/compat/can_reuse_media_keys.ts +5 -2
- package/src/compat/eme/close_session.ts +2 -2
- package/src/compat/eme/load_session.ts +1 -1
- package/src/compat/event_listeners.ts +1 -1
- package/src/compat/has_issues_with_high_media_source_duration.ts +27 -0
- package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +147 -48
- package/src/core/adaptive/adaptive_representation_selector.ts +11 -6
- package/src/core/adaptive/buffer_based_chooser.ts +144 -26
- package/src/core/adaptive/guess_based_chooser.ts +9 -8
- package/src/core/adaptive/network_analyzer.ts +9 -4
- package/src/core/adaptive/utils/representation_score_calculator.ts +22 -2
- package/src/core/api/debug/buffer_graph.ts +247 -0
- package/src/core/api/debug/buffer_size_graph.ts +130 -0
- package/src/core/api/debug/constants.ts +2 -0
- package/src/core/api/debug/index.ts +3 -0
- package/src/core/api/debug/modules/general_info.ts +184 -0
- package/src/core/api/debug/modules/segment_buffer_content.ts +155 -0
- package/src/core/api/debug/modules/segment_buffer_size.ts +48 -0
- package/src/core/api/debug/render.ts +40 -0
- package/src/core/api/debug/utils.ts +103 -0
- package/src/core/api/playback_observer.ts +5 -2
- package/src/core/api/public_api.ts +334 -73
- package/src/core/api/track_management/media_element_tracks_store.ts +17 -8
- package/src/core/api/track_management/track_dispatcher.ts +37 -14
- package/src/core/api/track_management/tracks_store.ts +77 -167
- package/src/core/api/utils.ts +29 -3
- package/src/core/decrypt/__tests__/__global__/utils.ts +61 -40
- package/src/core/decrypt/attach_media_keys.ts +1 -1
- package/src/core/decrypt/content_decryptor.ts +1 -1
- package/src/core/decrypt/find_key_system.ts +25 -11
- package/src/core/decrypt/session_events_listener.ts +45 -39
- package/src/core/decrypt/utils/check_key_statuses.ts +6 -0
- package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +2 -1
- package/src/core/decrypt/utils/loaded_sessions_store.ts +8 -1
- package/src/core/fetchers/cdn_prioritizer.ts +18 -9
- package/src/core/fetchers/manifest/manifest_fetcher.ts +5 -4
- package/src/core/fetchers/segment/segment_fetcher.ts +36 -14
- package/src/core/fetchers/segment/task_prioritizer.ts +25 -30
- package/src/core/fetchers/utils/schedule_request.ts +18 -7
- package/src/core/init/directfile_content_initializer.ts +2 -1
- package/src/core/init/media_source_content_initializer.ts +89 -50
- package/src/core/init/types.ts +9 -1
- package/src/core/init/utils/content_time_boundaries_observer.ts +48 -12
- package/src/core/init/utils/create_media_source.ts +4 -16
- package/src/core/init/utils/end_of_stream.ts +6 -3
- package/src/core/init/utils/get_loaded_reference.ts +2 -1
- package/src/core/init/utils/initial_seek_and_play.ts +9 -5
- package/src/core/init/utils/initialize_content_decryption.ts +2 -1
- package/src/core/init/utils/{media_duration_updater.ts → media_source_duration_updater.ts} +103 -110
- package/src/core/init/utils/rebuffering_controller.ts +115 -4
- package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +6 -4
- package/src/core/init/utils/throw_on_media_error.ts +1 -1
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +63 -66
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +20 -2
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +16 -0
- package/src/core/segment_buffers/implementations/types.ts +16 -4
- package/src/core/segment_buffers/index.ts +2 -0
- package/src/core/segment_buffers/segment_buffers_store.ts +16 -13
- package/src/core/stream/adaptation/adaptation_stream.ts +33 -19
- package/src/core/stream/adaptation/utils/create_representation_estimator.ts +114 -0
- package/src/core/stream/orchestrator/stream_orchestrator.ts +42 -20
- package/src/core/stream/period/period_stream.ts +13 -11
- package/src/core/stream/representation/representation_stream.ts +49 -37
- package/src/core/stream/representation/utils/append_segment_to_buffer.ts +9 -4
- package/src/core/stream/representation/utils/downloading_queue.ts +16 -4
- package/src/core/stream/representation/utils/push_init_segment.ts +11 -6
- package/src/core/stream/representation/utils/push_media_segment.ts +3 -3
- package/src/core/stream/utils/create_reload_request.ts +1 -1
- package/src/default_config.ts +59 -11
- package/src/errors/__tests__/media_error.test.ts +6 -6
- package/src/errors/index.ts +4 -1
- package/src/errors/media_error.ts +67 -1
- package/src/experimental/features/__tests__/debug_element.test.ts +26 -0
- package/src/experimental/features/debug_element.ts +13 -0
- package/src/experimental/features/index.ts +1 -0
- package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +10 -7
- package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +7 -4
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +25 -10
- package/src/experimental/tools/mediaCapabilitiesProber/index.ts +0 -4
- package/src/features/__tests__/initialize_features.test.ts +11 -0
- package/src/features/features_object.ts +1 -0
- package/src/features/initialize_features.ts +15 -10
- package/src/features/types.ts +9 -0
- package/src/manifest/__tests__/manifest.test.ts +7 -7
- package/src/manifest/__tests__/period.test.ts +90 -45
- package/src/manifest/adaptation.ts +96 -1
- package/src/manifest/manifest.ts +4 -0
- package/src/manifest/period.ts +4 -2
- package/src/manifest/representation.ts +77 -5
- package/src/manifest/utils.ts +1 -3
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +116 -151
- package/src/parsers/manifest/dash/common/parse_representations.ts +21 -4
- package/src/parsers/manifest/dash/js-parser/parse_from_document.ts +1 -1
- package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -0
- package/src/parsers/texttracks/ttml/parse_ttml.ts +1 -1
- package/src/public_types.ts +16 -1
- package/src/tools/TextTrackRenderer/text_track_renderer.ts +1 -1
- package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +31 -22
- package/src/transports/dash/low_latency_segment_loader.ts +2 -2
- package/src/transports/dash/manifest_parser.ts +1 -1
- package/src/transports/dash/segment_loader.ts +4 -4
- package/src/transports/local/segment_loader.ts +14 -30
- package/src/transports/smooth/isobmff/create_boxes.ts +4 -6
- package/src/transports/smooth/segment_loader.ts +4 -4
- package/src/transports/utils/call_custom_manifest_loader.ts +3 -3
- package/src/typings/globals.d.ts +21 -19
- package/src/utils/cancellable_sleep.ts +5 -14
- package/src/utils/create_cancellable_promise.ts +69 -0
- package/src/utils/is_null_or_undefined.ts +1 -1
- package/src/utils/reference.ts +6 -0
- package/src/utils/request/xhr.ts +1 -1
- package/src/utils/task_canceller.ts +63 -34
- package/tsconfig.json +1 -1
- package/tsconfig.modules.json +1 -1
- package/dist/_esm5.processed/core/init/utils/media_duration_updater.d.ts +0 -56
- package/locked_reps.js +0 -46
- package/scripts/doc-generator/construct_table_of_contents.js +0 -76
- package/scripts/doc-generator/convert_MD_to_HMTL.js +0 -26
- package/scripts/doc-generator/create_documentation.js +0 -331
- package/scripts/doc-generator/create_documentation_page.js +0 -209
- package/scripts/doc-generator/create_page.js +0 -210
- package/scripts/doc-generator/generate_header_html.js +0 -147
- package/scripts/doc-generator/generate_page_html.js +0 -115
- package/scripts/doc-generator/generate_page_list_html.js +0 -92
- package/scripts/doc-generator/generate_sidebar_html.js +0 -85
- package/scripts/doc-generator/get_search_data_for_content.js +0 -137
- package/scripts/doc-generator/index.js +0 -34
- package/scripts/doc-generator/parse_doc_configs.js +0 -327
- package/scripts/doc-generator/scripts/lunr.js +0 -10
- package/scripts/doc-generator/scripts/script.js +0 -451
- package/scripts/doc-generator/styles/code.css +0 -99
- package/scripts/doc-generator/styles/style.css +0 -835
- package/scripts/doc-generator/utils.js +0 -74
|
@@ -13,7 +13,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
-
import { MediaError } from "../../../errors";
|
|
17
16
|
import EventEmitter from "../../../utils/event_emitter";
|
|
18
17
|
import createSharedReference from "../../../utils/reference";
|
|
19
18
|
import TaskCanceller from "../../../utils/task_canceller";
|
|
@@ -31,36 +30,49 @@ var TrackDispatcher = /** @class */ (function (_super) {
|
|
|
31
30
|
* synchronously.
|
|
32
31
|
* @param {Object} manifest
|
|
33
32
|
* @param {Object} adaptationRef
|
|
34
|
-
* @param {Object|null} initialTrackInfo
|
|
35
33
|
*/
|
|
36
|
-
function TrackDispatcher(manifest, adaptationRef
|
|
34
|
+
function TrackDispatcher(manifest, adaptationRef) {
|
|
37
35
|
var _this = _super.call(this) || this;
|
|
38
36
|
_this._canceller = new TaskCanceller();
|
|
39
37
|
_this._manifest = manifest;
|
|
40
38
|
_this._adaptationRef = adaptationRef;
|
|
39
|
+
_this._updateToken = false;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @param {Object|null} initialTrackInfo
|
|
44
|
+
*/
|
|
45
|
+
TrackDispatcher.prototype.start = function (initialTrackInfo) {
|
|
46
|
+
this._updateToken = true;
|
|
41
47
|
if (initialTrackInfo === null) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
this._lastEmitted = null;
|
|
49
|
+
this._updateToken = false;
|
|
50
|
+
this._adaptationRef.setValue(null);
|
|
51
|
+
return;
|
|
45
52
|
}
|
|
46
|
-
var reference =
|
|
47
|
-
|
|
53
|
+
var reference = this._constructLockedRepresentationsReference(initialTrackInfo);
|
|
54
|
+
if (!this._updateToken) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this._lastEmitted = { adaptation: initialTrackInfo.adaptation,
|
|
48
58
|
switchingMode: initialTrackInfo.switchingMode,
|
|
49
59
|
lockedRepresentations: null };
|
|
50
|
-
|
|
60
|
+
this._updateToken = false;
|
|
61
|
+
this._adaptationRef.setValue({ adaptation: initialTrackInfo.adaptation,
|
|
51
62
|
switchingMode: initialTrackInfo.switchingMode,
|
|
52
63
|
representations: reference });
|
|
53
|
-
|
|
54
|
-
}
|
|
64
|
+
};
|
|
55
65
|
/**
|
|
56
66
|
* Update the wanted track on the Reference linked to this `TrackDispatcher`.
|
|
57
67
|
* @param {Object|null} newTrackInfo
|
|
58
68
|
*/
|
|
59
69
|
TrackDispatcher.prototype.updateTrack = function (newTrackInfo) {
|
|
70
|
+
this._updateToken = true;
|
|
60
71
|
if (newTrackInfo === null) {
|
|
61
72
|
if (this._lastEmitted === null) {
|
|
62
73
|
return;
|
|
63
74
|
}
|
|
75
|
+
this._updateToken = false;
|
|
64
76
|
this._canceller.cancel();
|
|
65
77
|
// has no point but let's still create one for simplicity sake
|
|
66
78
|
this._canceller = new TaskCanceller();
|
|
@@ -72,7 +84,11 @@ var TrackDispatcher = /** @class */ (function (_super) {
|
|
|
72
84
|
this._canceller.cancel();
|
|
73
85
|
this._canceller = new TaskCanceller();
|
|
74
86
|
var reference = this._constructLockedRepresentationsReference(newTrackInfo);
|
|
87
|
+
if (!this._updateToken) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
75
90
|
this._lastEmitted = { adaptation: adaptation, switchingMode: switchingMode, lockedRepresentations: null };
|
|
91
|
+
this._updateToken = false;
|
|
76
92
|
this._adaptationRef.setValue({ adaptation: adaptation, switchingMode: switchingMode, representations: reference });
|
|
77
93
|
};
|
|
78
94
|
/**
|
|
@@ -120,10 +136,9 @@ var TrackDispatcher = /** @class */ (function (_super) {
|
|
|
120
136
|
}
|
|
121
137
|
}
|
|
122
138
|
if (playableRepresentations.length <= 0) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
throw noRepErr;
|
|
139
|
+
trackInfo.adaptation.isSupported = false;
|
|
140
|
+
self.trigger("noPlayableRepresentation", null);
|
|
141
|
+
return;
|
|
127
142
|
}
|
|
128
143
|
// Check if Locked Representations have changed
|
|
129
144
|
var oldRef = reference.getValue();
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import Manifest, { Adaptation, Period } from "../../../manifest";
|
|
17
|
-
import { IAudioRepresentationsSwitchingMode, IAudioTrack, IAudioTrackSwitchingMode, ITrackUpdateEventPayload, IAvailableAudioTrack, IAvailableTextTrack, IAvailableVideoTrack, IBrokenRepresentationsLockContext, IPeriod, ITextTrack, IVideoRepresentationsSwitchingMode, IVideoTrack, IVideoTrackSwitchingMode } from "../../../public_types";
|
|
17
|
+
import { IAudioRepresentationsSwitchingMode, IAudioTrack, IAudioTrackSwitchingMode, ITrackUpdateEventPayload, IAvailableAudioTrack, IAvailableTextTrack, IAvailableVideoTrack, IBrokenRepresentationsLockContext, IPeriod, ITextTrack, IVideoRepresentationsSwitchingMode, IVideoTrack, IVideoTrackSwitchingMode, IPlayerError } from "../../../public_types";
|
|
18
18
|
import EventEmitter from "../../../utils/event_emitter";
|
|
19
19
|
import { ISharedReference } from "../../../utils/reference";
|
|
20
20
|
import { IAdaptationChoice, IRepresentationsChoice } from "../../stream";
|
|
@@ -394,6 +394,8 @@ interface ITracksStoreEvents {
|
|
|
394
394
|
newAvailablePeriods: IPeriod[];
|
|
395
395
|
brokenRepresentationsLock: IBrokenRepresentationsLockContext;
|
|
396
396
|
trackUpdate: ITrackUpdateEventPayload;
|
|
397
|
+
error: unknown;
|
|
398
|
+
warning: IPlayerError;
|
|
397
399
|
}
|
|
398
400
|
export interface IAudioRepresentationsLockSettings {
|
|
399
401
|
representations: string[];
|
|
@@ -33,12 +33,14 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
33
33
|
* switching for an easier API management.
|
|
34
34
|
*/
|
|
35
35
|
import config from "../../../config";
|
|
36
|
+
import { MediaError } from "../../../errors";
|
|
36
37
|
import log from "../../../log";
|
|
37
38
|
import arrayFind from "../../../utils/array_find";
|
|
38
39
|
import assert from "../../../utils/assert";
|
|
39
40
|
import EventEmitter from "../../../utils/event_emitter";
|
|
41
|
+
import isNullOrUndefined from "../../../utils/is_null_or_undefined";
|
|
42
|
+
import objectAssign from "../../../utils/object_assign";
|
|
40
43
|
import createSharedReference from "../../../utils/reference";
|
|
41
|
-
import takeFirstSet from "../../../utils/take_first_set";
|
|
42
44
|
import TrackDispatcher from "./track_dispatcher";
|
|
43
45
|
/**
|
|
44
46
|
* Class helping with the management of the audio, video and text tracks and
|
|
@@ -115,7 +117,7 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
115
117
|
var stillHere = textAdaptations
|
|
116
118
|
.some(function (a) { return a.id === curWantedTextTrack_1.adaptation.id; });
|
|
117
119
|
if (!stillHere) {
|
|
118
|
-
log.warn("
|
|
120
|
+
log.warn("TS: Chosen text Adaptation not available anymore");
|
|
119
121
|
var periodInfo = this_1._storedPeriodInfo[i];
|
|
120
122
|
periodInfo.text.storedSettings = null;
|
|
121
123
|
this_1.trigger("trackUpdate", { period: toExposedPeriod(newPeriod),
|
|
@@ -138,7 +140,7 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
138
140
|
var stillHere = videoAdaptations
|
|
139
141
|
.some(function (a) { return a.id === curWantedVideoTrack_1.adaptation.id; });
|
|
140
142
|
if (!stillHere) {
|
|
141
|
-
log.warn("
|
|
143
|
+
log.warn("TS: Chosen video Adaptation not available anymore");
|
|
142
144
|
var periodItem = this_1._storedPeriodInfo[i];
|
|
143
145
|
var storedSettings = void 0;
|
|
144
146
|
if (videoAdaptations.length === 0) {
|
|
@@ -172,7 +174,7 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
172
174
|
var stillHere = audioAdaptations
|
|
173
175
|
.some(function (a) { return a.id === curWantedAudioTrack_1.adaptation.id; });
|
|
174
176
|
if (!stillHere) {
|
|
175
|
-
log.warn("
|
|
177
|
+
log.warn("TS: Chosen audio Adaptation not available anymore");
|
|
176
178
|
var periodItem = this_1._storedPeriodInfo[i];
|
|
177
179
|
var storedSettings = audioAdaptations.length === 0 ?
|
|
178
180
|
null :
|
|
@@ -262,20 +264,58 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
262
264
|
end: period.end }]);
|
|
263
265
|
}
|
|
264
266
|
if (periodObj[bufferType].dispatcher !== null) {
|
|
265
|
-
log.error("
|
|
267
|
+
log.error("TS: Subject already added for ".concat(bufferType, " ") +
|
|
266
268
|
"and Period ".concat(period.start));
|
|
267
269
|
return;
|
|
268
270
|
}
|
|
269
271
|
var trackSetting = periodObj[bufferType].storedSettings;
|
|
270
|
-
var dispatcher = new TrackDispatcher(manifest, adaptationRef
|
|
272
|
+
var dispatcher = new TrackDispatcher(manifest, adaptationRef);
|
|
271
273
|
periodObj[bufferType].dispatcher = dispatcher;
|
|
274
|
+
dispatcher.addEventListener("noPlayableRepresentation", function () {
|
|
275
|
+
var _a, _b, _c;
|
|
276
|
+
var nextAdaptation = arrayFind(period.getAdaptationsForType(bufferType), function (a) {
|
|
277
|
+
var playableRepresentations = a.getPlayableRepresentations();
|
|
278
|
+
return playableRepresentations.length > 0;
|
|
279
|
+
});
|
|
280
|
+
if (nextAdaptation === undefined) {
|
|
281
|
+
var noRepErr = new MediaError("NO_PLAYABLE_REPRESENTATION", "No ".concat(bufferType, " Representation can be played"), { adaptation: undefined });
|
|
282
|
+
_this.trigger("error", noRepErr);
|
|
283
|
+
_this.dispose();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
var typeInfo = (_a = getPeriodItem(_this._storedPeriodInfo, period.id)) === null || _a === void 0 ? void 0 : _a[bufferType];
|
|
287
|
+
if (isNullOrUndefined(typeInfo)) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
var switchingMode = bufferType === "audio" ?
|
|
291
|
+
_this._defaultAudioTrackSwitchingMode :
|
|
292
|
+
"reload";
|
|
293
|
+
var storedSettings = { adaptation: nextAdaptation, switchingMode: switchingMode, lockedRepresentations: createSharedReference(null) };
|
|
294
|
+
typeInfo.storedSettings = storedSettings;
|
|
295
|
+
_this.trigger("trackUpdate", { period: toExposedPeriod(period),
|
|
296
|
+
trackType: bufferType,
|
|
297
|
+
reason: "no-playable-representation" });
|
|
298
|
+
// The previous event trigger could have had side-effects, so we
|
|
299
|
+
// re-check if we're still mostly in the same state
|
|
300
|
+
if (_this._isDisposed) {
|
|
301
|
+
return; // Someone disposed the `TracksStore` on the previous side-effect
|
|
302
|
+
}
|
|
303
|
+
typeInfo = (_b = getPeriodItem(_this._storedPeriodInfo, period.id)) === null || _b === void 0 ? void 0 : _b[bufferType];
|
|
304
|
+
if (isNullOrUndefined(typeInfo) || typeInfo.storedSettings !== storedSettings) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
(_c = typeInfo.dispatcher) === null || _c === void 0 ? void 0 : _c.updateTrack(storedSettings);
|
|
308
|
+
});
|
|
272
309
|
dispatcher.addEventListener("noPlayableLockedRepresentation", function () {
|
|
310
|
+
// TODO check that it doesn't already lead to segment loading or MediaSource
|
|
311
|
+
// reloading
|
|
273
312
|
trackSetting === null || trackSetting === void 0 ? void 0 : trackSetting.lockedRepresentations.setValue(null);
|
|
274
313
|
_this.trigger("brokenRepresentationsLock", { period: { id: period.id,
|
|
275
314
|
start: period.start,
|
|
276
315
|
end: period.end },
|
|
277
316
|
trackType: bufferType });
|
|
278
317
|
});
|
|
318
|
+
dispatcher.start(trackSetting);
|
|
279
319
|
};
|
|
280
320
|
/**
|
|
281
321
|
* Remove shared reference to choose an "audio", "video" or "text" Adaptation
|
|
@@ -286,13 +326,13 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
286
326
|
TracksStore.prototype.removeTrackReference = function (bufferType, period) {
|
|
287
327
|
var periodIndex = findPeriodIndex(this._storedPeriodInfo, period);
|
|
288
328
|
if (periodIndex === undefined) {
|
|
289
|
-
log.warn("
|
|
329
|
+
log.warn("TS: ".concat(bufferType, " not found for period"), period.start);
|
|
290
330
|
return;
|
|
291
331
|
}
|
|
292
332
|
var periodObj = this._storedPeriodInfo[periodIndex];
|
|
293
333
|
var choiceItem = periodObj[bufferType];
|
|
294
334
|
if ((choiceItem === null || choiceItem === void 0 ? void 0 : choiceItem.dispatcher) === null) {
|
|
295
|
-
log.warn("
|
|
335
|
+
log.warn("TS: TrackDispatcher already removed for ".concat(bufferType, " ") +
|
|
296
336
|
"and Period ".concat(period.start));
|
|
297
337
|
return;
|
|
298
338
|
}
|
|
@@ -564,7 +604,7 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
564
604
|
TracksStore.prototype.getChosenAudioTrack = function (periodObj) {
|
|
565
605
|
return periodObj.audio.storedSettings === null ?
|
|
566
606
|
null :
|
|
567
|
-
|
|
607
|
+
periodObj.audio.storedSettings.adaptation.toAudioTrack(true);
|
|
568
608
|
};
|
|
569
609
|
/**
|
|
570
610
|
* Returns an object describing the chosen text track for the given text
|
|
@@ -579,7 +619,7 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
579
619
|
TracksStore.prototype.getChosenTextTrack = function (periodObj) {
|
|
580
620
|
return periodObj.text.storedSettings === null ?
|
|
581
621
|
null :
|
|
582
|
-
|
|
622
|
+
periodObj.text.storedSettings.adaptation.toTextTrack();
|
|
583
623
|
};
|
|
584
624
|
/**
|
|
585
625
|
* Returns an object describing the chosen video track for the given video
|
|
@@ -595,7 +635,7 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
595
635
|
if (periodObj.video.storedSettings === null) {
|
|
596
636
|
return null;
|
|
597
637
|
}
|
|
598
|
-
return
|
|
638
|
+
return periodObj.video.storedSettings.adaptation.toVideoTrack(true);
|
|
599
639
|
};
|
|
600
640
|
/**
|
|
601
641
|
* Returns all available audio tracks for a given Period, as an array of
|
|
@@ -613,21 +653,9 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
613
653
|
null;
|
|
614
654
|
return periodObj.period.getSupportedAdaptations("audio")
|
|
615
655
|
.map(function (adaptation) {
|
|
616
|
-
var
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
audioDescription: adaptation.isAudioDescription === true,
|
|
620
|
-
id: adaptation.id,
|
|
621
|
-
active: currentId === null ? false :
|
|
622
|
-
currentId === adaptation.id,
|
|
623
|
-
representations: adaptation.getPlayableRepresentations()
|
|
624
|
-
.map(parseAudioRepresentation),
|
|
625
|
-
label: adaptation.label,
|
|
626
|
-
};
|
|
627
|
-
if (adaptation.isDub === true) {
|
|
628
|
-
formatted.dub = true;
|
|
629
|
-
}
|
|
630
|
-
return formatted;
|
|
656
|
+
var active = currentId === null ? false :
|
|
657
|
+
currentId === adaptation.id;
|
|
658
|
+
return objectAssign(adaptation.toAudioTrack(true), { active: active });
|
|
631
659
|
});
|
|
632
660
|
};
|
|
633
661
|
/**
|
|
@@ -646,19 +674,9 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
646
674
|
null;
|
|
647
675
|
return periodObj.period.getSupportedAdaptations("text")
|
|
648
676
|
.map(function (adaptation) {
|
|
649
|
-
var
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
closedCaption: adaptation.isClosedCaption === true,
|
|
653
|
-
id: adaptation.id,
|
|
654
|
-
active: currentId === null ? false :
|
|
655
|
-
currentId === adaptation.id,
|
|
656
|
-
label: adaptation.label,
|
|
657
|
-
};
|
|
658
|
-
if (adaptation.isForcedSubtitles !== undefined) {
|
|
659
|
-
formatted.forced = adaptation.isForcedSubtitles;
|
|
660
|
-
}
|
|
661
|
-
return formatted;
|
|
677
|
+
var active = currentId === null ? false :
|
|
678
|
+
currentId === adaptation.id;
|
|
679
|
+
return objectAssign(adaptation.toTextTrack(), { active: active });
|
|
662
680
|
});
|
|
663
681
|
};
|
|
664
682
|
/**
|
|
@@ -677,35 +695,21 @@ var TracksStore = /** @class */ (function (_super) {
|
|
|
677
695
|
storedSettings.adaptation.id;
|
|
678
696
|
return periodObj.period.getSupportedAdaptations("video")
|
|
679
697
|
.map(function (adaptation) {
|
|
680
|
-
var
|
|
681
|
-
adaptation.
|
|
698
|
+
var active = currentId === null ? false :
|
|
699
|
+
currentId === adaptation.id;
|
|
700
|
+
var track = adaptation.toVideoTrack(true);
|
|
701
|
+
var trickModeTracks = track.trickModeTracks !== undefined ?
|
|
702
|
+
track.trickModeTracks.map(function (trickModeAdaptation) {
|
|
682
703
|
var isActive = currentId === null ? false :
|
|
683
704
|
currentId === trickModeAdaptation.id;
|
|
684
|
-
|
|
685
|
-
.map(parseVideoRepresentation);
|
|
686
|
-
var trickMode = { id: trickModeAdaptation.id, representations: representations, isTrickModeTrack: true,
|
|
687
|
-
active: isActive };
|
|
688
|
-
if (trickModeAdaptation.isSignInterpreted === true) {
|
|
689
|
-
trickMode.signInterpreted = true;
|
|
690
|
-
}
|
|
691
|
-
return trickMode;
|
|
705
|
+
return objectAssign(trickModeAdaptation, { active: isActive });
|
|
692
706
|
}) :
|
|
693
|
-
|
|
694
|
-
var
|
|
695
|
-
id: adaptation.id,
|
|
696
|
-
active: currentId === null ? false :
|
|
697
|
-
currentId === adaptation.id,
|
|
698
|
-
representations: adaptation.getPlayableRepresentations()
|
|
699
|
-
.map(parseVideoRepresentation),
|
|
700
|
-
label: adaptation.label,
|
|
701
|
-
};
|
|
702
|
-
if (adaptation.isSignInterpreted === true) {
|
|
703
|
-
formatted.signInterpreted = true;
|
|
704
|
-
}
|
|
707
|
+
[];
|
|
708
|
+
var availableTrack = objectAssign(track, { active: active });
|
|
705
709
|
if (trickModeTracks !== undefined) {
|
|
706
|
-
|
|
710
|
+
availableTrack.trickModeTracks = trickModeTracks;
|
|
707
711
|
}
|
|
708
|
-
return
|
|
712
|
+
return availableTrack;
|
|
709
713
|
});
|
|
710
714
|
};
|
|
711
715
|
TracksStore.prototype.getLockedAudioRepresentations = function (periodObj) {
|
|
@@ -888,15 +892,6 @@ function getPeriodItem(periods, periodId) {
|
|
|
888
892
|
}
|
|
889
893
|
}
|
|
890
894
|
}
|
|
891
|
-
/**
|
|
892
|
-
* Parse video Representation into a IVideoRepresentation.
|
|
893
|
-
* @param {Object} representation
|
|
894
|
-
* @returns {Object}
|
|
895
|
-
*/
|
|
896
|
-
function parseVideoRepresentation(_a) {
|
|
897
|
-
var id = _a.id, bitrate = _a.bitrate, frameRate = _a.frameRate, width = _a.width, height = _a.height, codec = _a.codec, hdrInfo = _a.hdrInfo;
|
|
898
|
-
return { id: id, bitrate: bitrate, frameRate: frameRate, width: width, height: height, codec: codec, hdrInfo: hdrInfo };
|
|
899
|
-
}
|
|
900
895
|
/**
|
|
901
896
|
* A `ITMPeriodObject` should only be removed once all References linked to it
|
|
902
897
|
* do not exist anymore, to keep the possibility of making track choices.
|
|
@@ -910,15 +905,6 @@ function isPeriodItemRemovable(periodObj) {
|
|
|
910
905
|
((_b = periodObj.audio) === null || _b === void 0 ? void 0 : _b.dispatcher) === null &&
|
|
911
906
|
((_c = periodObj.video) === null || _c === void 0 ? void 0 : _c.dispatcher) === null;
|
|
912
907
|
}
|
|
913
|
-
/**
|
|
914
|
-
* Parse audio Representation into a ITMAudioRepresentation.
|
|
915
|
-
* @param {Object} representation
|
|
916
|
-
* @returns {Object}
|
|
917
|
-
*/
|
|
918
|
-
function parseAudioRepresentation(_a) {
|
|
919
|
-
var id = _a.id, bitrate = _a.bitrate, codec = _a.codec;
|
|
920
|
-
return { id: id, bitrate: bitrate, codec: codec };
|
|
921
|
-
}
|
|
922
908
|
function getRightVideoTrack(adaptation, isTrickModeEnabled) {
|
|
923
909
|
var _a;
|
|
924
910
|
if (isTrickModeEnabled &&
|
|
@@ -982,77 +968,6 @@ function generatePeriodInfo(period, inManifest, isTrickModeTrackEnabled, default
|
|
|
982
968
|
text: { storedSettings: textSettings,
|
|
983
969
|
dispatcher: null } };
|
|
984
970
|
}
|
|
985
|
-
/**
|
|
986
|
-
* Format Adaptation structure into the format awaited by the API.
|
|
987
|
-
* @param {Object} a
|
|
988
|
-
* @returns {Object}
|
|
989
|
-
*/
|
|
990
|
-
function toTextTrack(a) {
|
|
991
|
-
var _a, _b;
|
|
992
|
-
var formatted = {
|
|
993
|
-
language: (_a = a.language) !== null && _a !== void 0 ? _a : "",
|
|
994
|
-
normalized: (_b = a.normalizedLanguage) !== null && _b !== void 0 ? _b : "",
|
|
995
|
-
closedCaption: a.isClosedCaption === true,
|
|
996
|
-
id: a.id,
|
|
997
|
-
label: a.label,
|
|
998
|
-
};
|
|
999
|
-
if (a.isForcedSubtitles !== undefined) {
|
|
1000
|
-
formatted.forced = a.isForcedSubtitles;
|
|
1001
|
-
}
|
|
1002
|
-
return formatted;
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Format Adaptation structure into the format awaited by the API.
|
|
1006
|
-
* @param {Object} a
|
|
1007
|
-
* @returns {Object}
|
|
1008
|
-
*/
|
|
1009
|
-
function toVideoTrack(a) {
|
|
1010
|
-
var trickModeTracks = a.trickModeTracks !== undefined ?
|
|
1011
|
-
a.trickModeTracks.map(function (trickModeAdaptation) {
|
|
1012
|
-
var representations = trickModeAdaptation.getPlayableRepresentations()
|
|
1013
|
-
.map(parseVideoRepresentation);
|
|
1014
|
-
var trickMode = { id: trickModeAdaptation.id, representations: representations, isTrickModeTrack: true };
|
|
1015
|
-
if (trickModeAdaptation.isSignInterpreted === true) {
|
|
1016
|
-
trickMode.signInterpreted = true;
|
|
1017
|
-
}
|
|
1018
|
-
return trickMode;
|
|
1019
|
-
}) :
|
|
1020
|
-
undefined;
|
|
1021
|
-
var videoTrack = {
|
|
1022
|
-
id: a.id,
|
|
1023
|
-
representations: a.getPlayableRepresentations().map(parseVideoRepresentation),
|
|
1024
|
-
label: a.label,
|
|
1025
|
-
};
|
|
1026
|
-
if (a.isSignInterpreted === true) {
|
|
1027
|
-
videoTrack.signInterpreted = true;
|
|
1028
|
-
}
|
|
1029
|
-
if (a.isTrickModeTrack === true) {
|
|
1030
|
-
videoTrack.isTrickModeTrack = true;
|
|
1031
|
-
}
|
|
1032
|
-
if (trickModeTracks !== undefined) {
|
|
1033
|
-
videoTrack.trickModeTracks = trickModeTracks;
|
|
1034
|
-
}
|
|
1035
|
-
return videoTrack;
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Convert an audio Adaptation into an audio track.
|
|
1039
|
-
* @param {object|null} adaptation - Audio adaptation
|
|
1040
|
-
* @returns {object|null} - corresponding audio track object.
|
|
1041
|
-
*/
|
|
1042
|
-
function toAudioTrack(adaptation) {
|
|
1043
|
-
var audioTrack = {
|
|
1044
|
-
language: takeFirstSet(adaptation.language, ""),
|
|
1045
|
-
normalized: takeFirstSet(adaptation.normalizedLanguage, ""),
|
|
1046
|
-
audioDescription: adaptation.isAudioDescription === true,
|
|
1047
|
-
id: adaptation.id,
|
|
1048
|
-
representations: adaptation.representations.map(parseAudioRepresentation),
|
|
1049
|
-
label: adaptation.label,
|
|
1050
|
-
};
|
|
1051
|
-
if (adaptation.isDub === true) {
|
|
1052
|
-
audioTrack.dub = true;
|
|
1053
|
-
}
|
|
1054
|
-
return audioTrack;
|
|
1055
|
-
}
|
|
1056
971
|
function toExposedPeriod(p) {
|
|
1057
972
|
return { start: p.start, end: p.end, id: p.id };
|
|
1058
973
|
}
|
|
@@ -30,6 +30,16 @@ import { IPlaybackObservation, IReadOnlyPlaybackObserver } from "./playback_obse
|
|
|
30
30
|
* remove all listeners this function has registered.
|
|
31
31
|
*/
|
|
32
32
|
export declare function emitSeekEvents(mediaElement: HTMLMediaElement | null, playbackObserver: IReadOnlyPlaybackObserver<IPlaybackObservation>, onSeeking: () => void, onSeeked: () => void, cancelSignal: CancellationSignal): void;
|
|
33
|
+
/**
|
|
34
|
+
* @param {HTMLMediaElement} mediaElement
|
|
35
|
+
* @param {function} onPlay - Callback called when a play operation has started
|
|
36
|
+
* on `mediaElement`.
|
|
37
|
+
* @param {function} onPause - Callback called when a pause operation has
|
|
38
|
+
* started on `mediaElement`.
|
|
39
|
+
* @param {Object} cancelSignal - When triggered, stop calling callbacks and
|
|
40
|
+
* remove all listeners this function has registered.
|
|
41
|
+
*/
|
|
42
|
+
export declare function emitPlayPauseEvents(mediaElement: HTMLMediaElement | null, onPlay: () => void, onPause: () => void, cancelSignal: CancellationSignal): void;
|
|
33
43
|
/** Player state dictionnary. */
|
|
34
44
|
export declare const enum PLAYER_STATES {
|
|
35
45
|
STOPPED = "STOPPED",
|
|
@@ -28,13 +28,13 @@ import createSharedReference from "../../utils/reference";
|
|
|
28
28
|
* remove all listeners this function has registered.
|
|
29
29
|
*/
|
|
30
30
|
export function emitSeekEvents(mediaElement, playbackObserver, onSeeking, onSeeked, cancelSignal) {
|
|
31
|
-
if (cancelSignal.isCancelled || mediaElement === null) {
|
|
31
|
+
if (cancelSignal.isCancelled() || mediaElement === null) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
var wasSeeking = playbackObserver.getReference().getValue().seeking;
|
|
35
35
|
if (wasSeeking) {
|
|
36
36
|
onSeeking();
|
|
37
|
-
if (cancelSignal.isCancelled) {
|
|
37
|
+
if (cancelSignal.isCancelled()) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -49,12 +49,32 @@ export function emitSeekEvents(mediaElement, playbackObserver, onSeeking, onSeek
|
|
|
49
49
|
}
|
|
50
50
|
}, { includeLastObservation: true, clearSignal: cancelSignal });
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @param {HTMLMediaElement} mediaElement
|
|
54
|
+
* @param {function} onPlay - Callback called when a play operation has started
|
|
55
|
+
* on `mediaElement`.
|
|
56
|
+
* @param {function} onPause - Callback called when a pause operation has
|
|
57
|
+
* started on `mediaElement`.
|
|
58
|
+
* @param {Object} cancelSignal - When triggered, stop calling callbacks and
|
|
59
|
+
* remove all listeners this function has registered.
|
|
60
|
+
*/
|
|
61
|
+
export function emitPlayPauseEvents(mediaElement, onPlay, onPause, cancelSignal) {
|
|
62
|
+
if (cancelSignal.isCancelled() || mediaElement === null) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
mediaElement.addEventListener("play", onPlay);
|
|
66
|
+
mediaElement.addEventListener("pause", onPause);
|
|
67
|
+
cancelSignal.register(function () {
|
|
68
|
+
mediaElement.removeEventListener("play", onPlay);
|
|
69
|
+
mediaElement.removeEventListener("pause", onPause);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
52
72
|
export function constructPlayerStateReference(initializer, mediaElement, playbackObserver, cancelSignal) {
|
|
53
73
|
var playerStateRef = createSharedReference("LOADING" /* PLAYER_STATES.LOADING */, cancelSignal);
|
|
54
74
|
initializer.addEventListener("loaded", function () {
|
|
55
75
|
if (playerStateRef.getValue() === "LOADING" /* PLAYER_STATES.LOADING */) {
|
|
56
76
|
playerStateRef.setValue("LOADED" /* PLAYER_STATES.LOADED */);
|
|
57
|
-
if (!cancelSignal.isCancelled) {
|
|
77
|
+
if (!cancelSignal.isCancelled()) {
|
|
58
78
|
var newState = getLoadedContentState(mediaElement, null);
|
|
59
79
|
if (newState !== "PAUSED" /* PLAYER_STATES.PAUSED */) {
|
|
60
80
|
playerStateRef.setValue(newState);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { IEncryptedEventData } from "../../../../compat/eme";
|
|
18
18
|
import EventEmitter from "../../../../utils/event_emitter";
|
|
19
19
|
/** Default MediaKeySystemAccess configuration used by the RxPlayer. */
|
|
20
|
-
export declare const defaultKSConfig: {
|
|
20
|
+
export declare const defaultKSConfig: ({
|
|
21
21
|
audioCapabilities: {
|
|
22
22
|
contentType: string;
|
|
23
23
|
}[];
|
|
@@ -28,12 +28,19 @@ export declare const defaultKSConfig: {
|
|
|
28
28
|
videoCapabilities: {
|
|
29
29
|
contentType: string;
|
|
30
30
|
}[];
|
|
31
|
-
}
|
|
31
|
+
} | {
|
|
32
|
+
audioCapabilities: undefined;
|
|
33
|
+
distinctiveIdentifier: "optional";
|
|
34
|
+
initDataTypes: readonly ["cenc"];
|
|
35
|
+
persistentState: "optional";
|
|
36
|
+
sessionTypes: readonly ["temporary"];
|
|
37
|
+
videoCapabilities: undefined;
|
|
38
|
+
})[];
|
|
32
39
|
/**
|
|
33
40
|
* Default "com.microsoft.playready.recommendation" MediaKeySystemAccess
|
|
34
41
|
* configuration used by the RxPlayer.
|
|
35
42
|
*/
|
|
36
|
-
export declare const defaultPRRecommendationKSConfig: {
|
|
43
|
+
export declare const defaultPRRecommendationKSConfig: ({
|
|
37
44
|
audioCapabilities: {
|
|
38
45
|
robustness: string;
|
|
39
46
|
contentType: string;
|
|
@@ -46,22 +53,34 @@ export declare const defaultPRRecommendationKSConfig: {
|
|
|
46
53
|
robustness: string;
|
|
47
54
|
contentType: string;
|
|
48
55
|
}[];
|
|
49
|
-
}
|
|
56
|
+
} | {
|
|
57
|
+
audioCapabilities: undefined;
|
|
58
|
+
distinctiveIdentifier: "optional";
|
|
59
|
+
initDataTypes: readonly ["cenc"];
|
|
60
|
+
persistentState: "optional";
|
|
61
|
+
sessionTypes: readonly ["temporary"];
|
|
62
|
+
videoCapabilities: undefined;
|
|
63
|
+
})[];
|
|
50
64
|
/** Default Widevine MediaKeySystemAccess configuration used by the RxPlayer. */
|
|
51
|
-
export declare const defaultWidevineConfig: {
|
|
65
|
+
export declare const defaultWidevineConfig: ({
|
|
52
66
|
audioCapabilities: {
|
|
53
67
|
contentType: string;
|
|
54
|
-
robustness: string;
|
|
55
68
|
}[];
|
|
69
|
+
distinctiveIdentifier: "optional";
|
|
70
|
+
initDataTypes: readonly ["cenc"];
|
|
71
|
+
persistentState: "optional";
|
|
72
|
+
sessionTypes: readonly ["temporary"];
|
|
56
73
|
videoCapabilities: {
|
|
57
74
|
contentType: string;
|
|
58
|
-
robustness: string;
|
|
59
75
|
}[];
|
|
76
|
+
} | {
|
|
77
|
+
audioCapabilities: undefined;
|
|
60
78
|
distinctiveIdentifier: "optional";
|
|
61
79
|
initDataTypes: readonly ["cenc"];
|
|
62
80
|
persistentState: "optional";
|
|
63
81
|
sessionTypes: readonly ["temporary"];
|
|
64
|
-
|
|
82
|
+
videoCapabilities: undefined;
|
|
83
|
+
})[];
|
|
65
84
|
/**
|
|
66
85
|
* Custom implementation of an EME-compliant MediaKeyStatusMap.
|
|
67
86
|
* @class MediaKeyStatusMapImpl
|
|
@@ -44,7 +44,8 @@ import EventEmitter from "../../../../utils/event_emitter";
|
|
|
44
44
|
import flatMap from "../../../../utils/flat_map";
|
|
45
45
|
import { strToUtf8, utf8ToStr, } from "../../../../utils/string_parsing";
|
|
46
46
|
/** Default MediaKeySystemAccess configuration used by the RxPlayer. */
|
|
47
|
-
export var defaultKSConfig = [
|
|
47
|
+
export var defaultKSConfig = [
|
|
48
|
+
{
|
|
48
49
|
audioCapabilities: [{ contentType: "audio/mp4;codecs=\"mp4a.40.2\"" },
|
|
49
50
|
{ contentType: "audio/webm;codecs=opus" }],
|
|
50
51
|
distinctiveIdentifier: "optional",
|
|
@@ -54,12 +55,22 @@ export var defaultKSConfig = [{
|
|
|
54
55
|
videoCapabilities: [{ contentType: "video/mp4;codecs=\"avc1.4d401e\"" },
|
|
55
56
|
{ contentType: "video/mp4;codecs=\"avc1.42e01e\"" },
|
|
56
57
|
{ contentType: "video/webm;codecs=\"vp8\"" }],
|
|
57
|
-
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
audioCapabilities: undefined,
|
|
61
|
+
distinctiveIdentifier: "optional",
|
|
62
|
+
initDataTypes: ["cenc"],
|
|
63
|
+
persistentState: "optional",
|
|
64
|
+
sessionTypes: ["temporary"],
|
|
65
|
+
videoCapabilities: undefined,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
58
68
|
/**
|
|
59
69
|
* Default "com.microsoft.playready.recommendation" MediaKeySystemAccess
|
|
60
70
|
* configuration used by the RxPlayer.
|
|
61
71
|
*/
|
|
62
|
-
export var defaultPRRecommendationKSConfig = [
|
|
72
|
+
export var defaultPRRecommendationKSConfig = [
|
|
73
|
+
{
|
|
63
74
|
audioCapabilities: [{ robustness: "3000",
|
|
64
75
|
contentType: "audio/mp4;codecs=\"mp4a.40.2\"" },
|
|
65
76
|
{ robustness: "3000",
|
|
@@ -84,7 +95,16 @@ export var defaultPRRecommendationKSConfig = [{
|
|
|
84
95
|
contentType: "video/mp4;codecs=\"avc1.42e01e\"" },
|
|
85
96
|
{ robustness: "2000",
|
|
86
97
|
contentType: "video/webm;codecs=\"vp8\"" }],
|
|
87
|
-
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
audioCapabilities: undefined,
|
|
101
|
+
distinctiveIdentifier: "optional",
|
|
102
|
+
initDataTypes: ["cenc"],
|
|
103
|
+
persistentState: "optional",
|
|
104
|
+
sessionTypes: ["temporary"],
|
|
105
|
+
videoCapabilities: undefined,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
88
108
|
/** Default Widevine MediaKeySystemAccess configuration used by the RxPlayer. */
|
|
89
109
|
export var defaultWidevineConfig = (function () {
|
|
90
110
|
var ROBUSTNESSES = ["HW_SECURE_ALL",
|
|
@@ -101,9 +121,10 @@ export var defaultWidevineConfig = (function () {
|
|
|
101
121
|
return [{ contentType: "audio/mp4;codecs=\"mp4a.40.2\"", robustness: robustness },
|
|
102
122
|
{ contentType: "audio/webm;codecs=opus", robustness: robustness }];
|
|
103
123
|
});
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
return [
|
|
125
|
+
__assign(__assign({}, defaultKSConfig[0]), { audioCapabilities: audioCapabilities, videoCapabilities: videoCapabilities }),
|
|
126
|
+
defaultKSConfig[1],
|
|
127
|
+
];
|
|
107
128
|
})();
|
|
108
129
|
/**
|
|
109
130
|
* Custom implementation of an EME-compliant MediaKeyStatusMap.
|