rx-player 4.0.0-dev.2023111400 → 4.0.0-dev.2023121900
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/CHANGELOG.md +20 -60
- package/FILES.md +1 -1
- package/README.md +2 -33
- package/VERSION +1 -1
- package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
- package/dist/_esm5.processed/core/api/debug/modules/general_info.js +20 -10
- package/dist/_esm5.processed/core/api/option_utils.d.ts +0 -2
- package/dist/_esm5.processed/core/api/option_utils.js +0 -6
- package/dist/_esm5.processed/core/api/public_api.d.ts +1 -2
- package/dist/_esm5.processed/core/api/public_api.js +9 -17
- package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
- package/dist/_esm5.processed/core/init/media_source_content_initializer.js +3 -14
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +2 -36
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +2 -82
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
- package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +19 -10
- package/dist/_esm5.processed/core/stream/representation/utils/get_buffer_status.js +1 -1
- package/dist/_esm5.processed/core/stream/representation/utils/get_needed_segments.js +1 -1
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +1 -8
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
- package/dist/_esm5.processed/public_types.d.ts +2 -0
- package/dist/commonjs/compat/is_codec_supported.js +22 -1
- package/dist/commonjs/config.d.ts +2 -1
- package/dist/commonjs/core/adaptive/adaptive_representation_selector.d.ts +2 -19
- package/dist/commonjs/core/adaptive/adaptive_representation_selector.js +2 -2
- package/dist/commonjs/core/adaptive/network_analyzer.js +3 -3
- package/dist/commonjs/core/api/debug/buffer_graph.js +2 -6
- package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
- package/dist/commonjs/core/api/index.d.ts +1 -1
- package/dist/commonjs/core/api/option_utils.d.ts +2 -0
- package/dist/commonjs/core/api/option_utils.js +2 -3
- package/dist/commonjs/core/api/playback_observer.d.ts +128 -8
- package/dist/commonjs/core/api/playback_observer.js +217 -64
- package/dist/commonjs/core/api/public_api.d.ts +9 -0
- package/dist/commonjs/core/api/public_api.js +41 -16
- package/dist/commonjs/core/api/utils.js +1 -1
- package/dist/commonjs/core/decrypt/get_media_keys.js +2 -6
- package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
- package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
- package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
- package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
- package/dist/commonjs/core/init/directfile_content_initializer.js +29 -8
- package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
- package/dist/commonjs/core/init/media_source_content_initializer.js +32 -20
- package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
- package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +17 -19
- package/dist/commonjs/core/init/utils/create_stream_playback_observer.d.ts +1 -5
- package/dist/commonjs/core/init/utils/create_stream_playback_observer.js +16 -14
- package/dist/commonjs/core/init/utils/get_initial_time.d.ts +17 -3
- package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
- package/dist/commonjs/core/init/utils/initial_seek_and_play.d.ts +9 -11
- package/dist/commonjs/core/init/utils/initial_seek_and_play.js +121 -91
- package/dist/commonjs/core/init/utils/rebuffering_controller.js +27 -70
- package/dist/commonjs/core/init/utils/stream_events_emitter/stream_events_emitter.js +4 -2
- package/dist/commonjs/core/segment_buffers/garbage_collector.js +1 -2
- package/dist/commonjs/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
- package/dist/commonjs/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
- package/dist/commonjs/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
- package/dist/commonjs/core/segment_buffers/index.d.ts +2 -2
- package/dist/commonjs/core/segment_buffers/inventory/index.d.ts +2 -2
- package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
- package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.js +19 -10
- package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.d.ts +2 -2
- package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.js +16 -9
- package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +14 -18
- package/dist/commonjs/core/stream/period/period_stream.js +5 -8
- package/dist/commonjs/core/stream/period/types.d.ts +2 -3
- package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -5
- package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.js +17 -13
- package/dist/commonjs/core/stream/representation/representation_stream.js +3 -4
- package/dist/commonjs/core/stream/representation/types.d.ts +2 -2
- package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +11 -12
- package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +4 -4
- package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
- package/dist/commonjs/default_config.d.ts +12 -16
- package/dist/commonjs/default_config.js +21 -16
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
- package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
- package/dist/commonjs/manifest/adaptation.js +2 -1
- package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
- package/dist/commonjs/manifest/representation_index/static.js +2 -2
- package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
- package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
- package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
- package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
- package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
- package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
- package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
- package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
- package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
- package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
- package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
- package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
- package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +7 -3
- package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
- package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
- package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
- package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
- package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
- package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/commonjs/public_types.d.ts +107 -36
- package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
- package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
- package/dist/commonjs/transports/dash/segment_loader.js +2 -1
- package/dist/commonjs/transports/dash/text_loader.js +2 -0
- package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
- package/dist/commonjs/transports/smooth/pipelines.js +4 -2
- package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
- package/dist/commonjs/transports/types.d.ts +12 -0
- package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
- package/dist/commonjs/utils/request/fetch.d.ts +6 -0
- package/dist/commonjs/utils/request/fetch.js +29 -8
- package/dist/commonjs/utils/request/xhr.d.ts +11 -5
- package/dist/commonjs/utils/request/xhr.js +29 -8
- package/dist/es2017/compat/is_codec_supported.js +22 -1
- package/dist/es2017/config.d.ts +2 -1
- package/dist/es2017/core/adaptive/adaptive_representation_selector.d.ts +2 -19
- package/dist/es2017/core/adaptive/adaptive_representation_selector.js +2 -2
- package/dist/es2017/core/adaptive/network_analyzer.js +3 -3
- package/dist/es2017/core/api/debug/buffer_graph.js +2 -6
- package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
- package/dist/es2017/core/api/index.d.ts +1 -1
- package/dist/es2017/core/api/option_utils.d.ts +2 -0
- package/dist/es2017/core/api/option_utils.js +2 -3
- package/dist/es2017/core/api/playback_observer.d.ts +128 -8
- package/dist/es2017/core/api/playback_observer.js +217 -66
- package/dist/es2017/core/api/public_api.d.ts +9 -0
- package/dist/es2017/core/api/public_api.js +40 -15
- package/dist/es2017/core/api/utils.js +1 -1
- package/dist/es2017/core/decrypt/get_media_keys.js +2 -6
- package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
- package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
- package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
- package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
- package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
- package/dist/es2017/core/init/directfile_content_initializer.js +31 -8
- package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
- package/dist/es2017/core/init/media_source_content_initializer.js +34 -22
- package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
- package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +17 -17
- package/dist/es2017/core/init/utils/create_stream_playback_observer.d.ts +1 -5
- package/dist/es2017/core/init/utils/create_stream_playback_observer.js +16 -14
- package/dist/es2017/core/init/utils/get_initial_time.d.ts +17 -3
- package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
- package/dist/es2017/core/init/utils/initial_seek_and_play.d.ts +9 -11
- package/dist/es2017/core/init/utils/initial_seek_and_play.js +120 -91
- package/dist/es2017/core/init/utils/rebuffering_controller.js +27 -70
- package/dist/es2017/core/init/utils/stream_events_emitter/stream_events_emitter.js +4 -2
- package/dist/es2017/core/segment_buffers/garbage_collector.js +1 -2
- package/dist/es2017/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
- package/dist/es2017/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
- package/dist/es2017/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
- package/dist/es2017/core/segment_buffers/index.d.ts +2 -2
- package/dist/es2017/core/segment_buffers/inventory/index.d.ts +2 -2
- package/dist/es2017/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
- package/dist/es2017/core/segment_buffers/inventory/segment_inventory.js +19 -10
- package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.d.ts +2 -2
- package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.js +16 -9
- package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +16 -18
- package/dist/es2017/core/stream/period/period_stream.js +4 -7
- package/dist/es2017/core/stream/period/types.d.ts +2 -3
- package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -5
- package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.js +17 -13
- package/dist/es2017/core/stream/representation/representation_stream.js +3 -4
- package/dist/es2017/core/stream/representation/types.d.ts +2 -2
- package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.js +1 -2
- package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +4 -4
- package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
- package/dist/es2017/default_config.d.ts +12 -16
- package/dist/es2017/default_config.js +21 -16
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
- package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
- package/dist/es2017/manifest/adaptation.js +2 -1
- package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
- package/dist/es2017/manifest/representation_index/static.js +2 -2
- package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
- package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
- package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
- package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
- package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
- package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
- package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
- package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
- package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
- package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
- package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
- package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
- package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
- package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +7 -3
- package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
- package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
- package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
- package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
- package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
- package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
- package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
- package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/es2017/public_types.d.ts +107 -36
- package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
- package/dist/es2017/transports/dash/manifest_parser.js +3 -0
- package/dist/es2017/transports/dash/segment_loader.js +1 -0
- package/dist/es2017/transports/dash/text_loader.js +2 -0
- package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
- package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
- package/dist/es2017/transports/smooth/pipelines.js +2 -0
- package/dist/es2017/transports/smooth/segment_loader.js +1 -0
- package/dist/es2017/transports/types.d.ts +12 -0
- package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
- package/dist/es2017/utils/request/fetch.d.ts +6 -0
- package/dist/es2017/utils/request/fetch.js +29 -8
- package/dist/es2017/utils/request/xhr.d.ts +11 -5
- package/dist/es2017/utils/request/xhr.js +30 -9
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +1335 -812
- package/dist/rx-player.min.js +1 -1
- package/package.json +7 -4
- package/scripts/canal-release.patch +78 -0
- package/scripts/make-dev-releases +65 -0
- package/scripts/update-version +7 -0
- package/sonar-project.properties +1 -1
- package/src/compat/is_codec_supported.ts +23 -1
- package/src/core/adaptive/adaptive_representation_selector.ts +4 -21
- package/src/core/adaptive/network_analyzer.ts +3 -3
- package/src/core/api/debug/buffer_graph.ts +2 -5
- package/src/core/api/debug/modules/general_info.ts +15 -10
- package/src/core/api/index.ts +1 -0
- package/src/core/api/option_utils.ts +3 -3
- package/src/core/api/playback_observer.ts +327 -107
- package/src/core/api/public_api.ts +42 -14
- package/src/core/api/utils.ts +3 -1
- package/src/core/decrypt/get_media_keys.ts +2 -8
- package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
- package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
- package/src/core/fetchers/utils/schedule_request.ts +1 -1
- package/src/core/init/directfile_content_initializer.ts +31 -15
- package/src/core/init/media_source_content_initializer.ts +40 -27
- package/src/core/init/utils/content_time_boundaries_observer.ts +24 -23
- package/src/core/init/utils/create_stream_playback_observer.ts +19 -20
- package/src/core/init/utils/get_initial_time.ts +25 -12
- package/src/core/init/utils/initial_seek_and_play.ts +140 -108
- package/src/core/init/utils/rebuffering_controller.ts +32 -77
- package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +5 -2
- package/src/core/segment_buffers/garbage_collector.ts +1 -1
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +10 -2
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +1 -1
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +1 -1
- package/src/core/segment_buffers/index.ts +2 -0
- package/src/core/segment_buffers/inventory/index.ts +2 -0
- package/src/core/segment_buffers/inventory/segment_inventory.ts +49 -17
- package/src/core/stream/adaptation/get_representations_switch_strategy.ts +21 -12
- package/src/core/stream/orchestrator/stream_orchestrator.ts +14 -19
- package/src/core/stream/period/period_stream.ts +7 -8
- package/src/core/stream/period/types.ts +2 -3
- package/src/core/stream/period/utils/get_adaptation_switch_strategy.ts +21 -15
- package/src/core/stream/representation/representation_stream.ts +3 -5
- package/src/core/stream/representation/types.ts +2 -2
- package/src/core/stream/representation/utils/append_segment_to_buffer.ts +1 -1
- package/src/core/stream/representation/utils/get_buffer_status.ts +5 -4
- package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
- package/src/default_config.ts +22 -17
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
- package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
- package/src/manifest/adaptation.ts +2 -1
- package/src/manifest/representation_index/static.ts +2 -2
- package/src/manifest/representation_index/types.ts +4 -4
- package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
- package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
- package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
- package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
- package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
- package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
- package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
- package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
- package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
- package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
- package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
- package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
- package/src/parsers/manifest/dash/common/parse_representations.ts +9 -3
- package/src/parsers/manifest/local/representation_index.ts +3 -3
- package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
- package/src/parsers/manifest/smooth/representation_index.ts +23 -9
- package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
- package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
- package/src/parsers/manifest/utils/index_helpers.ts +1 -1
- package/src/parsers/texttracks/ttml/html/apply_line_height.ts +3 -1
- package/src/public_types.ts +108 -36
- package/src/transports/dash/init_segment_loader.ts +5 -0
- package/src/transports/dash/manifest_parser.ts +6 -0
- package/src/transports/dash/segment_loader.ts +1 -0
- package/src/transports/dash/text_loader.ts +2 -0
- package/src/transports/metaplaylist/manifest_loader.ts +1 -0
- package/src/transports/metaplaylist/pipelines.ts +4 -1
- package/src/transports/smooth/pipelines.ts +2 -0
- package/src/transports/smooth/segment_loader.ts +1 -0
- package/src/transports/types.ts +12 -0
- package/src/transports/utils/generate_manifest_loader.ts +3 -0
- package/src/utils/request/fetch.ts +35 -8
- package/src/utils/request/xhr.ts +45 -14
- package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
- package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
- package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
- package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
- package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
- package/src/typings/object-assign.d.ts +0 -48
|
@@ -49,8 +49,8 @@ var task_canceller_1 = require("../../../utils/task_canceller");
|
|
|
49
49
|
/**
|
|
50
50
|
* Observes what's being played and take care of media events relating to time
|
|
51
51
|
* boundaries:
|
|
52
|
-
* - Emits a `
|
|
53
|
-
* known and every time it changes.
|
|
52
|
+
* - Emits a `endingPositionChange` when the known maximum playable position
|
|
53
|
+
* of the current content is known and every time it changes.
|
|
54
54
|
* - Emits `endOfStream` API once segments have been pushed until the end and
|
|
55
55
|
* `resumeStream` if downloads starts back.
|
|
56
56
|
* - Emits a `periodChange` event when the currently-playing Period seemed to
|
|
@@ -80,9 +80,8 @@ var ContentTimeBoundariesObserver = /** @class */ (function (_super) {
|
|
|
80
80
|
_this._maximumPositionCalculator = maximumPositionCalculator;
|
|
81
81
|
var cancelSignal = _this._canceller.signal;
|
|
82
82
|
playbackObserver.listen(function (_a) {
|
|
83
|
-
var _b;
|
|
84
83
|
var position = _a.position;
|
|
85
|
-
var wantedPosition =
|
|
84
|
+
var wantedPosition = position.getWanted();
|
|
86
85
|
if (wantedPosition < manifest.getMinimumSafePosition()) {
|
|
87
86
|
var warning = new errors_1.MediaError("MEDIA_TIME_BEFORE_MANIFEST", "The current position is behind the " +
|
|
88
87
|
"earliest time announced in the Manifest.");
|
|
@@ -95,7 +94,7 @@ var ContentTimeBoundariesObserver = /** @class */ (function (_super) {
|
|
|
95
94
|
}
|
|
96
95
|
}, { includeLastObservation: true, clearSignal: cancelSignal });
|
|
97
96
|
manifest.addEventListener("manifestUpdate", function () {
|
|
98
|
-
_this.trigger("
|
|
97
|
+
_this.trigger("endingPositionChange", _this._getManifestEndTime());
|
|
99
98
|
if (cancelSignal.isCancelled()) {
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
@@ -104,11 +103,12 @@ var ContentTimeBoundariesObserver = /** @class */ (function (_super) {
|
|
|
104
103
|
return _this;
|
|
105
104
|
}
|
|
106
105
|
/**
|
|
107
|
-
* Returns an estimate of the current
|
|
106
|
+
* Returns an estimate of the current last position which may be played in
|
|
107
|
+
* the content at the moment.
|
|
108
108
|
* @returns {Object}
|
|
109
109
|
*/
|
|
110
|
-
ContentTimeBoundariesObserver.prototype.
|
|
111
|
-
return this.
|
|
110
|
+
ContentTimeBoundariesObserver.prototype.getCurrentEndingTime = function () {
|
|
111
|
+
return this._getManifestEndTime();
|
|
112
112
|
};
|
|
113
113
|
/**
|
|
114
114
|
* Method to call any time an Adaptation has been selected.
|
|
@@ -137,12 +137,12 @@ var ContentTimeBoundariesObserver = /** @class */ (function (_super) {
|
|
|
137
137
|
.updateLastVideoAdaptation(adaptation);
|
|
138
138
|
}
|
|
139
139
|
var endingPosition = this._maximumPositionCalculator.getEndingPosition();
|
|
140
|
-
var
|
|
141
|
-
{ isEnd: true,
|
|
142
|
-
duration: endingPosition } :
|
|
140
|
+
var newEndingPosition = endingPosition !== undefined ?
|
|
141
|
+
{ isEnd: true, endingPosition: endingPosition } :
|
|
143
142
|
{ isEnd: false,
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
endingPosition: this._maximumPositionCalculator
|
|
144
|
+
.getMaximumAvailablePosition() };
|
|
145
|
+
this.trigger("endingPositionChange", newEndingPosition);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -286,13 +286,12 @@ var ContentTimeBoundariesObserver = /** @class */ (function (_super) {
|
|
|
286
286
|
finally { if (e_1) throw e_1.error; }
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
-
ContentTimeBoundariesObserver.prototype.
|
|
289
|
+
ContentTimeBoundariesObserver.prototype._getManifestEndTime = function () {
|
|
290
290
|
var endingPosition = this._maximumPositionCalculator.getEndingPosition();
|
|
291
291
|
return endingPosition !== undefined ?
|
|
292
|
-
{ isEnd: true,
|
|
293
|
-
duration: endingPosition } :
|
|
292
|
+
{ isEnd: true, endingPosition: endingPosition } :
|
|
294
293
|
{ isEnd: false,
|
|
295
|
-
|
|
294
|
+
endingPosition: this._maximumPositionCalculator.getMaximumAvailablePosition() };
|
|
296
295
|
};
|
|
297
296
|
ContentTimeBoundariesObserver.prototype._lazilyCreateActiveStreamInfo = function (bufferType) {
|
|
298
297
|
var streamInfo = this._activeStreams.get(bufferType);
|
|
@@ -366,9 +365,8 @@ var MaximumPositionCalculator = /** @class */ (function () {
|
|
|
366
365
|
* @returns {number}
|
|
367
366
|
*/
|
|
368
367
|
MaximumPositionCalculator.prototype.getMaximumAvailablePosition = function () {
|
|
369
|
-
var _a;
|
|
370
368
|
if (this._manifest.isDynamic) {
|
|
371
|
-
return
|
|
369
|
+
return this._manifest.getMaximumSafePosition();
|
|
372
370
|
}
|
|
373
371
|
if (this._lastVideoAdaptation === undefined ||
|
|
374
372
|
this._lastAudioAdaptation === undefined) {
|
|
@@ -26,12 +26,8 @@ export interface IStreamPlaybackObserverArguments {
|
|
|
26
26
|
manifest: Manifest;
|
|
27
27
|
/** Becomes `true` after the initial play has been taken care of. */
|
|
28
28
|
initialPlayPerformed: IReadOnlySharedReference<boolean>;
|
|
29
|
-
/** Becomes `true` after the initial seek has been taken care of. */
|
|
30
|
-
initialSeekPerformed: IReadOnlySharedReference<boolean>;
|
|
31
29
|
/** The last speed requested by the user. */
|
|
32
30
|
speed: IReadOnlySharedReference<number>;
|
|
33
|
-
/** The time the player will seek when `initialSeekPerformed` becomes `true`. */
|
|
34
|
-
startTime: number;
|
|
35
31
|
}
|
|
36
32
|
/**
|
|
37
33
|
* Create PlaybackObserver for the `Stream` part of the code.
|
|
@@ -42,4 +38,4 @@ export interface IStreamPlaybackObserverArguments {
|
|
|
42
38
|
* @param {Object} fnCancelSignal - Abort the created PlaybackObserver.
|
|
43
39
|
* @returns {Object}
|
|
44
40
|
*/
|
|
45
|
-
export default function createStreamPlaybackObserver(srcPlaybackObserver: PlaybackObserver, { autoPlay, initialPlayPerformed,
|
|
41
|
+
export default function createStreamPlaybackObserver(srcPlaybackObserver: PlaybackObserver, { autoPlay, initialPlayPerformed, manifest, speed }: IStreamPlaybackObserverArguments, fnCancelSignal: CancellationSignal): IReadOnlyPlaybackObserver<IStreamOrchestratorPlaybackObservation>;
|
|
@@ -27,7 +27,7 @@ var task_canceller_1 = require("../../../utils/task_canceller");
|
|
|
27
27
|
* @returns {Object}
|
|
28
28
|
*/
|
|
29
29
|
function createStreamPlaybackObserver(srcPlaybackObserver, _a, fnCancelSignal) {
|
|
30
|
-
var autoPlay = _a.autoPlay, initialPlayPerformed = _a.initialPlayPerformed,
|
|
30
|
+
var autoPlay = _a.autoPlay, initialPlayPerformed = _a.initialPlayPerformed, manifest = _a.manifest, speed = _a.speed;
|
|
31
31
|
return srcPlaybackObserver.deriveReadOnlyObserver(function transform(observationRef, parentObserverCancelSignal) {
|
|
32
32
|
var canceller = new task_canceller_1.default();
|
|
33
33
|
canceller.linkToSignal(parentObserverCancelSignal);
|
|
@@ -45,11 +45,7 @@ function createStreamPlaybackObserver(srcPlaybackObserver, _a, fnCancelSignal) {
|
|
|
45
45
|
function constructStreamPlaybackObservation() {
|
|
46
46
|
var observation = observationRef.getValue();
|
|
47
47
|
var lastSpeed = speed.getValue();
|
|
48
|
-
|
|
49
|
-
if (!initialSeekPerformed.getValue()) {
|
|
50
|
-
pendingPosition = startTime;
|
|
51
|
-
}
|
|
52
|
-
else if (!manifest.isDynamic || manifest.isLastPeriodKnown) {
|
|
48
|
+
if (!manifest.isDynamic || manifest.isLastPeriodKnown) {
|
|
53
49
|
// HACK: When the position is actually further than the maximum
|
|
54
50
|
// position for a finished content, we actually want to be loading
|
|
55
51
|
// the last segment before ending.
|
|
@@ -57,19 +53,25 @@ function createStreamPlaybackObserver(srcPlaybackObserver, _a, fnCancelSignal) {
|
|
|
57
53
|
// want to seek one second before the period's end (despite never
|
|
58
54
|
// doing it).
|
|
59
55
|
var lastPeriod = manifest.periods[manifest.periods.length - 1];
|
|
60
|
-
if (lastPeriod !== undefined &&
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
if (lastPeriod !== undefined && lastPeriod.end !== undefined) {
|
|
57
|
+
var wantedPosition = observation.position.getWanted();
|
|
58
|
+
if (wantedPosition >= lastPeriod.start &&
|
|
59
|
+
wantedPosition >= lastPeriod.end - 1) {
|
|
60
|
+
// We're after the end of the last Period, check if `buffered`
|
|
61
|
+
// indicates that the last segment is probably not loaded, in which
|
|
62
|
+
// case act as if we want to load one second before the end.
|
|
63
|
+
var buffered = observation.buffered;
|
|
64
|
+
if (buffered.length === 0 ||
|
|
65
|
+
buffered.end(buffered.length - 1) < observation.duration - 1) {
|
|
66
|
+
observation.position.forceWantedPosition(lastPeriod.end - 1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
return {
|
|
67
72
|
// TODO more exact according to the current Adaptation chosen?
|
|
68
73
|
maximumPosition: manifest.getMaximumSafePosition(),
|
|
69
|
-
position:
|
|
70
|
-
last: observation.position,
|
|
71
|
-
pending: pendingPosition,
|
|
72
|
-
},
|
|
74
|
+
position: observation.position,
|
|
73
75
|
duration: observation.duration,
|
|
74
76
|
paused: {
|
|
75
77
|
last: observation.paused,
|
|
@@ -37,11 +37,25 @@ export interface IInitialTimeOptions {
|
|
|
37
37
|
*/
|
|
38
38
|
fromFirstPosition?: number | null | undefined;
|
|
39
39
|
/**
|
|
40
|
-
* If set, we should begin at this position relative to the content's
|
|
41
|
-
* in seconds.
|
|
40
|
+
* If set, we should begin at this position relative to the content's maximum
|
|
41
|
+
* seekable position, in seconds.
|
|
42
|
+
*
|
|
43
|
+
* It should consequently in most cases be a negative value.
|
|
42
44
|
*/
|
|
43
45
|
fromLastPosition?: number | null | undefined;
|
|
44
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* If set, we should begin at this position relative to the content's live
|
|
48
|
+
* edge if it makes sense, in seconds.
|
|
49
|
+
*
|
|
50
|
+
* It should consequently in most cases be a negative value.
|
|
51
|
+
*
|
|
52
|
+
* If the live edge is unknown or if it does not make sense for the current
|
|
53
|
+
* content, that position is relative to the content's maximum position
|
|
54
|
+
* instead.
|
|
55
|
+
*/
|
|
56
|
+
fromLivePosition?: number | null | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* If set, we should begin at this position relative to the whole duration of
|
|
45
59
|
* the content, in percentage.
|
|
46
60
|
*/
|
|
47
61
|
percentage?: number | null | undefined;
|
|
@@ -33,15 +33,10 @@ var monotonic_timestamp_1 = require("../../../utils/monotonic_timestamp");
|
|
|
33
33
|
* @returns {Number}
|
|
34
34
|
*/
|
|
35
35
|
function getInitialTime(manifest, lowLatencyMode, startAt) {
|
|
36
|
+
var _a;
|
|
36
37
|
if (!(0, is_null_or_undefined_1.default)(startAt)) {
|
|
37
38
|
var min = manifest.getMinimumSafePosition();
|
|
38
|
-
var max =
|
|
39
|
-
if (manifest.isLive) {
|
|
40
|
-
max = manifest.getLivePosition();
|
|
41
|
-
}
|
|
42
|
-
if (max === undefined) {
|
|
43
|
-
max = manifest.getMaximumSafePosition();
|
|
44
|
-
}
|
|
39
|
+
var max = manifest.getMaximumSafePosition();
|
|
45
40
|
if (!(0, is_null_or_undefined_1.default)(startAt.position)) {
|
|
46
41
|
log_1.default.debug("Init: using startAt.minimumPosition");
|
|
47
42
|
return Math.max(Math.min(startAt.position, max), min);
|
|
@@ -66,6 +61,13 @@ function getInitialTime(manifest, lowLatencyMode, startAt) {
|
|
|
66
61
|
return fromLastPosition >= 0 ? max :
|
|
67
62
|
Math.max(min, max + fromLastPosition);
|
|
68
63
|
}
|
|
64
|
+
else if (!(0, is_null_or_undefined_1.default)(startAt.fromLivePosition)) {
|
|
65
|
+
log_1.default.debug("Init: using startAt.fromLivePosition");
|
|
66
|
+
var livePosition = (_a = manifest.getLivePosition()) !== null && _a !== void 0 ? _a : max;
|
|
67
|
+
var fromLivePosition = startAt.fromLivePosition;
|
|
68
|
+
return fromLivePosition >= 0 ? livePosition :
|
|
69
|
+
Math.max(min, livePosition + fromLivePosition);
|
|
70
|
+
}
|
|
69
71
|
else if (!(0, is_null_or_undefined_1.default)(startAt.percentage)) {
|
|
70
72
|
log_1.default.debug("Init: using startAt.percentage");
|
|
71
73
|
var percentage = startAt.percentage;
|
|
@@ -38,11 +38,6 @@ export type IInitialPlayEvent =
|
|
|
38
38
|
export interface IInitialSeekAndPlayObject {
|
|
39
39
|
/** Emit the result of the auto-play operation, once performed. */
|
|
40
40
|
autoPlayResult: Promise<IInitialPlayEvent>;
|
|
41
|
-
/**
|
|
42
|
-
* Shared reference whose value becomes `true` once the initial seek has
|
|
43
|
-
* been considered / has been done by `performInitialSeekAndPlay`.
|
|
44
|
-
*/
|
|
45
|
-
initialSeekPerformed: IReadOnlySharedReference<boolean>;
|
|
46
41
|
/**
|
|
47
42
|
* Shared reference whose value becomes `true` once the initial play has
|
|
48
43
|
* been considered / has been done by `performInitialSeekAndPlay`.
|
|
@@ -52,12 +47,15 @@ export interface IInitialSeekAndPlayObject {
|
|
|
52
47
|
/**
|
|
53
48
|
* Seek as soon as possible at the initially wanted position and play if
|
|
54
49
|
* autoPlay is wanted.
|
|
55
|
-
* @param {
|
|
56
|
-
* @param {Object} playbackObserver
|
|
57
|
-
* @param {number|Function} startTime
|
|
58
|
-
* @param {boolean} mustAutoPlay
|
|
59
|
-
* @param {Function} onWarning
|
|
50
|
+
* @param {Object} args
|
|
60
51
|
* @param {Object} cancelSignal
|
|
61
52
|
* @returns {Object}
|
|
62
53
|
*/
|
|
63
|
-
export default function performInitialSeekAndPlay(mediaElement
|
|
54
|
+
export default function performInitialSeekAndPlay({ mediaElement, playbackObserver, startTime, mustAutoPlay, isDirectfile, onWarning }: {
|
|
55
|
+
mediaElement: HTMLMediaElement;
|
|
56
|
+
playbackObserver: PlaybackObserver;
|
|
57
|
+
startTime: number | (() => number);
|
|
58
|
+
mustAutoPlay: boolean;
|
|
59
|
+
isDirectfile: boolean;
|
|
60
|
+
onWarning: (err: IPlayerError) => void;
|
|
61
|
+
}, cancelSignal: CancellationSignal): IInitialSeekAndPlayObject;
|
|
@@ -16,116 +16,146 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
var compat_1 = require("../../../compat");
|
|
19
|
-
var browser_compatibility_types_1 = require("../../../compat/browser_compatibility_types");
|
|
20
19
|
var errors_1 = require("../../../errors");
|
|
21
20
|
var log_1 = require("../../../log");
|
|
22
21
|
var reference_1 = require("../../../utils/reference");
|
|
23
22
|
/**
|
|
24
23
|
* Seek as soon as possible at the initially wanted position and play if
|
|
25
24
|
* autoPlay is wanted.
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {Object} playbackObserver
|
|
28
|
-
* @param {number|Function} startTime
|
|
29
|
-
* @param {boolean} mustAutoPlay
|
|
30
|
-
* @param {Function} onWarning
|
|
25
|
+
* @param {Object} args
|
|
31
26
|
* @param {Object} cancelSignal
|
|
32
27
|
* @returns {Object}
|
|
33
28
|
*/
|
|
34
|
-
function performInitialSeekAndPlay(
|
|
35
|
-
var
|
|
36
|
-
var rejectAutoPlay;
|
|
37
|
-
var autoPlayResult = new Promise(function (res, rej) {
|
|
38
|
-
resolveAutoPlay = res;
|
|
39
|
-
rejectAutoPlay = rej;
|
|
40
|
-
});
|
|
41
|
-
var initialSeekPerformed = new reference_1.default(false, cancelSignal);
|
|
29
|
+
function performInitialSeekAndPlay(_a, cancelSignal) {
|
|
30
|
+
var mediaElement = _a.mediaElement, playbackObserver = _a.playbackObserver, startTime = _a.startTime, mustAutoPlay = _a.mustAutoPlay, isDirectfile = _a.isDirectfile, onWarning = _a.onWarning;
|
|
42
31
|
var initialPlayPerformed = new reference_1.default(false, cancelSignal);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var initialTime = typeof startTime === "function" ? startTime() :
|
|
55
|
-
startTime;
|
|
56
|
-
log_1.default.info("Init: Set initial time", initialTime);
|
|
57
|
-
playbackObserver.setCurrentTime(initialTime);
|
|
58
|
-
initialSeekPerformed.setValue(true);
|
|
59
|
-
initialSeekPerformed.finish();
|
|
60
|
-
if ((0, compat_1.shouldValidateMetadata)() && mediaElement.duration === 0) {
|
|
61
|
-
var error = new errors_1.MediaError("MEDIA_ERR_NOT_LOADED_METADATA", "Cannot load automatically: your browser " +
|
|
62
|
-
"falsely announced having loaded the content.");
|
|
63
|
-
onWarning(error);
|
|
32
|
+
var autoPlayResult = new Promise(function (resolveAutoPlay, rejectAutoPlay) {
|
|
33
|
+
// `startTime` defined as a function might depend on metadata to make its
|
|
34
|
+
// choice, such as the content duration, minimum and/or maximum position.
|
|
35
|
+
//
|
|
36
|
+
// The RxPlayer might already know those through the Manifest file for
|
|
37
|
+
// non-Directfile contents, yet only through the `HTMLMediaElement` once a
|
|
38
|
+
// a sufficient `readyState` has been reached for directfile contents.
|
|
39
|
+
// So let's divide the two possibilities here.
|
|
40
|
+
if (!isDirectfile || typeof startTime === "number") {
|
|
41
|
+
playbackObserver.setCurrentTime(typeof startTime === "number" ? startTime : startTime());
|
|
42
|
+
waitForSeekable();
|
|
64
43
|
}
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
else {
|
|
45
|
+
playbackObserver.listen(function (obs, stopListening) {
|
|
46
|
+
if (obs.readyState >= 1) {
|
|
47
|
+
stopListening();
|
|
48
|
+
playbackObserver.setCurrentTime(typeof startTime === "number" ? startTime : startTime());
|
|
49
|
+
waitForSeekable();
|
|
50
|
+
}
|
|
51
|
+
}, { includeLastObservation: true, clearSignal: cancelSignal });
|
|
67
52
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
var deregisterCancellation = cancelSignal.register(function (err) {
|
|
54
|
+
rejectAutoPlay(err);
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Logic that should be run once the initial seek has been asked to the
|
|
58
|
+
* PlaybackObserver.
|
|
59
|
+
*
|
|
60
|
+
* Actually wait until the seek has been performed, wait for the right moment
|
|
61
|
+
* to perform autoplay, resolve the promise once everything has been done and
|
|
62
|
+
* potentially send warning if a minor issue is detected.
|
|
63
|
+
*/
|
|
64
|
+
function waitForSeekable() {
|
|
65
|
+
playbackObserver.listen(function (obs, stopListening) {
|
|
66
|
+
if (obs.seeking === 0 /* SeekingState.None */ || obs.readyState === 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
72
69
|
stopListening();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"Media will play as soon as possible.");
|
|
84
|
-
}
|
|
85
|
-
initialPlayPerformed.setValue(true);
|
|
86
|
-
initialPlayPerformed.finish();
|
|
87
|
-
deregisterCancellation();
|
|
88
|
-
return resolveAutoPlay({ type: "skipped" });
|
|
89
|
-
}
|
|
90
|
-
var playResult;
|
|
91
|
-
try {
|
|
92
|
-
playResult = (_a = mediaElement.play()) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
70
|
+
if ((0, compat_1.shouldValidateMetadata)() && mediaElement.duration === 0) {
|
|
71
|
+
var error = new errors_1.MediaError("MEDIA_ERR_NOT_LOADED_METADATA", "Cannot load automatically: your browser " +
|
|
72
|
+
"falsely announced having loaded the content.");
|
|
73
|
+
onWarning(error);
|
|
74
|
+
}
|
|
75
|
+
if (cancelSignal.isCancelled()) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
waitForPlayable();
|
|
79
|
+
}, { includeLastObservation: true, clearSignal: cancelSignal });
|
|
93
80
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Logic that should be run once the initial seek has been properly performed.
|
|
83
|
+
*
|
|
84
|
+
* Wait for the media being playable before performing the autoplay operation
|
|
85
|
+
* if asked. Potentially send warning if a minor issue has been detected while
|
|
86
|
+
* doing so.
|
|
87
|
+
*/
|
|
88
|
+
function waitForPlayable() {
|
|
89
|
+
playbackObserver.listen(function (observation, stopListening) {
|
|
90
|
+
if (observation.seeking === 0 /* SeekingState.None */ &&
|
|
91
|
+
observation.rebuffering === null &&
|
|
92
|
+
observation.readyState >= 1) {
|
|
93
|
+
stopListening();
|
|
94
|
+
onPlayable();
|
|
95
|
+
}
|
|
96
|
+
}, { includeLastObservation: true, clearSignal: cancelSignal });
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Callback called once the content is considered "playable".
|
|
100
|
+
*
|
|
101
|
+
* Perform the autoplay if needed, handling potential issues and resolve the
|
|
102
|
+
* Promise when done.
|
|
103
|
+
* Might also send warnings if minor issues arise.
|
|
104
|
+
*/
|
|
105
|
+
function onPlayable() {
|
|
106
|
+
var _a;
|
|
107
|
+
log_1.default.info("Init: Can begin to play content");
|
|
108
|
+
if (!mustAutoPlay) {
|
|
109
|
+
if (mediaElement.autoplay) {
|
|
110
|
+
log_1.default.warn("Init: autoplay is enabled on HTML media element. " +
|
|
111
|
+
"Media will play as soon as possible.");
|
|
112
|
+
}
|
|
113
|
+
initialPlayPerformed.setValue(true);
|
|
114
|
+
initialPlayPerformed.finish();
|
|
115
|
+
deregisterCancellation();
|
|
116
|
+
return resolveAutoPlay({ type: "skipped" });
|
|
102
117
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return resolveAutoPlay({ type: "autoplay" });
|
|
107
|
-
})
|
|
108
|
-
.catch(function (playError) {
|
|
109
|
-
deregisterCancellation();
|
|
110
|
-
if (cancelSignal.isCancelled()) {
|
|
111
|
-
return;
|
|
118
|
+
var playResult;
|
|
119
|
+
try {
|
|
120
|
+
playResult = (_a = mediaElement.play()) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
112
121
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onWarning(error);
|
|
122
|
+
catch (playError) {
|
|
123
|
+
deregisterCancellation();
|
|
124
|
+
return rejectAutoPlay(playError);
|
|
125
|
+
}
|
|
126
|
+
playResult
|
|
127
|
+
.then(function () {
|
|
120
128
|
if (cancelSignal.isCancelled()) {
|
|
121
129
|
return;
|
|
122
130
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
initialPlayPerformed.setValue(true);
|
|
132
|
+
initialPlayPerformed.finish();
|
|
133
|
+
deregisterCancellation();
|
|
134
|
+
return resolveAutoPlay({ type: "autoplay" });
|
|
135
|
+
})
|
|
136
|
+
.catch(function (playError) {
|
|
137
|
+
deregisterCancellation();
|
|
138
|
+
if (cancelSignal.isCancelled()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (playError instanceof Error && playError.name === "NotAllowedError") {
|
|
142
|
+
// auto-play was probably prevented.
|
|
143
|
+
log_1.default.warn("Init: Media element can't play." +
|
|
144
|
+
" It may be due to browser auto-play policies.");
|
|
145
|
+
var error = new errors_1.MediaError("MEDIA_ERR_BLOCKED_AUTOPLAY", "Cannot trigger auto-play automatically: " +
|
|
146
|
+
"your browser does not allow it.");
|
|
147
|
+
onWarning(error);
|
|
148
|
+
if (cancelSignal.isCancelled()) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
return resolveAutoPlay({ type: "autoplay-blocked" });
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
rejectAutoPlay(playError);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return { autoPlayResult: autoPlayResult, initialPlayPerformed: initialPlayPerformed };
|
|
130
160
|
}
|
|
131
161
|
exports.default = performInitialSeekAndPlay;
|