@amazon/vinyl 3.0.0 → 3.1.0
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/dist/index.cjs +987 -969
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +665 -638
- package/dist/index.js.map +4 -4
- package/dist/test/benchmark.js.map +2 -2
- package/dist/test/integ.es5.js +357 -353
- package/dist/test/integ.js +2361 -1870
- package/dist/test/integ.js.map +4 -4
- package/dist/test/jasmine.css +50 -3
- package/dist/test/jasmineHtml.es5.js +195 -155
- package/dist/test/jasmineHtml.js +2938 -1833
- package/dist/test/jasmineHtml.js.map +3 -3
- package/dist/types/current/ad/AdControllerImpl.d.ts.map +1 -1
- package/dist/types/current/ad/AdControllerImpl.js +4 -1
- package/dist/types/current/ad/discoverHlsInterstitials.d.ts.map +1 -1
- package/dist/types/current/ad/discoverHlsInterstitials.js +2 -2
- package/dist/types/current/drm/DrmControllerImpl.d.ts +2 -0
- package/dist/types/current/drm/DrmControllerImpl.d.ts.map +1 -1
- package/dist/types/current/drm/DrmControllerImpl.js +56 -48
- package/dist/types/current/drm/licenseProvider/defaultLicenseProvider.d.ts.map +1 -1
- package/dist/types/current/drm/licenseProvider/defaultLicenseProvider.js +2 -2
- package/dist/types/current/index.d.ts +3 -6
- package/dist/types/current/index.d.ts.map +1 -1
- package/dist/types/current/index.js +3 -6
- package/dist/types/current/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/current/playback/PlaybackControllerImpl.d.ts.map +1 -1
- package/dist/types/current/playback/PlaybackControllerImpl.js +100 -9
- package/dist/types/current/playback/ReadonlyPlaybackController.d.ts +27 -1
- package/dist/types/current/playback/ReadonlyPlaybackController.d.ts.map +1 -1
- package/dist/types/current/playback/ReadonlyPlaybackController.js +16 -0
- package/dist/types/current/playback/createStallDetector.d.ts +43 -0
- package/dist/types/current/playback/createStallDetector.d.ts.map +1 -0
- package/dist/types/current/playback/createStallDetector.js +101 -0
- package/dist/types/current/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/current/playback/createStallMonitor.d.ts.map +1 -0
- package/dist/types/current/playback/createStallMonitor.js +94 -0
- package/dist/types/current/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/current/streaming/AudioOptions.d.ts.map +1 -1
- package/dist/types/current/streaming/AudioOptions.js +5 -1
- package/dist/types/current/streaming/ContentStream.d.ts +0 -5
- package/dist/types/current/streaming/ContentStream.d.ts.map +1 -1
- package/dist/types/current/streaming/ContentStream.js +0 -4
- package/dist/types/current/streaming/LoadMetric.d.ts.map +1 -1
- package/dist/types/current/streaming/StreamingEventMap.d.ts +1 -5
- package/dist/types/current/streaming/StreamingEventMap.d.ts.map +1 -1
- package/dist/types/current/streaming/StreamingEventMap.js +0 -1
- package/dist/types/current/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/current/streaming/buffering/BufferingController.d.ts.map +1 -1
- package/dist/types/current/streaming/buffering/BufferingController.js +0 -13
- package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.d.ts.map +1 -1
- package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.js +13 -4
- package/dist/types/current/text/SidecarTextTrackLoader.d.ts.map +1 -1
- package/dist/types/current/text/SidecarTextTrackLoader.js +4 -4
- package/dist/types/current/text/TextTrack.d.ts.map +1 -1
- package/dist/types/current/track/TrackController.d.ts.map +1 -1
- package/dist/types/current/track/TrackController.js +38 -32
- package/dist/types/current/track/createSegmentDataProvider.d.ts.map +1 -1
- package/dist/types/current/track/createSegmentDataProvider.js +6 -3
- package/dist/types/current/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/current/track/dash/DashMediaQualityMetadataResolver.d.ts.map +1 -1
- package/dist/types/current/track/dash/DashMediaQualityMetadataResolver.js +13 -8
- package/dist/types/current/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/current/track/dash/timeline/DashRepresentationSegmentProvider.d.ts.map +1 -1
- package/dist/types/current/track/dash/timeline/DashRepresentationSegmentProvider.js +71 -3
- package/dist/types/current/track/dash/urlDashManifestProvider.js +2 -2
- package/dist/types/current/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/current/track/dash/util/mpd.d.ts.map +1 -1
- package/dist/types/current/track/dash/util/mpd.js +24 -3
- package/dist/types/current/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/current/track/filters/resourceTypeFilter.d.ts.map +1 -1
- package/dist/types/current/track/filters/resourceTypeFilter.js +4 -0
- package/dist/types/current/track/filters/sampleRateFilter.d.ts +21 -7
- package/dist/types/current/track/filters/sampleRateFilter.d.ts.map +1 -1
- package/dist/types/current/track/filters/sampleRateFilter.js +42 -24
- package/dist/types/current/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/current/track/hls/createUrlHlsManifestProvider.d.ts.map +1 -1
- package/dist/types/current/track/hls/createUrlHlsManifestProvider.js +3 -3
- package/dist/types/current/track/mse/MseTrack.d.ts +9 -17
- package/dist/types/current/track/mse/MseTrack.d.ts.map +1 -1
- package/dist/types/current/track/mse/MseTrack.js +29 -46
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/util/media/mimeType.d.ts +8 -0
- package/dist/types/current/util/media/mimeType.d.ts.map +1 -0
- package/dist/types/current/util/media/mimeType.js +13 -0
- package/dist/types/current/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/types/current/vinyl/createVinylFactories.d.ts.map +1 -1
- package/dist/types/current/vinyl/createVinylFactories.js +2 -12
- package/dist/types/ts3.7/drm/DrmControllerImpl.d.ts +2 -0
- package/dist/types/ts3.7/index.d.ts +3 -6
- package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/ts3.7/playback/ReadonlyPlaybackController.d.ts +28 -0
- package/dist/types/ts3.7/playback/createStallDetector.d.ts +43 -0
- package/dist/types/ts3.7/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/ts3.7/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/ts3.7/streaming/ContentStream.d.ts +0 -5
- package/dist/types/ts3.7/streaming/StreamingEventMap.d.ts +0 -5
- package/dist/types/ts3.7/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/ts3.7/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/ts3.7/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/ts3.7/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/ts3.7/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/ts3.7/track/filters/sampleRateFilter.d.ts +21 -7
- package/dist/types/ts3.7/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/ts3.7/track/mse/MseTrack.d.ts +9 -17
- package/dist/types/ts3.7/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts3.7/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/types/ts4.1/drm/DrmControllerImpl.d.ts +2 -0
- package/dist/types/ts4.1/index.d.ts +3 -6
- package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/ts4.1/playback/ReadonlyPlaybackController.d.ts +28 -0
- package/dist/types/ts4.1/playback/createStallDetector.d.ts +43 -0
- package/dist/types/ts4.1/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/ts4.1/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/ts4.1/streaming/ContentStream.d.ts +0 -5
- package/dist/types/ts4.1/streaming/StreamingEventMap.d.ts +0 -5
- package/dist/types/ts4.1/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/ts4.1/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/ts4.1/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/ts4.1/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/ts4.1/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/ts4.1/track/filters/sampleRateFilter.d.ts +21 -7
- package/dist/types/ts4.1/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/ts4.1/track/mse/MseTrack.d.ts +9 -17
- package/dist/types/ts4.1/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.1/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/types/ts4.7/drm/DrmControllerImpl.d.ts +2 -0
- package/dist/types/ts4.7/index.d.ts +3 -6
- package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/ts4.7/playback/ReadonlyPlaybackController.d.ts +28 -0
- package/dist/types/ts4.7/playback/createStallDetector.d.ts +43 -0
- package/dist/types/ts4.7/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/ts4.7/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/ts4.7/streaming/ContentStream.d.ts +0 -5
- package/dist/types/ts4.7/streaming/StreamingEventMap.d.ts +0 -5
- package/dist/types/ts4.7/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/ts4.7/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/ts4.7/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/ts4.7/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/ts4.7/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/ts4.7/track/filters/sampleRateFilter.d.ts +21 -7
- package/dist/types/ts4.7/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/ts4.7/track/mse/MseTrack.d.ts +9 -17
- package/dist/types/ts4.7/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.7/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/unit/types/current/ad/AdControllerImpl.test.js +27 -1
- package/dist/unit/types/current/drm/DrmControllerImpl.test.js +93 -0
- package/dist/unit/types/current/index.d.ts +3 -4
- package/dist/unit/types/current/index.d.ts.map +1 -1
- package/dist/unit/types/current/index.js +3 -4
- package/dist/unit/types/current/playback/PlaybackControllerImpl.test.js +165 -0
- package/dist/unit/types/current/playback/createStallDetector.test.d.ts +2 -0
- package/dist/unit/types/current/playback/createStallDetector.test.d.ts.map +1 -0
- package/dist/unit/types/current/playback/createStallDetector.test.js +163 -0
- package/dist/unit/types/current/playback/createStallMonitor.test.d.ts +2 -0
- package/dist/unit/types/current/playback/createStallMonitor.test.d.ts.map +1 -0
- package/dist/unit/types/current/playback/createStallMonitor.test.js +125 -0
- package/dist/unit/types/current/streaming/ContentStream.test.js +0 -11
- package/dist/unit/types/current/streaming/MseTrack.test.js +47 -74
- package/dist/unit/types/current/streaming/abr/QualitySelectorImpl.test.js +1 -1
- package/dist/unit/types/current/streaming/buffering/BufferingController.test.js +0 -21
- package/dist/unit/types/current/streaming/createDefaultMediaTimelineTransformer.test.js +133 -0
- package/dist/unit/types/current/track/TrackController.test.js +97 -1
- package/dist/unit/types/current/track/createSegmentDataProvider.test.js +18 -0
- package/dist/unit/types/current/track/dash/DashMediaQualityMetadataResolver.test.js +46 -14
- package/dist/unit/types/current/track/dash/createSegmentControllerFactory.test.js +1 -0
- package/dist/unit/types/current/track/dash/timeline/DashRepresentationSegmentProvider.test.js +114 -0
- package/dist/unit/types/current/track/dash/util/mpd.test.js +37 -0
- package/dist/unit/types/current/track/filters/resourceTypeFilter.test.js +7 -0
- package/dist/unit/types/current/track/filters/sampleRateFilter.test.js +136 -34
- package/dist/unit/types/current/track/source/SourceObjectTrack.test.js +1 -1
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/unit/types/current/util/media/mimeType.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/mimeType.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/mimeType.test.js +22 -0
- package/dist/unit/types/current/vinyl/createVinylFactories.test.js +2 -36
- package/dist/vinylTestUtil/index.js +6 -4
- package/dist/vinylTestUtil/index.js.map +2 -2
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.js +1 -0
- package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/MockContentStream.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/MockContentStream.js +0 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/buffering/MockBufferingController.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/buffering/MockBufferingController.js +0 -1
- package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/types/current/util/playback/eventPromises.js +1 -1
- package/dist/vinylTestUtil/types/current/util/playback/expectTrackCanSeek.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/util/playback/expectTrackCanSeek.js +9 -1
- package/dist/vinylTestUtil/types/ts3.7/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/ts3.7/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts3.7/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.1/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/ts4.1/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.1/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.7/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/ts4.7/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.7/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/docs/USAGE.md +29 -0
- package/package.json +11 -10
- package/dist/types/current/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/current/patch/media/HtmlMediaElementPatch.d.ts.map +0 -1
- package/dist/types/current/patch/media/HtmlMediaElementPatch.js +0 -5
- package/dist/types/current/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/current/patch/media/MediaElementPatchOptions.d.ts.map +0 -1
- package/dist/types/current/patch/media/MediaElementPatchOptions.js +0 -16
- package/dist/types/current/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/current/patch/media/patchMediaElement.d.ts.map +0 -1
- package/dist/types/current/patch/media/patchMediaElement.js +0 -15
- package/dist/types/current/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/current/patch/media/patches/createPreventStallsPatch.d.ts.map +0 -1
- package/dist/types/current/patch/media/patches/createPreventStallsPatch.js +0 -55
- package/dist/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts.map +0 -1
- package/dist/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.js +0 -218
- package/dist/types/current/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/types/current/vinyl/VinylPatchOptions.d.ts.map +0 -1
- package/dist/types/current/vinyl/VinylPatchOptions.js +0 -11
- package/dist/types/ts3.7/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/ts3.7/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/ts3.7/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/ts3.7/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/ts3.7/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/ts3.7/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/types/ts4.1/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/ts4.1/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/ts4.1/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/ts4.1/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/ts4.1/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/ts4.1/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/types/ts4.7/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/ts4.7/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/ts4.7/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/ts4.7/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/ts4.7/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/ts4.7/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/unit/types/current/patch/media/MediaElementPatchOptions.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/MediaElementPatchOptions.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/MediaElementPatchOptions.test.js +0 -17
- package/dist/unit/types/current/patch/media/patchMediaElement.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/patchMediaElement.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/patchMediaElement.test.js +0 -36
- package/dist/unit/types/current/patch/media/patches/createPreventStallsPatch.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/patches/createPreventStallsPatch.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/patches/createPreventStallsPatch.test.js +0 -93
- package/dist/unit/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.test.js +0 -423
package/dist/index.cjs
CHANGED
|
@@ -74,10 +74,7 @@ __export(index_exports, {
|
|
|
74
74
|
LICENSE_TIMEOUT: () => LICENSE_TIMEOUT,
|
|
75
75
|
LIVE_DURATION: () => LIVE_DURATION,
|
|
76
76
|
LoudnessNormalizationControllerImpl: () => LoudnessNormalizationControllerImpl,
|
|
77
|
-
MAX_UNCHANGED_COUNT: () => MAX_UNCHANGED_COUNT,
|
|
78
77
|
MIN_APPEND_SIZE: () => MIN_APPEND_SIZE,
|
|
79
|
-
MIN_PLAYING_BEFORE_FAB: () => MIN_PLAYING_BEFORE_FAB,
|
|
80
|
-
MIN_STALLED_BEFORE_FAB: () => MIN_STALLED_BEFORE_FAB,
|
|
81
78
|
ManifestControllerImpl: () => ManifestControllerImpl,
|
|
82
79
|
MediaKeySessionErrorType: () => MediaKeySessionErrorType,
|
|
83
80
|
MediaSourceControllerImpl: () => MediaSourceControllerImpl,
|
|
@@ -87,7 +84,6 @@ __export(index_exports, {
|
|
|
87
84
|
MsCommonMediaKeySystemAccess: () => MsCommonMediaKeySystemAccess,
|
|
88
85
|
MsCommonMediaKeys: () => MsCommonMediaKeys,
|
|
89
86
|
MseTrack: () => MseTrack,
|
|
90
|
-
PLAYHEAD_NUDGE: () => PLAYHEAD_NUDGE,
|
|
91
87
|
PLAY_READY_KEY_SYSTEMS: () => PLAY_READY_KEY_SYSTEMS,
|
|
92
88
|
POLL_BUFFER_THROTTLE: () => POLL_BUFFER_THROTTLE,
|
|
93
89
|
PREFETCH_POLL_THROTTLE: () => PREFETCH_POLL_THROTTLE,
|
|
@@ -102,7 +98,6 @@ __export(index_exports, {
|
|
|
102
98
|
READY_TO_APPEND_TIMEOUT: () => READY_TO_APPEND_TIMEOUT,
|
|
103
99
|
RESTRICTABLE_CONTENT_TYPES: () => RESTRICTABLE_CONTENT_TYPES,
|
|
104
100
|
ReportableMediaError: () => ReportableMediaError,
|
|
105
|
-
SEEKING_STALL_TIME_CHECK: () => SEEKING_STALL_TIME_CHECK,
|
|
106
101
|
SEGMENT_START_AFFORDANCE: () => SEGMENT_START_AFFORDANCE,
|
|
107
102
|
SegmentControllerImpl: () => SegmentControllerImpl,
|
|
108
103
|
SegmentDataSlot: () => SegmentDataSlot,
|
|
@@ -113,6 +108,7 @@ __export(index_exports, {
|
|
|
113
108
|
SourceObjectTrack: () => SourceObjectTrack,
|
|
114
109
|
SourceTrack: () => SourceTrack,
|
|
115
110
|
SourceTrackBase: () => SourceTrackBase,
|
|
111
|
+
StallEndedReason: () => StallEndedReason,
|
|
116
112
|
StandardCommonEme: () => StandardCommonEme,
|
|
117
113
|
StandardCommonMediaKeySession: () => StandardCommonMediaKeySession,
|
|
118
114
|
StandardCommonMediaKeySystemAccess: () => StandardCommonMediaKeySystemAccess,
|
|
@@ -120,7 +116,6 @@ __export(index_exports, {
|
|
|
120
116
|
TIMEUPDATE_THROTTLE: () => TIMEUPDATE_THROTTLE,
|
|
121
117
|
TrackBase: () => TrackBase,
|
|
122
118
|
TrackControllerImpl: () => TrackControllerImpl,
|
|
123
|
-
UNRELIABLE_EVENTS_POLL_INTERVAL: () => UNRELIABLE_EVENTS_POLL_INTERVAL,
|
|
124
119
|
UnresolvableAdError: () => UnresolvableAdError,
|
|
125
120
|
VinylGlobal: () => VinylGlobal,
|
|
126
121
|
VinylPlayer: () => VinylPlayer,
|
|
@@ -182,14 +177,14 @@ __export(index_exports, {
|
|
|
182
177
|
createMediaQualityMetadataFromDashRepresentation: () => createMediaQualityMetadataFromDashRepresentation,
|
|
183
178
|
createMediaSource: () => createMediaSource,
|
|
184
179
|
createMediaTextTrackProvider: () => createMediaTextTrackProvider,
|
|
185
|
-
createPreventStallsPatch: () => createPreventStallsPatch,
|
|
186
180
|
createSegmentControllerFactory: () => createSegmentControllerFactory,
|
|
187
181
|
createSegmentDataProvider: () => createSegmentDataProvider,
|
|
188
182
|
createSourceObjectTrackFactory: () => createSourceObjectTrackFactory,
|
|
189
183
|
createSourceTrackFactory: () => createSourceTrackFactory,
|
|
184
|
+
createStallDetector: () => createStallDetector,
|
|
185
|
+
createStallMonitor: () => createStallMonitor,
|
|
190
186
|
createTrackFactory: () => createTrackFactory,
|
|
191
187
|
createTrackLoadOptionsFromUrl: () => createTrackLoadOptionsFromUrl,
|
|
192
|
-
createUnreliablePlaybackEventsPatch: () => createUnreliablePlaybackEventsPatch,
|
|
193
188
|
createUrlHlsManifestProvider: () => createUrlHlsManifestProvider,
|
|
194
189
|
createVinylFactories: () => createVinylFactories,
|
|
195
190
|
createVinylPlayer: () => createVinylPlayer,
|
|
@@ -200,8 +195,6 @@ __export(index_exports, {
|
|
|
200
195
|
defaultDrmKeySystemResolver: () => defaultDrmKeySystemResolver,
|
|
201
196
|
defaultLicenseProvider: () => defaultLicenseProvider,
|
|
202
197
|
defaultLoudnessNormalizationControllerImplOptions: () => defaultLoudnessNormalizationControllerImplOptions,
|
|
203
|
-
defaultMediaElementPatchOptions: () => defaultMediaElementPatchOptions,
|
|
204
|
-
defaultPatchOptions: () => defaultPatchOptions,
|
|
205
198
|
defaultPlaybackControllerImplOptions: () => defaultPlaybackControllerImplOptions,
|
|
206
199
|
defaultQualitySelectorImplOptions: () => defaultQualitySelectorImplOptions,
|
|
207
200
|
defaultResetControllerOptions: () => defaultResetControllerOptions,
|
|
@@ -271,6 +264,7 @@ __export(index_exports, {
|
|
|
271
264
|
mediaFormatMetadataValidator: () => mediaFormatMetadataValidator,
|
|
272
265
|
mediaKeySupportRef: () => mediaKeySupportRef,
|
|
273
266
|
mediaQualityMetadataValidator: () => mediaQualityMetadataValidator,
|
|
267
|
+
mimeSubtype: () => mimeSubtype,
|
|
274
268
|
msErrorCodeToStr: () => msErrorCodeToStr,
|
|
275
269
|
nextHasMetadata: () => nextHasMetadata,
|
|
276
270
|
nextMediaSourceEnded: () => nextMediaSourceEnded,
|
|
@@ -281,7 +275,6 @@ __export(index_exports, {
|
|
|
281
275
|
parseCencEncryptionScheme: () => parseCencEncryptionScheme,
|
|
282
276
|
parsePlayReadyKeyMessage: () => parsePlayReadyKeyMessage,
|
|
283
277
|
parseWebVtt: () => parseWebVtt,
|
|
284
|
-
patchMediaElement: () => patchMediaElement,
|
|
285
278
|
pickFirstBaseUrlSelector: () => pickFirstBaseUrlSelector,
|
|
286
279
|
pickPreferredTextTrack: () => pickPreferredTextTrack,
|
|
287
280
|
playbackStateLoggingHandler: () => playbackStateLoggingHandler,
|
|
@@ -291,8 +284,6 @@ __export(index_exports, {
|
|
|
291
284
|
prefetchPriorityQueuesRef: () => prefetchPriorityQueuesRef,
|
|
292
285
|
qualitySelectorImplOptionsValidator: () => qualitySelectorImplOptionsValidator,
|
|
293
286
|
renderCueText: () => renderCueText,
|
|
294
|
-
requiresPreventStallsPatch: () => requiresPreventStallsPatch,
|
|
295
|
-
requiresUnreliablePlaybackEventsPatch: () => requiresUnreliablePlaybackEventsPatch,
|
|
296
287
|
resolveCodecOverride: () => resolveCodecOverride,
|
|
297
288
|
resolveDashUri: () => resolveDashUri,
|
|
298
289
|
resolvePreferredLanguages: () => resolvePreferredLanguages,
|
|
@@ -303,7 +294,6 @@ __export(index_exports, {
|
|
|
303
294
|
sortDashAdaptationSets: () => sortDashAdaptationSets,
|
|
304
295
|
sortDashRepresentations: () => sortDashRepresentations,
|
|
305
296
|
sourceTrackBaseOptionsValidator: () => sourceTrackBaseOptionsValidator,
|
|
306
|
-
supportsAudioSamplingRate: () => supportsAudioSamplingRate,
|
|
307
297
|
supportsMsEme: () => supportsMsEme,
|
|
308
298
|
supportsMse: () => supportsMse,
|
|
309
299
|
supportsStandardEme: () => supportsStandardEme,
|
|
@@ -324,7 +314,8 @@ __export(index_exports, {
|
|
|
324
314
|
vinylVersion: () => vinylVersion,
|
|
325
315
|
vttCueStyleValidator: () => vttCueStyleValidator,
|
|
326
316
|
waitedReasons: () => waitedReasons,
|
|
327
|
-
webkitErrorCodeToStr: () => webkitErrorCodeToStr
|
|
317
|
+
webkitErrorCodeToStr: () => webkitErrorCodeToStr,
|
|
318
|
+
withinAudioSampleRateRange: () => withinAudioSampleRateRange
|
|
328
319
|
});
|
|
329
320
|
module.exports = __toCommonJS(index_exports);
|
|
330
321
|
|
|
@@ -530,7 +521,7 @@ var AdControllerImpl = class extends import_vinyl_util2.EventHostImpl {
|
|
|
530
521
|
*/
|
|
531
522
|
providerInterrupted() {
|
|
532
523
|
const provider = this.adsProvider;
|
|
533
|
-
return () => provider !== this.adsProvider;
|
|
524
|
+
return () => this.disposed || provider !== this.adsProvider;
|
|
534
525
|
}
|
|
535
526
|
setAdsProvider(provider) {
|
|
536
527
|
var _a;
|
|
@@ -909,7 +900,9 @@ var AdControllerImpl = class extends import_vinyl_util2.EventHostImpl {
|
|
|
909
900
|
* Disposes this controller, removes all listeners.
|
|
910
901
|
*/
|
|
911
902
|
dispose() {
|
|
903
|
+
var _a;
|
|
912
904
|
super.dispose();
|
|
905
|
+
(_a = this.adsProviderSub) == null ? void 0 : _a.call(this);
|
|
913
906
|
this.disposer.dispose();
|
|
914
907
|
this.adBreakState = null;
|
|
915
908
|
}
|
|
@@ -1218,7 +1211,7 @@ async function resolveHlsAssetList({
|
|
|
1218
1211
|
var _a;
|
|
1219
1212
|
const url = (0, import_vinyl_util5.resolveUrl)(assetListUrl, baseUrl);
|
|
1220
1213
|
const response = await (0, import_vinyl_util5.requestWithRetry)(url);
|
|
1221
|
-
const json = await response
|
|
1214
|
+
const json = await (0, import_vinyl_util5.readResponseBody)(response, "json");
|
|
1222
1215
|
const assets = (_a = json.ASSETS) != null ? _a : [];
|
|
1223
1216
|
const ads = assets.map((asset, i) => {
|
|
1224
1217
|
var _a2;
|
|
@@ -2047,7 +2040,7 @@ var defaultLicenseProvider = async (keySystem, serverOptions, challenge, abort)
|
|
|
2047
2040
|
}),
|
|
2048
2041
|
{ abort }
|
|
2049
2042
|
);
|
|
2050
|
-
return await res
|
|
2043
|
+
return await (0, import_vinyl_util19.readResponseBody)(res, "arrayBuffer");
|
|
2051
2044
|
};
|
|
2052
2045
|
|
|
2053
2046
|
// src/drm/util/extractContentId.ts
|
|
@@ -2145,6 +2138,11 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2145
2138
|
));
|
|
2146
2139
|
__publicField(this, "handleEncryptedEvent", (event) => {
|
|
2147
2140
|
if (this.disposed) return;
|
|
2141
|
+
if (this.manifestProvidesInitData()) {
|
|
2142
|
+
(0, import_vinyl_util24.logDebug)(this, "ignoring encrypted event; manifest provides pssh");
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
;
|
|
2148
2146
|
(async () => {
|
|
2149
2147
|
var _a;
|
|
2150
2148
|
const { initData, initDataType } = event;
|
|
@@ -2266,7 +2264,7 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2266
2264
|
* The new session will be added to the current sessions list.
|
|
2267
2265
|
*/
|
|
2268
2266
|
async maybeCreateSession(options) {
|
|
2269
|
-
var _a;
|
|
2267
|
+
var _a, _b;
|
|
2270
2268
|
const { drmInfo, initDataType, initData, trackUri, abort } = options;
|
|
2271
2269
|
if (!hasMimeType(drmInfo)) {
|
|
2272
2270
|
throw new DrmError("Encrypted content must have a mimeType.");
|
|
@@ -2279,33 +2277,41 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2279
2277
|
licenseServerOptionsProvider != null ? licenseServerOptionsProvider : {}
|
|
2280
2278
|
);
|
|
2281
2279
|
this.abortIfDisposed();
|
|
2282
|
-
const
|
|
2280
|
+
const certBytes = toCertBytes(licenseServerOptions.serverCertificate);
|
|
2281
|
+
if (certBytes) {
|
|
2282
|
+
await mediaKeys.setServerCertificate(certBytes);
|
|
2283
|
+
this.abortIfDisposed();
|
|
2284
|
+
}
|
|
2285
|
+
const transform = (_b = keySystemOptions == null ? void 0 : keySystemOptions.initDataTransformer) != null ? _b : defaultInitDataTransformer(mediaKeys.keySystem, certBytes);
|
|
2286
|
+
const transformedInitData = transform(
|
|
2287
|
+
(0, import_vinyl_util24.bufferToByteArray)(initData),
|
|
2288
|
+
initDataType,
|
|
2289
|
+
drmInfo
|
|
2290
|
+
);
|
|
2291
|
+
const existingSession = this.getSessionByInitData(transformedInitData);
|
|
2283
2292
|
if (existingSession) {
|
|
2284
2293
|
(0, import_vinyl_util24.logDebug)(this, "reusing session");
|
|
2285
2294
|
return existingSession;
|
|
2286
|
-
} else {
|
|
2287
|
-
const newSession = await this.createNewSession({
|
|
2288
|
-
serverCertificate: licenseServerOptions.serverCertificate,
|
|
2289
|
-
mediaKeys,
|
|
2290
|
-
initData,
|
|
2291
|
-
initDataType,
|
|
2292
|
-
drmInfo,
|
|
2293
|
-
trackUri,
|
|
2294
|
-
initDataTransformer: keySystemOptions == null ? void 0 : keySystemOptions.initDataTransformer
|
|
2295
|
-
});
|
|
2296
|
-
this.sessions.push(newSession);
|
|
2297
|
-
this.dispatch("sessionCreate", {
|
|
2298
|
-
initDataType: newSession.initDataType,
|
|
2299
|
-
mimeType: newSession.mimeType
|
|
2300
|
-
});
|
|
2301
|
-
newSession.on("closed", () => this.closeSession(newSession));
|
|
2302
|
-
abort == null ? void 0 : abort.onAborted(() => {
|
|
2303
|
-
if (this.disposed) return;
|
|
2304
|
-
(0, import_vinyl_util24.logDebug)(this, "abort session");
|
|
2305
|
-
this.closeSession(newSession);
|
|
2306
|
-
});
|
|
2307
|
-
return newSession;
|
|
2308
2295
|
}
|
|
2296
|
+
const newSession = this.createNewSession({
|
|
2297
|
+
mediaKeys,
|
|
2298
|
+
initData: transformedInitData,
|
|
2299
|
+
initDataType,
|
|
2300
|
+
drmInfo,
|
|
2301
|
+
trackUri
|
|
2302
|
+
});
|
|
2303
|
+
this.sessions.push(newSession);
|
|
2304
|
+
this.dispatch("sessionCreate", {
|
|
2305
|
+
initDataType: newSession.initDataType,
|
|
2306
|
+
mimeType: newSession.mimeType
|
|
2307
|
+
});
|
|
2308
|
+
newSession.on("closed", () => this.closeSession(newSession));
|
|
2309
|
+
abort == null ? void 0 : abort.onAborted(() => {
|
|
2310
|
+
if (this.disposed) return;
|
|
2311
|
+
(0, import_vinyl_util24.logDebug)(this, "abort session");
|
|
2312
|
+
this.closeSession(newSession);
|
|
2313
|
+
});
|
|
2314
|
+
return newSession;
|
|
2309
2315
|
}
|
|
2310
2316
|
initializeForPlayback(drmInfo, options) {
|
|
2311
2317
|
var _a;
|
|
@@ -2318,6 +2324,11 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2318
2324
|
).catch(this.handleError);
|
|
2319
2325
|
}
|
|
2320
2326
|
}
|
|
2327
|
+
/** True when the manifest carried pssh (sessions come from it, not events). */
|
|
2328
|
+
manifestProvidesInitData() {
|
|
2329
|
+
var _a, _b;
|
|
2330
|
+
return (_b = (_a = this.drmInfo) == null ? void 0 : _a.contentProtections.some((cP) => cP.pssh != null)) != null ? _b : false;
|
|
2331
|
+
}
|
|
2321
2332
|
setBufferingDrmInfo(drmInfo, options) {
|
|
2322
2333
|
var _a, _b;
|
|
2323
2334
|
(0, import_vinyl_util24.logDebug)(this, "setBufferingDrmInfo", drmInfo);
|
|
@@ -2457,24 +2468,10 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2457
2468
|
/**
|
|
2458
2469
|
* Creates a new key session and adds a message handler.
|
|
2459
2470
|
*/
|
|
2460
|
-
|
|
2461
|
-
const {
|
|
2462
|
-
serverCertificate,
|
|
2463
|
-
mediaKeys,
|
|
2464
|
-
initDataType,
|
|
2465
|
-
drmInfo,
|
|
2466
|
-
trackUri,
|
|
2467
|
-
initDataTransformer
|
|
2468
|
-
} = options;
|
|
2469
|
-
let initData = options.initData;
|
|
2470
|
-
const certBytes = serverCertificate ? typeof serverCertificate === "string" ? (0, import_vinyl_util24.base64ToByteArray)(serverCertificate) : (0, import_vinyl_util24.bufferToByteArray)(serverCertificate) : null;
|
|
2471
|
-
if (certBytes) {
|
|
2472
|
-
await mediaKeys.setServerCertificate(certBytes);
|
|
2473
|
-
}
|
|
2474
|
-
const transform = initDataTransformer != null ? initDataTransformer : defaultInitDataTransformer(mediaKeys.keySystem, certBytes);
|
|
2475
|
-
initData = transform((0, import_vinyl_util24.bufferToByteArray)(initData), initDataType, drmInfo);
|
|
2471
|
+
createNewSession(options) {
|
|
2472
|
+
const { mediaKeys, initData, initDataType, drmInfo, trackUri } = options;
|
|
2476
2473
|
this.abortIfDisposed();
|
|
2477
|
-
(0, import_vinyl_util24.logDebug)(this, "createSession", drmInfo.mimeType, initDataType);
|
|
2474
|
+
(0, import_vinyl_util24.logDebug)(this, "createSession", drmInfo.mimeType, initDataType, drmInfo);
|
|
2478
2475
|
const session = mediaKeys.createSession(
|
|
2479
2476
|
drmInfo.mimeType,
|
|
2480
2477
|
initDataType,
|
|
@@ -2504,15 +2501,15 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2504
2501
|
* Invoked when the content decryption module needs to interact with the license server.
|
|
2505
2502
|
*/
|
|
2506
2503
|
async messageHandler(messageProps) {
|
|
2507
|
-
var _a, _b;
|
|
2504
|
+
var _a, _b, _c;
|
|
2508
2505
|
const { mediaKeys, session, event } = messageProps;
|
|
2509
2506
|
messageEventValidator.assert(event);
|
|
2510
2507
|
this.pendingMessageProps = messageProps;
|
|
2511
2508
|
const keySystem = mediaKeys.keySystem;
|
|
2512
2509
|
(0, import_vinyl_util24.logDebug)(this, "message", keySystem, event.message.byteLength);
|
|
2513
|
-
const keySystemOptions = this.options.keySystems[keySystem];
|
|
2510
|
+
const keySystemOptions = (_a = this.options.keySystems[keySystem]) != null ? _a : this.options.keySystems["*"];
|
|
2514
2511
|
const licenseServerOptionsProvider = keySystemOptions == null ? void 0 : keySystemOptions.licenseServer;
|
|
2515
|
-
const licenseServerOptions = (
|
|
2512
|
+
const licenseServerOptions = (_b = (0, import_vinyl_util24.clone)(await (0, import_vinyl_util24.resolveValueProvider)(licenseServerOptionsProvider))) != null ? _b : {};
|
|
2516
2513
|
this.abortIfDisposed();
|
|
2517
2514
|
let challenge = event.message;
|
|
2518
2515
|
if (isPlayReady(keySystem)) {
|
|
@@ -2521,7 +2518,7 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2521
2518
|
if (licenseServerOptions.init == null)
|
|
2522
2519
|
licenseServerOptions.init = {};
|
|
2523
2520
|
licenseServerOptions.init.headers = __spreadValues(__spreadValues({}, (0, import_vinyl_util24.normalizeHeadersInit)(
|
|
2524
|
-
(
|
|
2521
|
+
(_c = licenseServerOptions.init.headers) != null ? _c : {}
|
|
2525
2522
|
)), unpacked.headers);
|
|
2526
2523
|
}
|
|
2527
2524
|
const licenseSpanStart = Date.now();
|
|
@@ -2530,6 +2527,7 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2530
2527
|
licenseServerOptions,
|
|
2531
2528
|
challenge
|
|
2532
2529
|
);
|
|
2530
|
+
if (this.disposed) return;
|
|
2533
2531
|
this.dispatch("loadSpanMeasured", __spreadValues({
|
|
2534
2532
|
kind: "license",
|
|
2535
2533
|
startTime: licenseSpanStart,
|
|
@@ -2619,9 +2617,9 @@ var DrmControllerImpl = class extends import_vinyl_util24.EventHostImpl {
|
|
|
2619
2617
|
}
|
|
2620
2618
|
getSessionByInitData(initData) {
|
|
2621
2619
|
var _a;
|
|
2622
|
-
return (_a = this.sessions.find(
|
|
2623
|
-
|
|
2624
|
-
|
|
2620
|
+
return (_a = this.sessions.find(
|
|
2621
|
+
(session) => (0, import_vinyl_util24.buffersEqual)(session.initData, initData)
|
|
2622
|
+
)) != null ? _a : null;
|
|
2625
2623
|
}
|
|
2626
2624
|
};
|
|
2627
2625
|
var messageEventValidator = /* @__PURE__ */ (0, import_vinyl_validation4.object)({
|
|
@@ -2630,6 +2628,10 @@ var messageEventValidator = /* @__PURE__ */ (0, import_vinyl_validation4.object)
|
|
|
2630
2628
|
function hasMimeType(drmInfo) {
|
|
2631
2629
|
return drmInfo.mimeType != null;
|
|
2632
2630
|
}
|
|
2631
|
+
function toCertBytes(serverCertificate) {
|
|
2632
|
+
if (!serverCertificate) return null;
|
|
2633
|
+
return typeof serverCertificate === "string" ? (0, import_vinyl_util24.base64ToByteArray)(serverCertificate) : (0, import_vinyl_util24.bufferToByteArray)(serverCertificate);
|
|
2634
|
+
}
|
|
2633
2635
|
function defaultInitDataTransformer(keySystem, certBytes) {
|
|
2634
2636
|
return (initData) => {
|
|
2635
2637
|
if (keySystem === "com.apple.fps.1_0" /* FAIR_PLAY_1_0 */) {
|
|
@@ -2775,7 +2777,7 @@ function configureVinylGlobal(options) {
|
|
|
2775
2777
|
var import_vinyl_util27 = require("@amazon/vinyl-util");
|
|
2776
2778
|
var vinylVersion = /* @__PURE__ */ (0, import_vinyl_util27.parseVersion)(
|
|
2777
2779
|
/* istanbul ignore next */
|
|
2778
|
-
"3.
|
|
2780
|
+
"3.1.0"
|
|
2779
2781
|
);
|
|
2780
2782
|
|
|
2781
2783
|
// src/global/globalRef.ts
|
|
@@ -2824,232 +2826,231 @@ function initializeVinylGlobal() {
|
|
|
2824
2826
|
vinylGlobalRef.initialize();
|
|
2825
2827
|
}
|
|
2826
2828
|
|
|
2827
|
-
// src/
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
var MIN_SEEKING_DELTA = 0.5;
|
|
2838
|
-
function createUnreliablePlaybackEventsPatch(media) {
|
|
2839
|
-
const { add, dispose } = (0, import_vinyl_util31.createDisposer)();
|
|
2840
|
-
const domEvents = add(new import_vinyl_util31.DomEventHost(media));
|
|
2841
|
-
const eventFabricated = add(new import_vinyl_util31.SignalImpl());
|
|
2842
|
-
let stateChangedAt = Date.now();
|
|
2843
|
-
let currentApparentState = 1 /* STOPPED */;
|
|
2844
|
-
function setApparentState(state, changedAt = Date.now()) {
|
|
2845
|
-
if (currentApparentState !== state) {
|
|
2846
|
-
currentApparentState = state;
|
|
2847
|
-
stateChangedAt = changedAt;
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
function elapsedStateTime() {
|
|
2851
|
-
return (Date.now() - stateChangedAt) / 1e3;
|
|
2852
|
-
}
|
|
2853
|
-
let lastTimestamp = Date.now();
|
|
2829
|
+
// src/playback/createStallDetector.ts
|
|
2830
|
+
function createStallDetector(media, options) {
|
|
2831
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2832
|
+
const { fabricatePlaying } = options;
|
|
2833
|
+
const pollInterval = (_a = options.pollInterval) != null ? _a : 0.25;
|
|
2834
|
+
const stallThreshold = (_b = options.stallThreshold) != null ? _b : 0.75;
|
|
2835
|
+
const bufferEndMargin = (_c = options.bufferEndMargin) != null ? _c : 0.5;
|
|
2836
|
+
const stallSkip = (_d = options.stallSkip) != null ? _d : 0.1;
|
|
2837
|
+
const maxAttempts = (_e = options.maxAttempts) != null ? _e : 3;
|
|
2838
|
+
const nudgeUnbuffered = (_f = options.nudgeUnbuffered) != null ? _f : false;
|
|
2854
2839
|
let lastTime = media.currentTime;
|
|
2855
|
-
let
|
|
2856
|
-
let
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
waiting = false;
|
|
2862
|
-
}
|
|
2863
|
-
);
|
|
2864
|
-
let playing = false;
|
|
2865
|
-
(0, import_vinyl_util31.onAny)(
|
|
2866
|
-
domEvents,
|
|
2867
|
-
["emptied", "ended", "pause", "seeking", "waiting"],
|
|
2868
|
-
() => {
|
|
2869
|
-
playing = false;
|
|
2870
|
-
}
|
|
2871
|
-
);
|
|
2872
|
-
domEvents.on("seeking", () => {
|
|
2873
|
-
seeking = true;
|
|
2874
|
-
});
|
|
2875
|
-
domEvents.on("seeked", () => {
|
|
2876
|
-
seeking = false;
|
|
2877
|
-
setApparentState(2 /* SEEKING */);
|
|
2878
|
-
});
|
|
2879
|
-
domEvents.on("play", () => {
|
|
2880
|
-
stateChangedAt = Date.now();
|
|
2881
|
-
});
|
|
2882
|
-
const readyStateEvents = [
|
|
2883
|
-
"emptied",
|
|
2884
|
-
"loadeddata",
|
|
2885
|
-
"loadedmetadata",
|
|
2886
|
-
"waiting"
|
|
2887
|
-
];
|
|
2888
|
-
let lastReadyStateEvent = "emptied";
|
|
2889
|
-
add(
|
|
2890
|
-
(0, import_vinyl_util31.onAny)(domEvents, readyStateEvents, (_, type) => {
|
|
2891
|
-
lastReadyStateEvent = type;
|
|
2892
|
-
})
|
|
2893
|
-
);
|
|
2894
|
-
const checkApparentState = () => {
|
|
2895
|
-
const progressed = (media.currentTime - lastTime) / media.playbackRate;
|
|
2896
|
-
const now = Date.now();
|
|
2897
|
-
if (Math.abs(progressed) > MIN_SEEKING_DELTA) {
|
|
2898
|
-
setApparentState(2 /* SEEKING */, lastTimestamp);
|
|
2899
|
-
} else if (progressed >= MIN_PLAYING_DELTA) {
|
|
2900
|
-
setApparentState(0 /* PLAYING */, lastTimestamp);
|
|
2901
|
-
} else if ((0, import_vinyl_util31.closeTo)(progressed, 0, MIN_PLAYING_DELTA)) {
|
|
2902
|
-
setApparentState(1 /* STOPPED */, lastTimestamp);
|
|
2903
|
-
}
|
|
2904
|
-
lastTime = media.currentTime;
|
|
2905
|
-
lastTimestamp = now;
|
|
2906
|
-
if (!playing && !seeking && !media.paused && !media.ended && media.readyState >= media.HAVE_FUTURE_DATA && currentApparentState === 0 /* PLAYING */ && elapsedStateTime() >= MIN_PLAYING_BEFORE_FAB) {
|
|
2907
|
-
waiting = false;
|
|
2908
|
-
playing = true;
|
|
2909
|
-
if (lastReadyStateEvent !== "canplay" && lastReadyStateEvent !== "canplaythrough") {
|
|
2910
|
-
lastReadyStateEvent = "canplay";
|
|
2911
|
-
eventFabricated.dispatch(new CustomEvent("canplay"));
|
|
2912
|
-
}
|
|
2913
|
-
if (media.readyState >= media.HAVE_ENOUGH_DATA) {
|
|
2914
|
-
if (lastReadyStateEvent !== "canplaythrough") {
|
|
2915
|
-
lastReadyStateEvent = "canplaythrough";
|
|
2916
|
-
eventFabricated.dispatch(new CustomEvent("canplaythrough"));
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
eventFabricated.dispatch(new CustomEvent("playing"));
|
|
2920
|
-
}
|
|
2921
|
-
if (!waiting && !media.paused && !media.ended && currentApparentState === 1 /* STOPPED */ && elapsedStateTime() >= MIN_STALLED_BEFORE_FAB) {
|
|
2922
|
-
waiting = true;
|
|
2923
|
-
playing = false;
|
|
2924
|
-
eventFabricated.dispatch(new CustomEvent("waiting"));
|
|
2925
|
-
}
|
|
2840
|
+
let stalledFor = 0;
|
|
2841
|
+
let attempts = 0;
|
|
2842
|
+
let sawPlaying = false;
|
|
2843
|
+
let recovered = false;
|
|
2844
|
+
const onPlaying = () => {
|
|
2845
|
+
sawPlaying = true;
|
|
2926
2846
|
};
|
|
2927
|
-
const
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
)
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
return {
|
|
2935
|
-
eventFabricated,
|
|
2936
|
-
properties: {
|
|
2937
|
-
/**
|
|
2938
|
-
* Platforms that have unreliable waiting events, also have unreliable ready state
|
|
2939
|
-
* when the end of buffered data has been reached. If the media is in a waiting state,
|
|
2940
|
-
* the highest ready state that is possible is HAVE_METADATA.
|
|
2941
|
-
*/
|
|
2942
|
-
readyState: {
|
|
2943
|
-
get() {
|
|
2944
|
-
return waiting ? Math.min(media.readyState, media.HAVE_METADATA) : media.readyState;
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
},
|
|
2948
|
-
events: {
|
|
2949
|
-
canplay(event) {
|
|
2950
|
-
const eventOrNull = lastReadyStateEvent === "canplay" ? null : event;
|
|
2951
|
-
lastReadyStateEvent = "canplay";
|
|
2952
|
-
return eventOrNull;
|
|
2953
|
-
},
|
|
2954
|
-
canplaythrough(event) {
|
|
2955
|
-
const eventOrNull = lastReadyStateEvent === "canplaythrough" ? null : event;
|
|
2956
|
-
lastReadyStateEvent = "canplaythrough";
|
|
2957
|
-
return eventOrNull;
|
|
2958
|
-
},
|
|
2959
|
-
playing(event) {
|
|
2960
|
-
if (playing) {
|
|
2961
|
-
return null;
|
|
2962
|
-
}
|
|
2963
|
-
setApparentState(0 /* PLAYING */);
|
|
2964
|
-
playing = true;
|
|
2965
|
-
return event;
|
|
2966
|
-
},
|
|
2967
|
-
waiting(event) {
|
|
2968
|
-
if (waiting) {
|
|
2969
|
-
return null;
|
|
2970
|
-
}
|
|
2971
|
-
waiting = true;
|
|
2972
|
-
setApparentState(1 /* STOPPED */);
|
|
2973
|
-
return event;
|
|
2974
|
-
}
|
|
2975
|
-
},
|
|
2976
|
-
dispose
|
|
2847
|
+
const onEmptied = () => stop();
|
|
2848
|
+
media.addEventListener("playing", onPlaying);
|
|
2849
|
+
media.addEventListener("emptied", onEmptied);
|
|
2850
|
+
const stop = () => {
|
|
2851
|
+
clearInterval(id);
|
|
2852
|
+
media.removeEventListener("playing", onPlaying);
|
|
2853
|
+
media.removeEventListener("emptied", onEmptied);
|
|
2977
2854
|
};
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2855
|
+
const id = setInterval(() => {
|
|
2856
|
+
if (media.paused || media.ended) return stop();
|
|
2857
|
+
if (media.currentTime !== lastTime) {
|
|
2858
|
+
lastTime = media.currentTime;
|
|
2859
|
+
if (!sawPlaying || recovered) fabricatePlaying();
|
|
2860
|
+
return stop();
|
|
2861
|
+
}
|
|
2862
|
+
if (!nudgeUnbuffered && !withinBufferedData(media, bufferEndMargin)) {
|
|
2863
|
+
stalledFor = 0;
|
|
2864
|
+
return;
|
|
2865
|
+
}
|
|
2866
|
+
stalledFor += pollInterval;
|
|
2867
|
+
if (stalledFor < stallThreshold) return;
|
|
2868
|
+
stalledFor = 0;
|
|
2869
|
+
if (attempts++ >= maxAttempts) return stop();
|
|
2870
|
+
recovered = true;
|
|
2871
|
+
media.currentTime += stallSkip;
|
|
2872
|
+
lastTime = media.currentTime;
|
|
2873
|
+
}, pollInterval * 1e3);
|
|
2874
|
+
return stop;
|
|
2875
|
+
}
|
|
2876
|
+
function withinBufferedData(media, endMargin) {
|
|
2877
|
+
const t = media.currentTime;
|
|
2878
|
+
const duration = media.duration;
|
|
2879
|
+
const buffered = media.buffered;
|
|
2880
|
+
for (let i = 0; i < buffered.length; i++) {
|
|
2881
|
+
const end = buffered.end(i);
|
|
2882
|
+
const isEndOfMedia = Number.isFinite(duration) && duration > 0 && end >= duration - endMargin;
|
|
2883
|
+
if (t >= buffered.start(i) && (t < end - endMargin || isEndOfMedia))
|
|
2884
|
+
return true;
|
|
2885
|
+
}
|
|
2886
|
+
return false;
|
|
2981
2887
|
}
|
|
2982
2888
|
|
|
2983
|
-
// src/
|
|
2984
|
-
var
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2889
|
+
// src/playback/createStallMonitor.ts
|
|
2890
|
+
var import_vinyl_util30 = require("@amazon/vinyl-util");
|
|
2891
|
+
|
|
2892
|
+
// src/playback/ReadonlyPlaybackController.ts
|
|
2893
|
+
var PlayedReason = /* @__PURE__ */ ((PlayedReason2) => {
|
|
2894
|
+
PlayedReason2["EMPTIED"] = "emptied";
|
|
2895
|
+
PlayedReason2["ENDED"] = "ended";
|
|
2896
|
+
PlayedReason2["PAUSE"] = "pause";
|
|
2897
|
+
PlayedReason2["SEEKING"] = "seeking";
|
|
2898
|
+
PlayedReason2["WAITING"] = "waiting";
|
|
2899
|
+
return PlayedReason2;
|
|
2900
|
+
})(PlayedReason || {});
|
|
2901
|
+
var playedReasons = [
|
|
2902
|
+
"emptied" /* EMPTIED */,
|
|
2903
|
+
"ended" /* ENDED */,
|
|
2904
|
+
"pause" /* PAUSE */,
|
|
2905
|
+
"seeking" /* SEEKING */,
|
|
2906
|
+
"waiting" /* WAITING */
|
|
2907
|
+
];
|
|
2908
|
+
var WaitedReason = /* @__PURE__ */ ((WaitedReason2) => {
|
|
2909
|
+
WaitedReason2["PLAYING"] = "playing";
|
|
2910
|
+
WaitedReason2["PAUSE"] = "pause";
|
|
2911
|
+
WaitedReason2["EMPTIED"] = "emptied";
|
|
2912
|
+
WaitedReason2["SEEKING"] = "seeking";
|
|
2913
|
+
return WaitedReason2;
|
|
2914
|
+
})(WaitedReason || {});
|
|
2915
|
+
var waitedReasons = [
|
|
2916
|
+
"playing" /* PLAYING */,
|
|
2917
|
+
"pause" /* PAUSE */,
|
|
2918
|
+
"emptied" /* EMPTIED */,
|
|
2919
|
+
"seeking" /* SEEKING */
|
|
2920
|
+
];
|
|
2921
|
+
var StallEndedReason = /* @__PURE__ */ ((StallEndedReason2) => {
|
|
2922
|
+
StallEndedReason2["PLAYING"] = "playing";
|
|
2923
|
+
StallEndedReason2["PAUSE"] = "pause";
|
|
2924
|
+
StallEndedReason2["SEEKING"] = "seeking";
|
|
2925
|
+
StallEndedReason2["EMPTIED"] = "emptied";
|
|
2926
|
+
return StallEndedReason2;
|
|
2927
|
+
})(StallEndedReason || {});
|
|
2928
|
+
var ALL_PLAYBACK_STATE_EVENTS = [
|
|
2929
|
+
"abort",
|
|
2930
|
+
"canPlay",
|
|
2931
|
+
"canPlayThrough",
|
|
2932
|
+
"durationChange",
|
|
2933
|
+
"emptied",
|
|
2934
|
+
"ended",
|
|
2935
|
+
"error",
|
|
2936
|
+
"playIsPendingChange",
|
|
2937
|
+
"loadedData",
|
|
2938
|
+
"loadedMetadata",
|
|
2939
|
+
"loadStart",
|
|
2940
|
+
"looped",
|
|
2941
|
+
"mutedChange",
|
|
2942
|
+
"pause",
|
|
2943
|
+
"play",
|
|
2944
|
+
"playRejected",
|
|
2945
|
+
"played",
|
|
2946
|
+
"playing",
|
|
2947
|
+
"progress",
|
|
2948
|
+
"rateChange",
|
|
2949
|
+
"readyStateChange",
|
|
2950
|
+
"reset",
|
|
2951
|
+
"resize",
|
|
2952
|
+
"seeked",
|
|
2953
|
+
"seeking",
|
|
2954
|
+
"stallEntered",
|
|
2955
|
+
"stallEnded",
|
|
2956
|
+
"timeUpdate",
|
|
2957
|
+
"volumeChange",
|
|
2958
|
+
"waited",
|
|
2959
|
+
"waiting",
|
|
2960
|
+
"waitingForKey"
|
|
2961
|
+
];
|
|
2962
|
+
var PlaybackReadyState = /* @__PURE__ */ ((PlaybackReadyState2) => {
|
|
2963
|
+
PlaybackReadyState2[PlaybackReadyState2["HAVE_NOTHING"] = 0] = "HAVE_NOTHING";
|
|
2964
|
+
PlaybackReadyState2[PlaybackReadyState2["HAVE_METADATA"] = 1] = "HAVE_METADATA";
|
|
2965
|
+
PlaybackReadyState2[PlaybackReadyState2["HAVE_CURRENT_DATA"] = 2] = "HAVE_CURRENT_DATA";
|
|
2966
|
+
PlaybackReadyState2[PlaybackReadyState2["HAVE_FUTURE_DATA"] = 3] = "HAVE_FUTURE_DATA";
|
|
2967
|
+
PlaybackReadyState2[PlaybackReadyState2["HAVE_ENOUGH_DATA"] = 4] = "HAVE_ENOUGH_DATA";
|
|
2968
|
+
return PlaybackReadyState2;
|
|
2969
|
+
})(PlaybackReadyState || {});
|
|
2970
|
+
var PlaybackNetworkState = /* @__PURE__ */ ((PlaybackNetworkState2) => {
|
|
2971
|
+
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_EMPTY"] = 0] = "NETWORK_EMPTY";
|
|
2972
|
+
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_IDLE"] = 1] = "NETWORK_IDLE";
|
|
2973
|
+
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_LOADING"] = 2] = "NETWORK_LOADING";
|
|
2974
|
+
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_NO_SOURCE"] = 3] = "NETWORK_NO_SOURCE";
|
|
2975
|
+
return PlaybackNetworkState2;
|
|
2976
|
+
})(PlaybackNetworkState || {});
|
|
2977
|
+
|
|
2978
|
+
// src/playback/createStallMonitor.ts
|
|
2979
|
+
function createStallMonitor(controller, callbacks, options = {}) {
|
|
2980
|
+
var _a, _b;
|
|
2981
|
+
const stallThresholdMs = ((_a = options.stallThreshold) != null ? _a : 1) * 1e3;
|
|
2982
|
+
const pollIntervalMs = ((_b = options.pollInterval) != null ? _b : 0.25) * 1e3;
|
|
2983
|
+
let observedPlaying = false;
|
|
2984
|
+
let lastProgressAt = Date.now();
|
|
2985
|
+
let inStall = false;
|
|
2986
|
+
let pollId = null;
|
|
2987
|
+
const endStall = (reason) => {
|
|
2988
|
+
if (!inStall) return;
|
|
2989
|
+
inStall = false;
|
|
2990
|
+
const ended = Date.now();
|
|
2991
|
+
callbacks.onStallEnded({
|
|
2992
|
+
started: lastProgressAt,
|
|
2993
|
+
ended,
|
|
2994
|
+
duration: (ended - lastProgressAt) / 1e3,
|
|
2995
|
+
reason
|
|
2996
|
+
});
|
|
2991
2997
|
};
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
unchangedCount = 0;
|
|
3005
|
-
media.pause();
|
|
3006
|
-
media.play().catch(import_vinyl_util32.noop);
|
|
3007
|
-
}
|
|
3008
|
-
} else {
|
|
3009
|
-
if (attemptedFix) {
|
|
3010
|
-
(0, import_vinyl_util32.logInfo)(pathTarget, "stall ended");
|
|
3011
|
-
attemptedFix = false;
|
|
2998
|
+
const stopPoll = () => {
|
|
2999
|
+
if (pollId == null) return;
|
|
3000
|
+
clearInterval(pollId);
|
|
3001
|
+
pollId = null;
|
|
3002
|
+
};
|
|
3003
|
+
const startPoll = () => {
|
|
3004
|
+
if (pollId != null) return;
|
|
3005
|
+
pollId = setInterval(() => {
|
|
3006
|
+
if (inStall || !observedPlaying) return;
|
|
3007
|
+
if (Date.now() - lastProgressAt >= stallThresholdMs) {
|
|
3008
|
+
inStall = true;
|
|
3009
|
+
callbacks.onStallEntered();
|
|
3012
3010
|
}
|
|
3013
|
-
|
|
3014
|
-
previousTime = media.currentTime;
|
|
3015
|
-
}
|
|
3016
|
-
});
|
|
3017
|
-
return {
|
|
3018
|
-
dispose
|
|
3011
|
+
}, pollIntervalMs);
|
|
3019
3012
|
};
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
// src/patch/media/MediaElementPatchOptions.ts
|
|
3026
|
-
var defaultMediaElementPatchOptions = /* @__PURE__ */ (0, import_vinyl_util33.lazy)(() => {
|
|
3027
|
-
return {
|
|
3028
|
-
unreliablePlaybackEvents: requiresUnreliablePlaybackEventsPatch(),
|
|
3029
|
-
preventStalls: requiresPreventStallsPatch()
|
|
3013
|
+
const suspend = (reason) => {
|
|
3014
|
+
endStall(reason);
|
|
3015
|
+
observedPlaying = false;
|
|
3016
|
+
stopPoll();
|
|
3030
3017
|
};
|
|
3031
|
-
});
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
["unreliablePlaybackEvents", createUnreliablePlaybackEventsPatch],
|
|
3040
|
-
["preventStalls", createPreventStallsPatch]
|
|
3018
|
+
const { add, dispose } = (0, import_vinyl_util30.createDisposer)();
|
|
3019
|
+
add(
|
|
3020
|
+
controller.on("playing", () => {
|
|
3021
|
+
if (inStall) endStall("playing" /* PLAYING */);
|
|
3022
|
+
else lastProgressAt = Date.now();
|
|
3023
|
+
observedPlaying = true;
|
|
3024
|
+
startPoll();
|
|
3025
|
+
})
|
|
3041
3026
|
);
|
|
3027
|
+
add(
|
|
3028
|
+
controller.on("timeUpdate", () => {
|
|
3029
|
+
if (inStall) endStall("playing" /* PLAYING */);
|
|
3030
|
+
lastProgressAt = Date.now();
|
|
3031
|
+
})
|
|
3032
|
+
);
|
|
3033
|
+
add(controller.on("pause", () => suspend("pause" /* PAUSE */)));
|
|
3034
|
+
add(controller.on("seeking", () => suspend("seeking" /* SEEKING */)));
|
|
3035
|
+
add(controller.on("emptied", () => suspend("emptied" /* EMPTIED */)));
|
|
3036
|
+
let stopped = false;
|
|
3037
|
+
return () => {
|
|
3038
|
+
if (stopped) return;
|
|
3039
|
+
stopped = true;
|
|
3040
|
+
stopPoll();
|
|
3041
|
+
dispose();
|
|
3042
|
+
};
|
|
3042
3043
|
}
|
|
3043
3044
|
|
|
3044
3045
|
// src/playback/error/InvalidSeekError.ts
|
|
3045
|
-
var
|
|
3046
|
-
var
|
|
3047
|
-
var InvalidSeekError = class _InvalidSeekError extends
|
|
3046
|
+
var import_vinyl_util31 = require("@amazon/vinyl-util");
|
|
3047
|
+
var import_vinyl_util32 = require("@amazon/vinyl-util");
|
|
3048
|
+
var InvalidSeekError = class _InvalidSeekError extends import_vinyl_util31.ReportableError {
|
|
3048
3049
|
constructor(time, seekable, tolerance) {
|
|
3049
3050
|
super(
|
|
3050
3051
|
`Could not seek to time: ${time}, outside of seekable ranges ${seekable} with tolerance ${tolerance}`,
|
|
3051
|
-
|
|
3052
|
-
|
|
3052
|
+
import_vinyl_util32.ErrorOrigin.API,
|
|
3053
|
+
import_vinyl_util31.ErrorLevel.WARN
|
|
3053
3054
|
);
|
|
3054
3055
|
__publicField(this, "time", time);
|
|
3055
3056
|
__publicField(this, "seekable", seekable);
|
|
@@ -3068,7 +3069,7 @@ var InvalidSeekError = class _InvalidSeekError extends import_vinyl_util35.Repor
|
|
|
3068
3069
|
};
|
|
3069
3070
|
|
|
3070
3071
|
// src/playback/error/ReportableMediaError.ts
|
|
3071
|
-
var
|
|
3072
|
+
var import_vinyl_util33 = require("@amazon/vinyl-util");
|
|
3072
3073
|
|
|
3073
3074
|
// src/playback/logging/mediaErrorToJson.ts
|
|
3074
3075
|
function mediaErrorToJson(error) {
|
|
@@ -3108,11 +3109,11 @@ function mediaErrorToJson(error) {
|
|
|
3108
3109
|
}
|
|
3109
3110
|
|
|
3110
3111
|
// src/playback/error/ReportableMediaError.ts
|
|
3111
|
-
var _ReportableMediaError = class _ReportableMediaError extends
|
|
3112
|
+
var _ReportableMediaError = class _ReportableMediaError extends import_vinyl_util33.ReportableError {
|
|
3112
3113
|
constructor(error) {
|
|
3113
3114
|
const { name, code, message } = mediaErrorToJson(error);
|
|
3114
|
-
const level = error == null || code === _ReportableMediaError.MEDIA_ERR_ABORTED ?
|
|
3115
|
-
super(message,
|
|
3115
|
+
const level = error == null || code === _ReportableMediaError.MEDIA_ERR_ABORTED ? import_vinyl_util33.ErrorLevel.SILENT : import_vinyl_util33.ErrorLevel.FATAL;
|
|
3116
|
+
super(message, import_vinyl_util33.ErrorOrigin.MEDIA, level);
|
|
3116
3117
|
__publicField(this, "reason");
|
|
3117
3118
|
__publicField(this, "code");
|
|
3118
3119
|
this.reason = name;
|
|
@@ -3137,90 +3138,11 @@ __publicField(_ReportableMediaError, "MEDIA_ERR_SRC_NOT_SUPPORTED", 4);
|
|
|
3137
3138
|
var ReportableMediaError = _ReportableMediaError;
|
|
3138
3139
|
|
|
3139
3140
|
// src/playback/logging/playbackStateLoggingHandler.ts
|
|
3141
|
+
var import_vinyl_util34 = require("@amazon/vinyl-util");
|
|
3142
|
+
var import_vinyl_util35 = require("@amazon/vinyl-util");
|
|
3143
|
+
var import_vinyl_util36 = require("@amazon/vinyl-util");
|
|
3144
|
+
var import_vinyl_util37 = require("@amazon/vinyl-util");
|
|
3140
3145
|
var import_vinyl_util38 = require("@amazon/vinyl-util");
|
|
3141
|
-
var import_vinyl_util39 = require("@amazon/vinyl-util");
|
|
3142
|
-
|
|
3143
|
-
// src/playback/ReadonlyPlaybackController.ts
|
|
3144
|
-
var PlayedReason = /* @__PURE__ */ ((PlayedReason2) => {
|
|
3145
|
-
PlayedReason2["EMPTIED"] = "emptied";
|
|
3146
|
-
PlayedReason2["ENDED"] = "ended";
|
|
3147
|
-
PlayedReason2["PAUSE"] = "pause";
|
|
3148
|
-
PlayedReason2["SEEKING"] = "seeking";
|
|
3149
|
-
PlayedReason2["WAITING"] = "waiting";
|
|
3150
|
-
return PlayedReason2;
|
|
3151
|
-
})(PlayedReason || {});
|
|
3152
|
-
var playedReasons = [
|
|
3153
|
-
"emptied" /* EMPTIED */,
|
|
3154
|
-
"ended" /* ENDED */,
|
|
3155
|
-
"pause" /* PAUSE */,
|
|
3156
|
-
"seeking" /* SEEKING */,
|
|
3157
|
-
"waiting" /* WAITING */
|
|
3158
|
-
];
|
|
3159
|
-
var WaitedReason = /* @__PURE__ */ ((WaitedReason2) => {
|
|
3160
|
-
WaitedReason2["PLAYING"] = "playing";
|
|
3161
|
-
WaitedReason2["PAUSE"] = "pause";
|
|
3162
|
-
WaitedReason2["EMPTIED"] = "emptied";
|
|
3163
|
-
WaitedReason2["SEEKING"] = "seeking";
|
|
3164
|
-
return WaitedReason2;
|
|
3165
|
-
})(WaitedReason || {});
|
|
3166
|
-
var waitedReasons = [
|
|
3167
|
-
"playing" /* PLAYING */,
|
|
3168
|
-
"pause" /* PAUSE */,
|
|
3169
|
-
"emptied" /* EMPTIED */,
|
|
3170
|
-
"seeking" /* SEEKING */
|
|
3171
|
-
];
|
|
3172
|
-
var ALL_PLAYBACK_STATE_EVENTS = [
|
|
3173
|
-
"abort",
|
|
3174
|
-
"canPlay",
|
|
3175
|
-
"canPlayThrough",
|
|
3176
|
-
"durationChange",
|
|
3177
|
-
"emptied",
|
|
3178
|
-
"ended",
|
|
3179
|
-
"error",
|
|
3180
|
-
"playIsPendingChange",
|
|
3181
|
-
"loadedData",
|
|
3182
|
-
"loadedMetadata",
|
|
3183
|
-
"loadStart",
|
|
3184
|
-
"looped",
|
|
3185
|
-
"mutedChange",
|
|
3186
|
-
"pause",
|
|
3187
|
-
"play",
|
|
3188
|
-
"playRejected",
|
|
3189
|
-
"played",
|
|
3190
|
-
"playing",
|
|
3191
|
-
"progress",
|
|
3192
|
-
"rateChange",
|
|
3193
|
-
"readyStateChange",
|
|
3194
|
-
"reset",
|
|
3195
|
-
"resize",
|
|
3196
|
-
"seeked",
|
|
3197
|
-
"seeking",
|
|
3198
|
-
"timeUpdate",
|
|
3199
|
-
"volumeChange",
|
|
3200
|
-
"waited",
|
|
3201
|
-
"waiting",
|
|
3202
|
-
"waitingForKey"
|
|
3203
|
-
];
|
|
3204
|
-
var PlaybackReadyState = /* @__PURE__ */ ((PlaybackReadyState2) => {
|
|
3205
|
-
PlaybackReadyState2[PlaybackReadyState2["HAVE_NOTHING"] = 0] = "HAVE_NOTHING";
|
|
3206
|
-
PlaybackReadyState2[PlaybackReadyState2["HAVE_METADATA"] = 1] = "HAVE_METADATA";
|
|
3207
|
-
PlaybackReadyState2[PlaybackReadyState2["HAVE_CURRENT_DATA"] = 2] = "HAVE_CURRENT_DATA";
|
|
3208
|
-
PlaybackReadyState2[PlaybackReadyState2["HAVE_FUTURE_DATA"] = 3] = "HAVE_FUTURE_DATA";
|
|
3209
|
-
PlaybackReadyState2[PlaybackReadyState2["HAVE_ENOUGH_DATA"] = 4] = "HAVE_ENOUGH_DATA";
|
|
3210
|
-
return PlaybackReadyState2;
|
|
3211
|
-
})(PlaybackReadyState || {});
|
|
3212
|
-
var PlaybackNetworkState = /* @__PURE__ */ ((PlaybackNetworkState2) => {
|
|
3213
|
-
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_EMPTY"] = 0] = "NETWORK_EMPTY";
|
|
3214
|
-
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_IDLE"] = 1] = "NETWORK_IDLE";
|
|
3215
|
-
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_LOADING"] = 2] = "NETWORK_LOADING";
|
|
3216
|
-
PlaybackNetworkState2[PlaybackNetworkState2["NETWORK_NO_SOURCE"] = 3] = "NETWORK_NO_SOURCE";
|
|
3217
|
-
return PlaybackNetworkState2;
|
|
3218
|
-
})(PlaybackNetworkState || {});
|
|
3219
|
-
|
|
3220
|
-
// src/playback/logging/playbackStateLoggingHandler.ts
|
|
3221
|
-
var import_vinyl_util40 = require("@amazon/vinyl-util");
|
|
3222
|
-
var import_vinyl_util41 = require("@amazon/vinyl-util");
|
|
3223
|
-
var import_vinyl_util42 = require("@amazon/vinyl-util");
|
|
3224
3146
|
var TIMEUPDATE_THROTTLE = 5;
|
|
3225
3147
|
var locale2 = {
|
|
3226
3148
|
/**
|
|
@@ -3234,18 +3156,18 @@ var locale2 = {
|
|
|
3234
3156
|
};
|
|
3235
3157
|
function playbackStateLoggingHandler(playbackState) {
|
|
3236
3158
|
const target = {
|
|
3237
|
-
logPrefix: (0,
|
|
3159
|
+
logPrefix: (0, import_vinyl_util38.createLogPrefix)("Playback")
|
|
3238
3160
|
};
|
|
3239
|
-
const disposer = (0,
|
|
3161
|
+
const disposer = (0, import_vinyl_util34.createDisposer)();
|
|
3240
3162
|
const { add } = disposer;
|
|
3241
3163
|
let timeUpdateCount = 0;
|
|
3242
3164
|
let startTime = null;
|
|
3243
3165
|
const logTimeupdateBatch = () => {
|
|
3244
3166
|
if (startTime == null) return;
|
|
3245
3167
|
const currentTime = playbackState.currentTime;
|
|
3246
|
-
(0,
|
|
3168
|
+
(0, import_vinyl_util35.logDebug)(
|
|
3247
3169
|
target,
|
|
3248
|
-
(0,
|
|
3170
|
+
(0, import_vinyl_util37.substitute)(locale2.timeupdateLogBatch, {
|
|
3249
3171
|
start: startTime.toFixed(1),
|
|
3250
3172
|
end: currentTime.toFixed(1),
|
|
3251
3173
|
count: timeUpdateCount
|
|
@@ -3255,7 +3177,7 @@ function playbackStateLoggingHandler(playbackState) {
|
|
|
3255
3177
|
startTime = null;
|
|
3256
3178
|
};
|
|
3257
3179
|
const logTimeupdateBatchThrottled = add(
|
|
3258
|
-
(0,
|
|
3180
|
+
(0, import_vinyl_util36.throttle)(logTimeupdateBatch, TIMEUPDATE_THROTTLE, { trailing: true })
|
|
3259
3181
|
);
|
|
3260
3182
|
add(
|
|
3261
3183
|
playbackState.on("timeUpdate", () => {
|
|
@@ -3269,16 +3191,16 @@ function playbackStateLoggingHandler(playbackState) {
|
|
|
3269
3191
|
add(
|
|
3270
3192
|
playbackState.on(type, (event) => {
|
|
3271
3193
|
logTimeupdateBatch();
|
|
3272
|
-
(0,
|
|
3194
|
+
(0, import_vinyl_util35.logDebug)(target, type, event);
|
|
3273
3195
|
})
|
|
3274
3196
|
);
|
|
3275
3197
|
}
|
|
3276
3198
|
return disposer;
|
|
3277
3199
|
}
|
|
3278
3200
|
|
|
3279
|
-
// src/playback/loudness/LoudnessNormalizationControllerImpl.ts
|
|
3280
|
-
var
|
|
3281
|
-
var
|
|
3201
|
+
// src/playback/loudness/LoudnessNormalizationControllerImpl.ts
|
|
3202
|
+
var import_vinyl_util39 = require("@amazon/vinyl-util");
|
|
3203
|
+
var import_vinyl_util40 = require("@amazon/vinyl-util");
|
|
3282
3204
|
|
|
3283
3205
|
// src/playback/loudness/LoudnessNormalizationControllerImplOptions.ts
|
|
3284
3206
|
var import_vinyl_validation6 = require("@amazon/vinyl-validation");
|
|
@@ -3296,13 +3218,13 @@ var loudnessNormalizationControllerImplOptionsValidator = /* @__PURE__ */ (0, im
|
|
|
3296
3218
|
// src/playback/loudness/LoudnessNormalizationControllerImpl.ts
|
|
3297
3219
|
var DECIBEL_EXPONENT_BASE = /* @__PURE__ */ Math.pow(10, 1 / 10);
|
|
3298
3220
|
var MAX_GAIN_LEVEL = 1;
|
|
3299
|
-
var LoudnessNormalizationControllerImpl = class extends
|
|
3221
|
+
var LoudnessNormalizationControllerImpl = class extends import_vinyl_util40.EventHostImpl {
|
|
3300
3222
|
constructor(deps) {
|
|
3301
3223
|
super();
|
|
3302
3224
|
__publicField(this, "deps", deps);
|
|
3303
|
-
__publicField(this, "logPrefix", /* @__PURE__ */ (0,
|
|
3225
|
+
__publicField(this, "logPrefix", /* @__PURE__ */ (0, import_vinyl_util40.createLogPrefix)(this));
|
|
3304
3226
|
__publicField(this, "_gain", MAX_GAIN_LEVEL);
|
|
3305
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
3227
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util39.createDisposer)());
|
|
3306
3228
|
__publicField(this, "trackLoudness", null);
|
|
3307
3229
|
__publicField(this, "_options", defaultLoudnessNormalizationControllerImplOptions);
|
|
3308
3230
|
const { add } = this.disposer;
|
|
@@ -3336,9 +3258,9 @@ var LoudnessNormalizationControllerImpl = class extends import_vinyl_util44.Even
|
|
|
3336
3258
|
*/
|
|
3337
3259
|
set gain(value) {
|
|
3338
3260
|
const previousGain = this._gain;
|
|
3339
|
-
if (!(0,
|
|
3261
|
+
if (!(0, import_vinyl_util40.closeTo)(previousGain, value)) {
|
|
3340
3262
|
this._gain = value;
|
|
3341
|
-
(0,
|
|
3263
|
+
(0, import_vinyl_util40.logDebug)(this, "loudness gain adjustment:", {
|
|
3342
3264
|
trackLoudness: this.trackLoudness,
|
|
3343
3265
|
targetLufs: this.options.targetLufs,
|
|
3344
3266
|
gain: value
|
|
@@ -3375,65 +3297,72 @@ var LoudnessNormalizationControllerImpl = class extends import_vinyl_util44.Even
|
|
|
3375
3297
|
};
|
|
3376
3298
|
|
|
3377
3299
|
// src/playback/nextHasMetadata.ts
|
|
3378
|
-
var
|
|
3300
|
+
var import_vinyl_util41 = require("@amazon/vinyl-util");
|
|
3379
3301
|
function nextHasMetadata(controller, options) {
|
|
3380
3302
|
if (controller.hasMetadata) return Promise.resolve({});
|
|
3381
|
-
return (0,
|
|
3303
|
+
return (0, import_vinyl_util41.nextEventAsPromise)(controller, "loadedMetadata", options);
|
|
3382
3304
|
}
|
|
3383
3305
|
|
|
3384
3306
|
// src/playback/PlaybackController.ts
|
|
3385
3307
|
var LIVE_DURATION = 4294967296;
|
|
3386
3308
|
|
|
3387
3309
|
// src/playback/PlaybackControllerImpl.ts
|
|
3388
|
-
var
|
|
3310
|
+
var import_vinyl_util42 = require("@amazon/vinyl-util");
|
|
3389
3311
|
var defaultPlaybackControllerImplOptions = {
|
|
3390
3312
|
loopTimeAffordance: 2,
|
|
3391
3313
|
minSeekableBuffer: -1,
|
|
3392
3314
|
// Default comes from getMinSeekableBufferDefault()
|
|
3393
3315
|
playTimeout: 30,
|
|
3394
|
-
seekTimeout: 30
|
|
3316
|
+
seekTimeout: 30,
|
|
3317
|
+
stallThreshold: 1
|
|
3395
3318
|
};
|
|
3396
3319
|
function getMinSeekableBufferDefault() {
|
|
3397
|
-
return !(0,
|
|
3320
|
+
return !(0, import_vinyl_util42.hasBrowser)(import_vinyl_util42.Browser.CHROMIUM) ? 5 : 2;
|
|
3398
3321
|
}
|
|
3399
|
-
var
|
|
3322
|
+
var SEEK_RETRY_LIMIT = 2;
|
|
3323
|
+
var SEEK_ATTEMPT_TIMEOUT = 4;
|
|
3324
|
+
var PlaybackControllerImpl = class extends import_vinyl_util42.EventHostImpl {
|
|
3400
3325
|
constructor(deps, options) {
|
|
3401
3326
|
super();
|
|
3402
3327
|
__publicField(this, "loudnessNormalizationController");
|
|
3403
3328
|
__publicField(this, "_error", null);
|
|
3404
3329
|
__publicField(this, "media");
|
|
3405
3330
|
__publicField(this, "domEvents");
|
|
3406
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
3331
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util42.createDisposer)());
|
|
3407
3332
|
__publicField(this, "_playing", false);
|
|
3408
3333
|
__publicField(this, "_seeking", false);
|
|
3409
3334
|
__publicField(this, "_waiting", false);
|
|
3410
3335
|
// Monotonic counter identifying the most recent seekTo call.
|
|
3411
3336
|
__publicField(this, "_seekId", 0);
|
|
3337
|
+
// Stops the stall detector started after the last seek, if any.
|
|
3338
|
+
__publicField(this, "stopStallDetection", null);
|
|
3412
3339
|
// default user volume (0.0 to 1.0 scale)
|
|
3413
3340
|
__publicField(this, "userVolume", 1);
|
|
3414
3341
|
__publicField(this, "_pendingPlay", null);
|
|
3415
3342
|
__publicField(this, "playAbort", null);
|
|
3416
|
-
__publicField(this, "disposeAbort", /* @__PURE__ */ new
|
|
3343
|
+
__publicField(this, "disposeAbort", /* @__PURE__ */ new import_vinyl_util42.Abort());
|
|
3417
3344
|
__publicField(this, "options");
|
|
3418
3345
|
this.options = __spreadValues(__spreadProps(__spreadValues({}, defaultPlaybackControllerImplOptions), {
|
|
3419
3346
|
minSeekableBuffer: getMinSeekableBufferDefault()
|
|
3420
3347
|
}), options);
|
|
3421
3348
|
this.loudnessNormalizationController = deps.loudnessNormalizationController;
|
|
3422
|
-
(0,
|
|
3349
|
+
(0, import_vinyl_util42.logInfo)(this, "constructed", this.options);
|
|
3423
3350
|
this.media = deps.media;
|
|
3424
3351
|
const { add } = this.disposer;
|
|
3425
3352
|
add(() => {
|
|
3353
|
+
var _a;
|
|
3426
3354
|
this.disposeAbort.abort();
|
|
3427
3355
|
this.disposeAbort.dispose();
|
|
3356
|
+
(_a = this.stopStallDetection) == null ? void 0 : _a.call(this);
|
|
3428
3357
|
});
|
|
3429
3358
|
this.domEvents = add(
|
|
3430
|
-
new
|
|
3359
|
+
new import_vinyl_util42.DomEventHost(deps.media)
|
|
3431
3360
|
);
|
|
3432
3361
|
add(playbackStateLoggingHandler(this));
|
|
3433
3362
|
this.domEvents.on("error", (_) => {
|
|
3434
3363
|
const error = new ReportableMediaError(this.media.error);
|
|
3435
|
-
if (error.level ===
|
|
3436
|
-
(0,
|
|
3364
|
+
if (error.level === import_vinyl_util42.ErrorLevel.SILENT) {
|
|
3365
|
+
(0, import_vinyl_util42.logInfo)(this, error.message);
|
|
3437
3366
|
return;
|
|
3438
3367
|
}
|
|
3439
3368
|
this._error = error;
|
|
@@ -3443,6 +3372,16 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3443
3372
|
});
|
|
3444
3373
|
});
|
|
3445
3374
|
this.initializeEvents();
|
|
3375
|
+
add(
|
|
3376
|
+
createStallMonitor(
|
|
3377
|
+
this,
|
|
3378
|
+
{
|
|
3379
|
+
onStallEntered: () => this.dispatch("stallEntered", {}),
|
|
3380
|
+
onStallEnded: (info) => this.dispatch("stallEnded", info)
|
|
3381
|
+
},
|
|
3382
|
+
{ stallThreshold: this.options.stallThreshold }
|
|
3383
|
+
)
|
|
3384
|
+
);
|
|
3446
3385
|
add(
|
|
3447
3386
|
this.loudnessNormalizationController.on("change", () => {
|
|
3448
3387
|
this.refreshVolume();
|
|
@@ -3459,7 +3398,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3459
3398
|
refreshVolume() {
|
|
3460
3399
|
const effectiveVolume = this.userVolume * this.loudnessNormalizationController.gain;
|
|
3461
3400
|
this.media.volume = Math.min(1, effectiveVolume);
|
|
3462
|
-
(0,
|
|
3401
|
+
(0, import_vinyl_util42.logDebug)(this, "refreshVolume", {
|
|
3463
3402
|
userVolume: this.userVolume,
|
|
3464
3403
|
lnGain: this.loudnessNormalizationController.gain,
|
|
3465
3404
|
effectiveVolume: this.media.volume
|
|
@@ -3500,7 +3439,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3500
3439
|
"waiting",
|
|
3501
3440
|
"waitingForKey"
|
|
3502
3441
|
]) {
|
|
3503
|
-
this.domEvents.on((0,
|
|
3442
|
+
this.domEvents.on((0, import_vinyl_util42.toLowerCase)(key), () => this.dispatch(key, {}));
|
|
3504
3443
|
}
|
|
3505
3444
|
this.domEvents.on("progress", (e) => {
|
|
3506
3445
|
this.dispatch("progress", { loaded: e.loaded, total: e.total });
|
|
@@ -3518,9 +3457,9 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3518
3457
|
volumeChange: () => this.volume,
|
|
3519
3458
|
rateChange: () => this.playbackRate
|
|
3520
3459
|
};
|
|
3521
|
-
for (const key of (0,
|
|
3460
|
+
for (const key of (0, import_vinyl_util42.ownKeys)(changeEventGetters)) {
|
|
3522
3461
|
this.domEvents.on(
|
|
3523
|
-
(0,
|
|
3462
|
+
(0, import_vinyl_util42.toLowerCase)(key),
|
|
3524
3463
|
createChangeEventTrigger(changeEventGetters[key], (event) => {
|
|
3525
3464
|
this.dispatch(key, event);
|
|
3526
3465
|
})
|
|
@@ -3600,7 +3539,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3600
3539
|
started = true;
|
|
3601
3540
|
startedAt = Date.now();
|
|
3602
3541
|
});
|
|
3603
|
-
(0,
|
|
3542
|
+
(0, import_vinyl_util42.onAny)(host, endEvents, (_, event) => {
|
|
3604
3543
|
if (started) {
|
|
3605
3544
|
started = false;
|
|
3606
3545
|
const now = Date.now();
|
|
@@ -3632,7 +3571,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3632
3571
|
current: this.muted
|
|
3633
3572
|
});
|
|
3634
3573
|
};
|
|
3635
|
-
const mutedTimeoutSlot = add(new
|
|
3574
|
+
const mutedTimeoutSlot = add(new import_vinyl_util42.TimeoutSlot());
|
|
3636
3575
|
this.on("volumeChange", () => {
|
|
3637
3576
|
maybeDispatchMutedChange();
|
|
3638
3577
|
mutedTimeoutSlot.set(maybeDispatchMutedChange, 0.2);
|
|
@@ -3649,10 +3588,9 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3649
3588
|
initializeLoopedEvent() {
|
|
3650
3589
|
let lastTime = 0;
|
|
3651
3590
|
this.on("timeUpdate", () => {
|
|
3652
|
-
var _a;
|
|
3653
3591
|
if (this.loop && !this.paused && this.currentTime <= this.options.loopTimeAffordance && lastTime >= this.duration - this.options.loopTimeAffordance) {
|
|
3654
|
-
if ((
|
|
3655
|
-
(0,
|
|
3592
|
+
if ((0, import_vinyl_util42.hasBrowser)(import_vinyl_util42.Browser.FIREFOX)) {
|
|
3593
|
+
(0, import_vinyl_util42.logDebug)(this, "fabricating Firefox playing event on loop");
|
|
3656
3594
|
this.dispatch("playing", {});
|
|
3657
3595
|
}
|
|
3658
3596
|
this.dispatch("looped", {});
|
|
@@ -3661,7 +3599,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3661
3599
|
});
|
|
3662
3600
|
}
|
|
3663
3601
|
get buffered() {
|
|
3664
|
-
return (0,
|
|
3602
|
+
return (0, import_vinyl_util42.createTimeRangesReader)(this.media.buffered);
|
|
3665
3603
|
}
|
|
3666
3604
|
get currentTime() {
|
|
3667
3605
|
return this.media.currentTime;
|
|
@@ -3673,7 +3611,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3673
3611
|
return this.media.defaultPlaybackRate;
|
|
3674
3612
|
}
|
|
3675
3613
|
set defaultPlaybackRate(value) {
|
|
3676
|
-
(0,
|
|
3614
|
+
(0, import_vinyl_util42.logDebug)(this, `defaultPlaybackRate set to ${value}`);
|
|
3677
3615
|
this.media.defaultPlaybackRate = value;
|
|
3678
3616
|
}
|
|
3679
3617
|
get duration() {
|
|
@@ -3691,14 +3629,14 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3691
3629
|
return this.media.loop;
|
|
3692
3630
|
}
|
|
3693
3631
|
set loop(value) {
|
|
3694
|
-
(0,
|
|
3632
|
+
(0, import_vinyl_util42.logDebug)(this, `loop set to ${value}`);
|
|
3695
3633
|
this.media.loop = value;
|
|
3696
3634
|
}
|
|
3697
3635
|
get muted() {
|
|
3698
3636
|
return this.media.muted;
|
|
3699
3637
|
}
|
|
3700
3638
|
set muted(value) {
|
|
3701
|
-
(0,
|
|
3639
|
+
(0, import_vinyl_util42.logDebug)(this, `muted set to ${value}`);
|
|
3702
3640
|
this.media.muted = value;
|
|
3703
3641
|
}
|
|
3704
3642
|
get networkState() {
|
|
@@ -3711,7 +3649,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3711
3649
|
return this.media.playbackRate;
|
|
3712
3650
|
}
|
|
3713
3651
|
set playbackRate(value) {
|
|
3714
|
-
(0,
|
|
3652
|
+
(0, import_vinyl_util42.logDebug)(this, `playbackRate set to ${value}`);
|
|
3715
3653
|
this.media.playbackRate = value;
|
|
3716
3654
|
}
|
|
3717
3655
|
get playing() {
|
|
@@ -3721,14 +3659,14 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3721
3659
|
return this.media.preservesPitch;
|
|
3722
3660
|
}
|
|
3723
3661
|
set preservesPitch(value) {
|
|
3724
|
-
(0,
|
|
3662
|
+
(0, import_vinyl_util42.logDebug)(this, `preservesPitch set to ${value}`);
|
|
3725
3663
|
this.media.preservesPitch = value;
|
|
3726
3664
|
}
|
|
3727
3665
|
get readyState() {
|
|
3728
3666
|
return this.media.readyState;
|
|
3729
3667
|
}
|
|
3730
3668
|
get seekable() {
|
|
3731
|
-
return (0,
|
|
3669
|
+
return (0, import_vinyl_util42.createTimeRangesReader)(this.media.seekable);
|
|
3732
3670
|
}
|
|
3733
3671
|
get seeking() {
|
|
3734
3672
|
return this._seeking;
|
|
@@ -3737,7 +3675,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3737
3675
|
return this.userVolume;
|
|
3738
3676
|
}
|
|
3739
3677
|
set volume(value) {
|
|
3740
|
-
(0,
|
|
3678
|
+
(0, import_vinyl_util42.logDebug)(this, `volume set to ${value}`);
|
|
3741
3679
|
this.userVolume = value;
|
|
3742
3680
|
this.refreshVolume();
|
|
3743
3681
|
}
|
|
@@ -3746,9 +3684,9 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3746
3684
|
}
|
|
3747
3685
|
pause() {
|
|
3748
3686
|
var _a;
|
|
3749
|
-
(0,
|
|
3687
|
+
(0, import_vinyl_util42.logDebug)(this, "pause");
|
|
3750
3688
|
(_a = this.playAbort) == null ? void 0 : _a.abort(
|
|
3751
|
-
new
|
|
3689
|
+
new import_vinyl_util42.AbortError(
|
|
3752
3690
|
"The play() request was interrupted by a call to pause()."
|
|
3753
3691
|
)
|
|
3754
3692
|
);
|
|
@@ -3765,22 +3703,39 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3765
3703
|
current: value != null
|
|
3766
3704
|
});
|
|
3767
3705
|
}
|
|
3706
|
+
/**
|
|
3707
|
+
* Starts (or restarts) the stall detector: recovers a play head that stays frozen when it
|
|
3708
|
+
* should be advancing — some WebKit versions never resume after a seek or a play, e.g. after a
|
|
3709
|
+
* buffer-flushing seek. Superseded by the next seek/play and stopped on dispose.
|
|
3710
|
+
* @private
|
|
3711
|
+
*/
|
|
3712
|
+
startStallDetection() {
|
|
3713
|
+
var _a;
|
|
3714
|
+
(_a = this.stopStallDetection) == null ? void 0 : _a.call(this);
|
|
3715
|
+
this.stopStallDetection = createStallDetector(this.media, {
|
|
3716
|
+
fabricatePlaying: () => this.dispatch("playing", {}),
|
|
3717
|
+
// Safari/iOS can leave a seek on a freshly-attached source pending
|
|
3718
|
+
// with a stale empty `buffered`; re-issue the seek to un-stick it.
|
|
3719
|
+
nudgeUnbuffered: (0, import_vinyl_util42.hasBrowser)(import_vinyl_util42.Browser.WEBKIT)
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3768
3722
|
play() {
|
|
3769
|
-
(0,
|
|
3723
|
+
(0, import_vinyl_util42.logDebug)(this, "play");
|
|
3724
|
+
this.startStallDetection();
|
|
3770
3725
|
if (!this.pendingPlay) {
|
|
3771
|
-
const playAbort = new
|
|
3726
|
+
const playAbort = new import_vinyl_util42.Abort();
|
|
3772
3727
|
this.playAbort = playAbort;
|
|
3773
|
-
this.pendingPlay = (0,
|
|
3728
|
+
this.pendingPlay = (0, import_vinyl_util42.withAbort)(
|
|
3774
3729
|
(async () => {
|
|
3775
3730
|
await nextHasMetadata(this);
|
|
3776
3731
|
playAbort.throwIfAborted();
|
|
3777
|
-
await (0,
|
|
3732
|
+
await (0, import_vinyl_util42.withTimeout)(
|
|
3778
3733
|
this.media.play(),
|
|
3779
3734
|
this.options.playTimeout,
|
|
3780
3735
|
{
|
|
3781
3736
|
message: "play() timed out after {time}s",
|
|
3782
|
-
origin:
|
|
3783
|
-
level:
|
|
3737
|
+
origin: import_vinyl_util42.ErrorOrigin.INTERNAL,
|
|
3738
|
+
level: import_vinyl_util42.ErrorLevel.SILENT
|
|
3784
3739
|
}
|
|
3785
3740
|
);
|
|
3786
3741
|
})(),
|
|
@@ -3808,19 +3763,23 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3808
3763
|
return this.pendingPlay != null;
|
|
3809
3764
|
}
|
|
3810
3765
|
async seekTo(time, tolerance = 0.5) {
|
|
3811
|
-
|
|
3766
|
+
var _a;
|
|
3767
|
+
(0, import_vinyl_util42.logDebug)(this, `seekTo: ${time}`);
|
|
3812
3768
|
const seekId = ++this._seekId;
|
|
3769
|
+
(_a = this.stopStallDetection) == null ? void 0 : _a.call(this);
|
|
3770
|
+
this.stopStallDetection = null;
|
|
3813
3771
|
const superseded = () => {
|
|
3814
3772
|
if (this._seekId === seekId) return false;
|
|
3815
|
-
(0,
|
|
3773
|
+
(0, import_vinyl_util42.logDebug)(this, `seekTo: ${time} superseded by a newer seek`);
|
|
3816
3774
|
return true;
|
|
3817
3775
|
};
|
|
3818
|
-
const nextEvent = (type) => {
|
|
3819
|
-
|
|
3820
|
-
|
|
3776
|
+
const nextEvent = (type, options) => {
|
|
3777
|
+
var _a2;
|
|
3778
|
+
return (0, import_vinyl_util42.nextEventAsPromise)(this, type, {
|
|
3779
|
+
timeout: (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.seekTimeout,
|
|
3821
3780
|
timeoutMessage: `seek timed out on ${type} event after {time}s`,
|
|
3822
|
-
timeoutOrigin:
|
|
3823
|
-
timeoutLevel:
|
|
3781
|
+
timeoutOrigin: import_vinyl_util42.ErrorOrigin.INTERNAL,
|
|
3782
|
+
timeoutLevel: import_vinyl_util42.ErrorLevel.WARN,
|
|
3824
3783
|
abort: this.disposeAbort
|
|
3825
3784
|
});
|
|
3826
3785
|
};
|
|
@@ -3830,11 +3789,11 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3830
3789
|
}
|
|
3831
3790
|
const seekable = this.seekable;
|
|
3832
3791
|
const range = seekable.getRangeAt(
|
|
3833
|
-
(0,
|
|
3792
|
+
(0, import_vinyl_util42.clamp)(time, 0, this.duration),
|
|
3834
3793
|
tolerance
|
|
3835
3794
|
);
|
|
3836
3795
|
if (range == null) {
|
|
3837
|
-
(0,
|
|
3796
|
+
(0, import_vinyl_util42.logWarn)(
|
|
3838
3797
|
this,
|
|
3839
3798
|
`seekTo: seek outside of seekable ranges, seek ignored`,
|
|
3840
3799
|
seekable.ranges
|
|
@@ -3846,23 +3805,40 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3846
3805
|
Math.min(time, range[1] - seekableBuffer),
|
|
3847
3806
|
range[0]
|
|
3848
3807
|
);
|
|
3849
|
-
(0,
|
|
3808
|
+
(0, import_vinyl_util42.logDebug)(
|
|
3850
3809
|
this,
|
|
3851
3810
|
`seekTo operation, requested: ${time}, actual: ${clampedTime}`
|
|
3852
3811
|
);
|
|
3853
|
-
if ((0,
|
|
3854
|
-
(0,
|
|
3812
|
+
if ((0, import_vinyl_util42.closeTo)(clampedTime, this.currentTime, tolerance)) {
|
|
3813
|
+
(0, import_vinyl_util42.logDebug)(
|
|
3855
3814
|
this,
|
|
3856
3815
|
`seekTo: requested: ${time}, actual: ${clampedTime} no-op`
|
|
3857
3816
|
);
|
|
3858
3817
|
} else {
|
|
3859
|
-
const
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3818
|
+
const nullIfStuck = (error) => {
|
|
3819
|
+
if (this.disposeAbort.aborted()) throw error;
|
|
3820
|
+
return null;
|
|
3821
|
+
};
|
|
3822
|
+
const seekOnce = async (reSeeking) => {
|
|
3823
|
+
const seeking = reSeeking ? nextEvent("seeking", {
|
|
3824
|
+
timeout: SEEK_ATTEMPT_TIMEOUT
|
|
3825
|
+
}).catch(nullIfStuck) : nextEvent("seeking");
|
|
3826
|
+
this.media.currentTime = clampedTime;
|
|
3827
|
+
if (await seeking === null) return null;
|
|
3828
|
+
return nextEvent("seeked", {
|
|
3829
|
+
timeout: SEEK_ATTEMPT_TIMEOUT
|
|
3830
|
+
}).catch(nullIfStuck);
|
|
3831
|
+
};
|
|
3832
|
+
let seekedEvent = await seekOnce(false);
|
|
3833
|
+
for (let attempt = 0; !superseded() && attempt < SEEK_RETRY_LIMIT && (seekedEvent === null || seekedEvent.reason === "seeked" && !(0, import_vinyl_util42.closeTo)(clampedTime, this.currentTime, tolerance)); attempt++) {
|
|
3834
|
+
if (seekedEvent === null) void this.media.play().catch(import_vinyl_util42.noop);
|
|
3835
|
+
(0, import_vinyl_util42.logDebug)(this, `seekTo: re-seeking to ${clampedTime}`);
|
|
3836
|
+
seekedEvent = await seekOnce(true);
|
|
3865
3837
|
}
|
|
3838
|
+
if ((seekedEvent == null ? void 0 : seekedEvent.reason) === "emptied") {
|
|
3839
|
+
throw new import_vinyl_util42.AbortError();
|
|
3840
|
+
}
|
|
3841
|
+
if (!this.paused) this.startStallDetection();
|
|
3866
3842
|
}
|
|
3867
3843
|
}
|
|
3868
3844
|
/**
|
|
@@ -3871,7 +3847,7 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3871
3847
|
*/
|
|
3872
3848
|
initializeReadyStateChangeEvent() {
|
|
3873
3849
|
let previous = this.readyState;
|
|
3874
|
-
(0,
|
|
3850
|
+
(0, import_vinyl_util42.onAny)(
|
|
3875
3851
|
this,
|
|
3876
3852
|
[
|
|
3877
3853
|
"canPlay",
|
|
@@ -3895,10 +3871,10 @@ var PlaybackControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
|
3895
3871
|
}
|
|
3896
3872
|
reset() {
|
|
3897
3873
|
if (this._error == null) {
|
|
3898
|
-
(0,
|
|
3874
|
+
(0, import_vinyl_util42.logDebug)(this, "reset no-op");
|
|
3899
3875
|
return;
|
|
3900
3876
|
}
|
|
3901
|
-
(0,
|
|
3877
|
+
(0, import_vinyl_util42.logDebug)(this, "reset");
|
|
3902
3878
|
this._error = null;
|
|
3903
3879
|
this.dispatch("reset", {});
|
|
3904
3880
|
}
|
|
@@ -3956,7 +3932,7 @@ var PlaybackSourceImpl = class {
|
|
|
3956
3932
|
};
|
|
3957
3933
|
|
|
3958
3934
|
// src/streaming/abr/QualitySelectorImpl.ts
|
|
3959
|
-
var
|
|
3935
|
+
var import_vinyl_util43 = require("@amazon/vinyl-util");
|
|
3960
3936
|
var import_vinyl_validation7 = require("@amazon/vinyl-validation");
|
|
3961
3937
|
var AbrStrategy = /* @__PURE__ */ ((AbrStrategy2) => {
|
|
3962
3938
|
AbrStrategy2["LOWEST"] = "lowest";
|
|
@@ -3989,9 +3965,9 @@ var defaultQualitySelectorImplOptions = {
|
|
|
3989
3965
|
};
|
|
3990
3966
|
var QualitySelectorImpl = class {
|
|
3991
3967
|
constructor(deps) {
|
|
3992
|
-
__publicField(this, "logPrefix", /* @__PURE__ */ (0,
|
|
3968
|
+
__publicField(this, "logPrefix", /* @__PURE__ */ (0, import_vinyl_util43.createLogPrefix)(this));
|
|
3993
3969
|
__publicField(this, "_options", defaultQualitySelectorImplOptions);
|
|
3994
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
3970
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util43.createDisposer)());
|
|
3995
3971
|
const { add } = this.disposer;
|
|
3996
3972
|
add(
|
|
3997
3973
|
deps.options.onData((v) => {
|
|
@@ -4030,9 +4006,9 @@ var QualitySelectorImpl = class {
|
|
|
4030
4006
|
if (previousIndex >= 0) return previousIndex;
|
|
4031
4007
|
}
|
|
4032
4008
|
const fetchedTime = prefetchState.fetchedTime;
|
|
4033
|
-
const bandwidthEstimate = (0,
|
|
4034
|
-
const bufferRatio = highBufferThreshold > 0 ? (0,
|
|
4035
|
-
const bandwidthMultiplier = prefetchState.active ? (0,
|
|
4009
|
+
const bandwidthEstimate = (0, import_vinyl_util43.getNetworkMetrics)().estimatedDownlinkBandwidth;
|
|
4010
|
+
const bufferRatio = highBufferThreshold > 0 ? (0, import_vinyl_util43.clamp)(fetchedTime / highBufferThreshold, 0, 1) : 1;
|
|
4011
|
+
const bandwidthMultiplier = prefetchState.active ? (0, import_vinyl_util43.lerp)(bandwidthMultiplierLow, bandwidthMultiplierHigh, bufferRatio) : bandwidthMultiplierHigh;
|
|
4036
4012
|
let bandwidth = (prefetchState.active ? Math.min(bandwidthEstimate.ewmaLow, bandwidthEstimate.latest) : bandwidthEstimate.ewmaLow) * bandwidthMultiplier;
|
|
4037
4013
|
if (maxBandwidth != null && maxBandwidth < bandwidth) {
|
|
4038
4014
|
bandwidth = maxBandwidth;
|
|
@@ -4081,30 +4057,34 @@ var QualitySelectorImpl = class {
|
|
|
4081
4057
|
// src/streaming/AudioOptions.ts
|
|
4082
4058
|
var import_vinyl_validation8 = require("@amazon/vinyl-validation");
|
|
4083
4059
|
var defaultAudioOptions = {
|
|
4084
|
-
selection: { language: null, descriptive: false }
|
|
4060
|
+
selection: { language: null, descriptive: false },
|
|
4061
|
+
disableSampleRateFilter: false
|
|
4085
4062
|
};
|
|
4086
4063
|
var audioSelectionValidator = /* @__PURE__ */ (0, import_vinyl_validation8.object)({
|
|
4087
4064
|
language: /* @__PURE__ */ (0, import_vinyl_validation8.string)().or(/* @__PURE__ */ (0, import_vinyl_validation8.array)(/* @__PURE__ */ (0, import_vinyl_validation8.string)()).readonly()).orNull().optional(),
|
|
4088
4065
|
descriptive: /* @__PURE__ */ (0, import_vinyl_validation8.boolean)().optional()
|
|
4089
4066
|
});
|
|
4090
4067
|
var audioOptionsValidator = /* @__PURE__ */ (0, import_vinyl_validation8.object)({
|
|
4091
|
-
selection: /* @__PURE__ */ audioSelectionValidator.optional()
|
|
4068
|
+
selection: /* @__PURE__ */ audioSelectionValidator.optional(),
|
|
4069
|
+
disableSampleRateFilter: /* @__PURE__ */ (0, import_vinyl_validation8.boolean)().optional(),
|
|
4070
|
+
maxSampleRate: /* @__PURE__ */ (0, import_vinyl_validation8.number)().maybe().optional(),
|
|
4071
|
+
minSampleRate: /* @__PURE__ */ (0, import_vinyl_validation8.number)().maybe().optional()
|
|
4092
4072
|
});
|
|
4093
4073
|
|
|
4094
4074
|
// src/streaming/buffering/BufferingController.ts
|
|
4095
|
-
var
|
|
4075
|
+
var import_vinyl_util46 = require("@amazon/vinyl-util");
|
|
4096
4076
|
|
|
4097
4077
|
// src/streaming/SegmentController.ts
|
|
4098
4078
|
var SEGMENT_START_AFFORDANCE = 0.2;
|
|
4099
4079
|
|
|
4100
4080
|
// src/streaming/buffering/error/SourceBufferError.ts
|
|
4101
|
-
var
|
|
4102
|
-
var
|
|
4103
|
-
var SourceBufferError = class _SourceBufferError extends
|
|
4081
|
+
var import_vinyl_util44 = require("@amazon/vinyl-util");
|
|
4082
|
+
var import_vinyl_util45 = require("@amazon/vinyl-util");
|
|
4083
|
+
var SourceBufferError = class _SourceBufferError extends import_vinyl_util45.ReportableError {
|
|
4104
4084
|
get [Symbol.toStringTag]() {
|
|
4105
4085
|
return "SourceBufferError";
|
|
4106
4086
|
}
|
|
4107
|
-
constructor(message = `A SourceBuffer error has occurred.`, origin =
|
|
4087
|
+
constructor(message = `A SourceBuffer error has occurred.`, origin = import_vinyl_util44.ErrorOrigin.MEDIA) {
|
|
4108
4088
|
super(message, origin);
|
|
4109
4089
|
Object.setPrototypeOf(this, _SourceBufferError.prototype);
|
|
4110
4090
|
}
|
|
@@ -4164,7 +4144,7 @@ var defaultBufferingControllerOptions = {
|
|
|
4164
4144
|
// 150 * 1024 * 1024
|
|
4165
4145
|
}
|
|
4166
4146
|
};
|
|
4167
|
-
var BufferingControllerImpl = class extends
|
|
4147
|
+
var BufferingControllerImpl = class extends import_vinyl_util46.EventHostImpl {
|
|
4168
4148
|
constructor(deps, contentType2, options) {
|
|
4169
4149
|
super();
|
|
4170
4150
|
__publicField(this, "deps", deps);
|
|
@@ -4181,7 +4161,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4181
4161
|
/**
|
|
4182
4162
|
* The currently buffered segments.
|
|
4183
4163
|
*/
|
|
4184
|
-
__publicField(this, "buffered", /* @__PURE__ */ new
|
|
4164
|
+
__publicField(this, "buffered", /* @__PURE__ */ new import_vinyl_util46.LinkedList());
|
|
4185
4165
|
__publicField(this, "appendOffset", 0);
|
|
4186
4166
|
/**
|
|
4187
4167
|
* The currently buffering quality.
|
|
@@ -4195,12 +4175,11 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4195
4175
|
__publicField(this, "reopen", false);
|
|
4196
4176
|
__publicField(this, "_error", null);
|
|
4197
4177
|
__publicField(this, "_bufferingEnded", false);
|
|
4198
|
-
__publicField(this, "
|
|
4199
|
-
__publicField(this, "
|
|
4200
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util50.createDisposer)());
|
|
4178
|
+
__publicField(this, "queue", /* @__PURE__ */ (0, import_vinyl_util46.createTaskQueue)());
|
|
4179
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util46.createDisposer)());
|
|
4201
4180
|
__publicField(this, "_active", false);
|
|
4202
4181
|
__publicField(this, "activateDisposer", null);
|
|
4203
|
-
__publicField(this, "segmentAbort", /* @__PURE__ */ (0,
|
|
4182
|
+
__publicField(this, "segmentAbort", /* @__PURE__ */ (0, import_vinyl_util46.createAbortSlot)());
|
|
4204
4183
|
/**
|
|
4205
4184
|
* Resets the throttle and polls the buffer on the next frame.
|
|
4206
4185
|
*/
|
|
@@ -4217,11 +4196,11 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4217
4196
|
* @private
|
|
4218
4197
|
*/
|
|
4219
4198
|
__publicField(this, "pollBuffer", /* @__PURE__ */ this.disposer.add(
|
|
4220
|
-
/* @__PURE__ */ (0,
|
|
4199
|
+
/* @__PURE__ */ (0, import_vinyl_util46.throttle)(
|
|
4221
4200
|
() => {
|
|
4222
4201
|
const time = this.playbackController.currentTime;
|
|
4223
|
-
if ((0,
|
|
4224
|
-
(0,
|
|
4202
|
+
if ((0, import_vinyl_util46.getLogLevel)() === import_vinyl_util46.LogLevel.VERBOSE) {
|
|
4203
|
+
(0, import_vinyl_util46.logVerbose)(
|
|
4225
4204
|
this,
|
|
4226
4205
|
`pollBuffer time: ${time}, bufferedTime: ${this.getBufferedTime()}, busy: ${this.busy}, error: ${this.error != null}, readyState: ${this.mediaSourceController.readyState}`
|
|
4227
4206
|
);
|
|
@@ -4251,7 +4230,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4251
4230
|
const newAppendSize = this.getMaxAppendSize(contentType2) * QUOTA_REACHED_SCALE;
|
|
4252
4231
|
if (newAppendSize >= MIN_APPEND_SIZE) {
|
|
4253
4232
|
sourceBufferQuotas.set(contentType2, newAppendSize);
|
|
4254
|
-
(0,
|
|
4233
|
+
(0, import_vinyl_util46.logWarn)(
|
|
4255
4234
|
this,
|
|
4256
4235
|
"QuotaExceededError, new source buffer limit:",
|
|
4257
4236
|
(newAppendSize / 1024 / 1024).toFixed(1) + " MiB"
|
|
@@ -4267,7 +4246,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4267
4246
|
if (this.tryCodecFallback(error)) {
|
|
4268
4247
|
return;
|
|
4269
4248
|
}
|
|
4270
|
-
if (!(0,
|
|
4249
|
+
if (!(0, import_vinyl_util46.isSilentError)(error)) {
|
|
4271
4250
|
this._error = error;
|
|
4272
4251
|
this.dispatch("error", {
|
|
4273
4252
|
target: this,
|
|
@@ -4280,13 +4259,13 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4280
4259
|
*/
|
|
4281
4260
|
__publicField(this, "finishAndClearBuffers", async () => {
|
|
4282
4261
|
if (!this.active) return;
|
|
4283
|
-
(0,
|
|
4262
|
+
(0, import_vinyl_util46.logVerbose)(this, "finishAndClearBuffers");
|
|
4284
4263
|
await this.sourceBufferController.clear();
|
|
4285
|
-
(0,
|
|
4264
|
+
(0, import_vinyl_util46.logVerbose)(this, "finishAndClearBuffers complete");
|
|
4286
4265
|
});
|
|
4287
|
-
this.logPrefix = (0,
|
|
4266
|
+
this.logPrefix = (0, import_vinyl_util46.createLogPrefix)(`Buffering_${contentType2}`);
|
|
4288
4267
|
this.options = __spreadValues(__spreadValues({}, defaultBufferingControllerOptions), options);
|
|
4289
|
-
(0,
|
|
4268
|
+
(0, import_vinyl_util46.logDebug)(this, "constructed", this.options);
|
|
4290
4269
|
this.mediaSourceController = deps.mediaSourceController;
|
|
4291
4270
|
this.playbackController = deps.playbackController;
|
|
4292
4271
|
this.segmentController = deps.segmentController;
|
|
@@ -4303,8 +4282,8 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4303
4282
|
activate() {
|
|
4304
4283
|
if (this._active) return;
|
|
4305
4284
|
this._active = true;
|
|
4306
|
-
(0,
|
|
4307
|
-
this.activateDisposer = (0,
|
|
4285
|
+
(0, import_vinyl_util46.logDebug)(this, "activate");
|
|
4286
|
+
this.activateDisposer = (0, import_vinyl_util46.createDisposer)();
|
|
4308
4287
|
const { add } = this.activateDisposer;
|
|
4309
4288
|
this.sourceBufferController = add(
|
|
4310
4289
|
this.deps.sourceBufferControllerFactory()
|
|
@@ -4317,7 +4296,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4317
4296
|
})
|
|
4318
4297
|
);
|
|
4319
4298
|
const onMediaSourceOpen2 = () => {
|
|
4320
|
-
(0,
|
|
4299
|
+
(0, import_vinyl_util46.logDebug)(this, "media source opened");
|
|
4321
4300
|
this.pollBufferImmediate();
|
|
4322
4301
|
};
|
|
4323
4302
|
if (this.mediaSourceOpen) {
|
|
@@ -4334,7 +4313,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4334
4313
|
}
|
|
4335
4314
|
deactivate() {
|
|
4336
4315
|
if (!this._active) return;
|
|
4337
|
-
(0,
|
|
4316
|
+
(0, import_vinyl_util46.logDebug)(this, "deactivate");
|
|
4338
4317
|
this.abortCurrentSegment();
|
|
4339
4318
|
this.resetBufferedState();
|
|
4340
4319
|
this.activateDisposer.dispose();
|
|
@@ -4344,10 +4323,10 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4344
4323
|
}
|
|
4345
4324
|
reset() {
|
|
4346
4325
|
if (!this._error) {
|
|
4347
|
-
(0,
|
|
4326
|
+
(0, import_vinyl_util46.logDebug)(this, "reset no-op");
|
|
4348
4327
|
return;
|
|
4349
4328
|
}
|
|
4350
|
-
(0,
|
|
4329
|
+
(0, import_vinyl_util46.logDebug)(this, "reset");
|
|
4351
4330
|
this._error = null;
|
|
4352
4331
|
this.pollBufferImmediate();
|
|
4353
4332
|
}
|
|
@@ -4377,7 +4356,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4377
4356
|
}
|
|
4378
4357
|
async appendNext() {
|
|
4379
4358
|
var _a;
|
|
4380
|
-
(0,
|
|
4359
|
+
(0, import_vinyl_util46.logVerbose)(this, "appendNext");
|
|
4381
4360
|
const sourceBufferController = this.sourceBufferController;
|
|
4382
4361
|
const time = this.playbackController.currentTime;
|
|
4383
4362
|
const tail = this.tail;
|
|
@@ -4391,7 +4370,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4391
4370
|
(_a = tail == null ? void 0 : tail.endTime) != null ? _a : time - SEGMENT_START_AFFORDANCE,
|
|
4392
4371
|
this.segmentAbort.value
|
|
4393
4372
|
);
|
|
4394
|
-
(0,
|
|
4373
|
+
(0, import_vinyl_util46.logVerbose)(this, "streamingSegment", streamingSegment);
|
|
4395
4374
|
if (streamingSegment) this.appendOffset = 0;
|
|
4396
4375
|
}
|
|
4397
4376
|
if (!streamingSegment) {
|
|
@@ -4434,7 +4413,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4434
4413
|
this.buffered.push(streamingSegment);
|
|
4435
4414
|
}
|
|
4436
4415
|
this.appendOffset = newOffset;
|
|
4437
|
-
(0,
|
|
4416
|
+
(0, import_vinyl_util46.logVerbose)(
|
|
4438
4417
|
this,
|
|
4439
4418
|
`appended chunk, this.appendOffset: ${this.appendOffset}`
|
|
4440
4419
|
);
|
|
@@ -4444,7 +4423,6 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4444
4423
|
this.buffered.push(streamingSegment);
|
|
4445
4424
|
}
|
|
4446
4425
|
if (!tail) this.refreshHead();
|
|
4447
|
-
this.setHasData(true);
|
|
4448
4426
|
}
|
|
4449
4427
|
abortCurrentSegment() {
|
|
4450
4428
|
this.segmentAbort.abort();
|
|
@@ -4482,7 +4460,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4482
4460
|
const previous = this._bufferingQuality;
|
|
4483
4461
|
if ((value == null ? void 0 : value.qualityId) === (previous == null ? void 0 : previous.qualityId)) return;
|
|
4484
4462
|
this._bufferingQuality = value;
|
|
4485
|
-
(0,
|
|
4463
|
+
(0, import_vinyl_util46.logDebug)(this, "bufferingQualityChange", value);
|
|
4486
4464
|
this.dispatch("bufferingQualityChange", {
|
|
4487
4465
|
previous,
|
|
4488
4466
|
current: value
|
|
@@ -4496,7 +4474,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4496
4474
|
const previous = this._playbackQuality;
|
|
4497
4475
|
if ((value == null ? void 0 : value.qualityId) === (previous == null ? void 0 : previous.qualityId)) return;
|
|
4498
4476
|
this._playbackQuality = value;
|
|
4499
|
-
(0,
|
|
4477
|
+
(0, import_vinyl_util46.logDebug)(this, "playbackQualityChange", value);
|
|
4500
4478
|
this.dispatch("playbackQualityChange", {
|
|
4501
4479
|
previous,
|
|
4502
4480
|
current: value
|
|
@@ -4528,15 +4506,6 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4528
4506
|
get bufferingEnded() {
|
|
4529
4507
|
return this._bufferingEnded;
|
|
4530
4508
|
}
|
|
4531
|
-
get hasData() {
|
|
4532
|
-
return this._hasData;
|
|
4533
|
-
}
|
|
4534
|
-
setHasData(value) {
|
|
4535
|
-
if (this._hasData === value) return;
|
|
4536
|
-
const previous = this._hasData;
|
|
4537
|
-
this._hasData = value;
|
|
4538
|
-
this.dispatch("hasDataChange", { previous, current: value });
|
|
4539
|
-
}
|
|
4540
4509
|
/**
|
|
4541
4510
|
* Attempts to recover from a SourceBuffer decode/append failure caused by a
|
|
4542
4511
|
* codec the browser reported as supported but cannot actually decode.
|
|
@@ -4557,7 +4526,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4557
4526
|
const contentType2 = quality == null ? void 0 : quality.contentType;
|
|
4558
4527
|
if (!mimeType || !contentType2) return false;
|
|
4559
4528
|
if (!denylistCodecsFromMimeType(mimeType)) return false;
|
|
4560
|
-
(0,
|
|
4529
|
+
(0, import_vinyl_util46.logWarn)(
|
|
4561
4530
|
this,
|
|
4562
4531
|
"SourceBuffer append failed; denylisting codec and requesting reload:",
|
|
4563
4532
|
mimeType
|
|
@@ -4591,7 +4560,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4591
4560
|
*/
|
|
4592
4561
|
clear() {
|
|
4593
4562
|
if (!this.active) return;
|
|
4594
|
-
(0,
|
|
4563
|
+
(0, import_vinyl_util46.logDebug)(this, "clear");
|
|
4595
4564
|
this.abortCurrentSegment();
|
|
4596
4565
|
this.queue.enqueue(this.finishAndClearBuffers).catch(this.handleError).finally(() => {
|
|
4597
4566
|
this.resetBufferedState();
|
|
@@ -4599,7 +4568,7 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4599
4568
|
});
|
|
4600
4569
|
}
|
|
4601
4570
|
endBuffering() {
|
|
4602
|
-
(0,
|
|
4571
|
+
(0, import_vinyl_util46.logDebug)(this, "bufferingEnded");
|
|
4603
4572
|
this._bufferingEnded = true;
|
|
4604
4573
|
this.bufferingQuality = null;
|
|
4605
4574
|
this.dispatch("bufferingEnded", {});
|
|
@@ -4611,7 +4580,6 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4611
4580
|
this._bufferingEnded = false;
|
|
4612
4581
|
this.bufferingQuality = null;
|
|
4613
4582
|
this.playbackQuality = null;
|
|
4614
|
-
this.setHasData(false);
|
|
4615
4583
|
}
|
|
4616
4584
|
get disposed() {
|
|
4617
4585
|
return this.disposer.disposed;
|
|
@@ -4624,15 +4592,15 @@ var BufferingControllerImpl = class extends import_vinyl_util50.EventHostImpl {
|
|
|
4624
4592
|
};
|
|
4625
4593
|
|
|
4626
4594
|
// src/streaming/buffering/MediaSourceController.ts
|
|
4627
|
-
var
|
|
4595
|
+
var import_vinyl_util49 = require("@amazon/vinyl-util");
|
|
4628
4596
|
|
|
4629
4597
|
// src/util/media/sourceBuffer.ts
|
|
4630
|
-
var
|
|
4631
|
-
var
|
|
4598
|
+
var import_vinyl_util47 = require("@amazon/vinyl-util");
|
|
4599
|
+
var import_vinyl_util48 = require("@amazon/vinyl-util");
|
|
4632
4600
|
function nextSourceBufferIdle(sourceBuffer) {
|
|
4633
4601
|
if (!sourceBuffer) return Promise.resolve();
|
|
4634
4602
|
if (!sourceBuffer.updating) return Promise.resolve();
|
|
4635
|
-
return (0,
|
|
4603
|
+
return (0, import_vinyl_util47.promise)((resolve, reject) => {
|
|
4636
4604
|
const removeListeners = () => {
|
|
4637
4605
|
sourceBuffer.removeEventListener("error", onErred);
|
|
4638
4606
|
sourceBuffer.removeEventListener("abort", onAborted);
|
|
@@ -4648,7 +4616,7 @@ function nextSourceBufferIdle(sourceBuffer) {
|
|
|
4648
4616
|
};
|
|
4649
4617
|
const onAborted = () => {
|
|
4650
4618
|
removeListeners();
|
|
4651
|
-
reject(new
|
|
4619
|
+
reject(new import_vinyl_util48.AbortError());
|
|
4652
4620
|
};
|
|
4653
4621
|
sourceBuffer.addEventListener("error", onErred);
|
|
4654
4622
|
sourceBuffer.addEventListener("abort", onAborted);
|
|
@@ -4658,7 +4626,7 @@ function nextSourceBufferIdle(sourceBuffer) {
|
|
|
4658
4626
|
|
|
4659
4627
|
// src/streaming/buffering/MediaSourceController.ts
|
|
4660
4628
|
var DURATION_PADDING = 0.1;
|
|
4661
|
-
var MediaSourceControllerImpl = class extends
|
|
4629
|
+
var MediaSourceControllerImpl = class extends import_vinyl_util49.EventHostImpl {
|
|
4662
4630
|
constructor(deps) {
|
|
4663
4631
|
super();
|
|
4664
4632
|
__publicField(this, "deps", deps);
|
|
@@ -4674,7 +4642,7 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4674
4642
|
*/
|
|
4675
4643
|
__publicField(this, "durationToken", 0);
|
|
4676
4644
|
__publicField(this, "errorHandler", (error) => {
|
|
4677
|
-
if ((0,
|
|
4645
|
+
if ((0, import_vinyl_util49.isSilentError)(error)) return;
|
|
4678
4646
|
this.dispatch("error", {
|
|
4679
4647
|
target: this,
|
|
4680
4648
|
error
|
|
@@ -4695,12 +4663,12 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4695
4663
|
return this.activateDisposer != null;
|
|
4696
4664
|
}
|
|
4697
4665
|
activate() {
|
|
4698
|
-
this.activateDisposer = (0,
|
|
4666
|
+
this.activateDisposer = (0, import_vinyl_util49.createDisposer)();
|
|
4699
4667
|
const add = this.activateDisposer.add;
|
|
4700
4668
|
const mediaSource = this.deps.mediaSourceFactory();
|
|
4701
4669
|
this.mediaSource = mediaSource;
|
|
4702
4670
|
const domEvents = add(
|
|
4703
|
-
new
|
|
4671
|
+
new import_vinyl_util49.DomEventHost(mediaSource)
|
|
4704
4672
|
);
|
|
4705
4673
|
domEvents.on("sourceopen", () => {
|
|
4706
4674
|
this.refreshDuration().catch(this.errorHandler);
|
|
@@ -4714,7 +4682,7 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4714
4682
|
"sourceOpen",
|
|
4715
4683
|
"sourceEnded"
|
|
4716
4684
|
]) {
|
|
4717
|
-
domEvents.on((0,
|
|
4685
|
+
domEvents.on((0, import_vinyl_util49.toLowerCase)(key), () => this.dispatch(key, {}));
|
|
4718
4686
|
}
|
|
4719
4687
|
add(
|
|
4720
4688
|
this.deps.mediaTimelineTransformed.onData(() => {
|
|
@@ -4743,7 +4711,7 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4743
4711
|
try {
|
|
4744
4712
|
URL.revokeObjectURL(this.objectUrl);
|
|
4745
4713
|
} catch (error) {
|
|
4746
|
-
(0,
|
|
4714
|
+
(0, import_vinyl_util49.logWarn)(this, "error revoking object url", error);
|
|
4747
4715
|
}
|
|
4748
4716
|
}
|
|
4749
4717
|
get sourceBufferCount() {
|
|
@@ -4764,9 +4732,9 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4764
4732
|
const duration = await timeline.getDuration();
|
|
4765
4733
|
const value = duration === Infinity ? LIVE_DURATION : duration + DURATION_PADDING;
|
|
4766
4734
|
await Promise.all(Array.from(this.sourceBuffers, nextSourceBufferIdle));
|
|
4767
|
-
if (token !== this.durationToken || mediaSource.readyState !== "open" || (0,
|
|
4735
|
+
if (token !== this.durationToken || mediaSource.readyState !== "open" || (0, import_vinyl_util49.closeTo)(mediaSource.duration, value, 0.1))
|
|
4768
4736
|
return;
|
|
4769
|
-
(0,
|
|
4737
|
+
(0, import_vinyl_util49.logDebug)(this, `setting duration: ${value}`);
|
|
4770
4738
|
mediaSource.duration = value;
|
|
4771
4739
|
this.durationSet = true;
|
|
4772
4740
|
this.checkReady();
|
|
@@ -4777,12 +4745,12 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4777
4745
|
}
|
|
4778
4746
|
createSourceBuffer(contentType2, mimeType) {
|
|
4779
4747
|
if (!this.active) {
|
|
4780
|
-
throw new
|
|
4748
|
+
throw new import_vinyl_util49.IllegalStateError(
|
|
4781
4749
|
"cannot create a source buffer when not active"
|
|
4782
4750
|
);
|
|
4783
4751
|
}
|
|
4784
4752
|
const mediaSource = this.mediaSource;
|
|
4785
|
-
(0,
|
|
4753
|
+
(0, import_vinyl_util49.logDebug)(
|
|
4786
4754
|
this,
|
|
4787
4755
|
"create source buffer",
|
|
4788
4756
|
contentType2,
|
|
@@ -4803,7 +4771,7 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4803
4771
|
return {
|
|
4804
4772
|
value: sourceBuffer,
|
|
4805
4773
|
dispose: () => {
|
|
4806
|
-
(0,
|
|
4774
|
+
(0, import_vinyl_util49.logDebug)(
|
|
4807
4775
|
this,
|
|
4808
4776
|
"removing source buffer from media source",
|
|
4809
4777
|
mediaSource.readyState
|
|
@@ -4817,7 +4785,7 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4817
4785
|
}
|
|
4818
4786
|
endOfStream(error) {
|
|
4819
4787
|
var _a;
|
|
4820
|
-
(0,
|
|
4788
|
+
(0, import_vinyl_util49.logDebug)(this, "endOfStream, error:", error);
|
|
4821
4789
|
(_a = this.mediaSource) == null ? void 0 : _a.endOfStream(error);
|
|
4822
4790
|
}
|
|
4823
4791
|
get readyToAppend() {
|
|
@@ -4829,9 +4797,9 @@ var MediaSourceControllerImpl = class extends import_vinyl_util53.EventHostImpl
|
|
|
4829
4797
|
this.deactivate();
|
|
4830
4798
|
}
|
|
4831
4799
|
};
|
|
4832
|
-
var MediaSourceError = class _MediaSourceError extends
|
|
4800
|
+
var MediaSourceError = class _MediaSourceError extends import_vinyl_util49.ReportableError {
|
|
4833
4801
|
constructor(message, reason) {
|
|
4834
|
-
super(message,
|
|
4802
|
+
super(message, import_vinyl_util49.ErrorOrigin.INTERNAL, import_vinyl_util49.ErrorLevel.FATAL);
|
|
4835
4803
|
__publicField(this, "reason", reason);
|
|
4836
4804
|
Object.setPrototypeOf(this, _MediaSourceError.prototype);
|
|
4837
4805
|
}
|
|
@@ -4840,13 +4808,13 @@ var MediaSourceError = class _MediaSourceError extends import_vinyl_util53.Repor
|
|
|
4840
4808
|
}
|
|
4841
4809
|
toJSON() {
|
|
4842
4810
|
return __spreadProps(__spreadValues({}, super.toJSON()), {
|
|
4843
|
-
reason: (0,
|
|
4811
|
+
reason: (0, import_vinyl_util49.toJson)(this.reason)
|
|
4844
4812
|
});
|
|
4845
4813
|
}
|
|
4846
4814
|
};
|
|
4847
4815
|
|
|
4848
4816
|
// src/streaming/buffering/SourceBufferController.ts
|
|
4849
|
-
var
|
|
4817
|
+
var import_vinyl_util50 = require("@amazon/vinyl-util");
|
|
4850
4818
|
var APPEND_WINDOW_START_OFFSET = 0.05;
|
|
4851
4819
|
var APPEND_WINDOW_END_OFFSET = 0.01;
|
|
4852
4820
|
var READY_TO_APPEND_TIMEOUT = 30;
|
|
@@ -4855,7 +4823,7 @@ var SourceBufferControllerImpl = class {
|
|
|
4855
4823
|
__publicField(this, "contentType", contentType2);
|
|
4856
4824
|
__publicField(this, "sourceBufferRef", null);
|
|
4857
4825
|
__publicField(this, "mimeType", null);
|
|
4858
|
-
__publicField(this, "queue", /* @__PURE__ */ (0,
|
|
4826
|
+
__publicField(this, "queue", /* @__PURE__ */ (0, import_vinyl_util50.createTaskQueue)());
|
|
4859
4827
|
// Assigned in the constructor body: a field initializer runs before the
|
|
4860
4828
|
// contentType param-property, so it would capture `undefined`.
|
|
4861
4829
|
__publicField(this, "logPrefix");
|
|
@@ -4872,8 +4840,8 @@ var SourceBufferControllerImpl = class {
|
|
|
4872
4840
|
* @private
|
|
4873
4841
|
*/
|
|
4874
4842
|
__publicField(this, "nextIdle", () => nextSourceBufferIdle(this.sourceBuffer).finally(this.clearBufferedCache));
|
|
4875
|
-
this.logPrefix = (0,
|
|
4876
|
-
(0,
|
|
4843
|
+
this.logPrefix = (0, import_vinyl_util50.createLogPrefix)(`SourceBuffer_${contentType2}`);
|
|
4844
|
+
(0, import_vinyl_util50.logDebug)(this, "constructed, contentType:", contentType2);
|
|
4877
4845
|
this.mediaSourceController = deps.mediaSourceController;
|
|
4878
4846
|
}
|
|
4879
4847
|
get [Symbol.toStringTag]() {
|
|
@@ -4884,9 +4852,9 @@ var SourceBufferControllerImpl = class {
|
|
|
4884
4852
|
}
|
|
4885
4853
|
get buffered() {
|
|
4886
4854
|
if (this._buffered == null) {
|
|
4887
|
-
if (!this.sourceBuffer) this._buffered =
|
|
4855
|
+
if (!this.sourceBuffer) this._buffered = import_vinyl_util50.emptyRanges;
|
|
4888
4856
|
else
|
|
4889
|
-
this._buffered = (0,
|
|
4857
|
+
this._buffered = (0, import_vinyl_util50.createTimeRangesReader)(
|
|
4890
4858
|
this.sourceBuffer.buffered
|
|
4891
4859
|
);
|
|
4892
4860
|
}
|
|
@@ -4903,7 +4871,7 @@ var SourceBufferControllerImpl = class {
|
|
|
4903
4871
|
var _a;
|
|
4904
4872
|
if (this.mimeType !== mimeType) {
|
|
4905
4873
|
if (this.sourceBuffer && "changeType" in this.sourceBuffer) {
|
|
4906
|
-
(0,
|
|
4874
|
+
(0, import_vinyl_util50.logDebug)(this, "changeType", mimeType);
|
|
4907
4875
|
this.sourceBuffer.changeType(mimeType);
|
|
4908
4876
|
} else {
|
|
4909
4877
|
(_a = this.sourceBufferRef) == null ? void 0 : _a.dispose();
|
|
@@ -4912,7 +4880,7 @@ var SourceBufferControllerImpl = class {
|
|
|
4912
4880
|
mimeType
|
|
4913
4881
|
);
|
|
4914
4882
|
if (!this.mediaSourceController.readyToAppend)
|
|
4915
|
-
await (0,
|
|
4883
|
+
await (0, import_vinyl_util50.nextEventAsPromise)(
|
|
4916
4884
|
this.mediaSourceController,
|
|
4917
4885
|
"readyToAppend",
|
|
4918
4886
|
{ timeout: READY_TO_APPEND_TIMEOUT, abort }
|
|
@@ -4925,34 +4893,34 @@ var SourceBufferControllerImpl = class {
|
|
|
4925
4893
|
this.mimeType = mimeType;
|
|
4926
4894
|
}
|
|
4927
4895
|
const sourceBuffer = this.sourceBuffer;
|
|
4928
|
-
(0,
|
|
4896
|
+
(0, import_vinyl_util50.logDebug)(this, `appending init ${data3.byteLength} bytes`);
|
|
4929
4897
|
sourceBuffer.appendBuffer(data3);
|
|
4930
4898
|
await this.nextIdle();
|
|
4931
|
-
(0,
|
|
4899
|
+
(0, import_vinyl_util50.logDebug)(this, "appended init");
|
|
4932
4900
|
});
|
|
4933
4901
|
}
|
|
4934
4902
|
async append(data3) {
|
|
4935
4903
|
return this.queue.enqueue(async () => {
|
|
4936
|
-
(0,
|
|
4904
|
+
(0, import_vinyl_util50.logDebug)(this, `appending ${data3.byteLength} bytes`);
|
|
4937
4905
|
const sourceBuffer = this.sourceBuffer;
|
|
4938
4906
|
if (!sourceBuffer)
|
|
4939
4907
|
throw new SourceBufferError(
|
|
4940
4908
|
"media segment provided before init segment",
|
|
4941
|
-
|
|
4909
|
+
import_vinyl_util50.ErrorOrigin.INTERNAL
|
|
4942
4910
|
);
|
|
4943
4911
|
sourceBuffer.appendBuffer(data3);
|
|
4944
4912
|
await this.nextIdle();
|
|
4945
|
-
(0,
|
|
4913
|
+
(0, import_vinyl_util50.logDebug)(this, "appended", this.buffered);
|
|
4946
4914
|
});
|
|
4947
4915
|
}
|
|
4948
4916
|
setTimestampOffset(timestampOffset) {
|
|
4949
4917
|
return this.queue.enqueue(() => {
|
|
4950
4918
|
const sourceBuffer = this.sourceBuffer;
|
|
4951
4919
|
if (!sourceBuffer)
|
|
4952
|
-
throw new
|
|
4920
|
+
throw new import_vinyl_util50.IllegalStateError(
|
|
4953
4921
|
"source buffer must be initialized before setting timestamp offset"
|
|
4954
4922
|
);
|
|
4955
|
-
(0,
|
|
4923
|
+
(0, import_vinyl_util50.logDebug)(this, "timestampOffset:", timestampOffset.toFixed(4));
|
|
4956
4924
|
sourceBuffer.timestampOffset = timestampOffset;
|
|
4957
4925
|
});
|
|
4958
4926
|
}
|
|
@@ -4960,7 +4928,7 @@ var SourceBufferControllerImpl = class {
|
|
|
4960
4928
|
return this.queue.enqueue(() => {
|
|
4961
4929
|
const sourceBuffer = this.sourceBuffer;
|
|
4962
4930
|
if (!sourceBuffer)
|
|
4963
|
-
throw new
|
|
4931
|
+
throw new import_vinyl_util50.IllegalStateError(
|
|
4964
4932
|
"source buffer must be initialized before setting append window"
|
|
4965
4933
|
);
|
|
4966
4934
|
const finalAppendWindowStart = Math.max(
|
|
@@ -4968,7 +4936,7 @@ var SourceBufferControllerImpl = class {
|
|
|
4968
4936
|
appendWindowStart - APPEND_WINDOW_START_OFFSET
|
|
4969
4937
|
);
|
|
4970
4938
|
const finalAppendWindowEnd = appendWindowEnd + APPEND_WINDOW_END_OFFSET;
|
|
4971
|
-
(0,
|
|
4939
|
+
(0, import_vinyl_util50.logDebug)(
|
|
4972
4940
|
this,
|
|
4973
4941
|
"appendWindow:",
|
|
4974
4942
|
finalAppendWindowStart.toFixed(4),
|
|
@@ -4983,10 +4951,10 @@ var SourceBufferControllerImpl = class {
|
|
|
4983
4951
|
return this.queue.enqueue(async () => {
|
|
4984
4952
|
var _a;
|
|
4985
4953
|
if (endTime > startTime) {
|
|
4986
|
-
(0,
|
|
4954
|
+
(0, import_vinyl_util50.logDebug)(this, `removing range: ${startTime}-${endTime}`);
|
|
4987
4955
|
(_a = this.sourceBuffer) == null ? void 0 : _a.remove(startTime, endTime);
|
|
4988
4956
|
await this.nextIdle();
|
|
4989
|
-
(0,
|
|
4957
|
+
(0, import_vinyl_util50.logDebug)(this, "removed, new buffered:", this.buffered);
|
|
4990
4958
|
}
|
|
4991
4959
|
});
|
|
4992
4960
|
}
|
|
@@ -4998,7 +4966,7 @@ var SourceBufferControllerImpl = class {
|
|
|
4998
4966
|
*/
|
|
4999
4967
|
dispose() {
|
|
5000
4968
|
var _a;
|
|
5001
|
-
(0,
|
|
4969
|
+
(0, import_vinyl_util50.logDebug)(this, "dispose");
|
|
5002
4970
|
this.queue.abort();
|
|
5003
4971
|
(_a = this.sourceBufferRef) == null ? void 0 : _a.dispose();
|
|
5004
4972
|
this.sourceBufferRef = null;
|
|
@@ -5006,35 +4974,34 @@ var SourceBufferControllerImpl = class {
|
|
|
5006
4974
|
};
|
|
5007
4975
|
|
|
5008
4976
|
// src/streaming/ContentStream.ts
|
|
5009
|
-
var
|
|
4977
|
+
var import_vinyl_util51 = require("@amazon/vinyl-util");
|
|
5010
4978
|
var import_vinyl_di = require("@amazon/vinyl-di");
|
|
5011
|
-
var ContentStreamImpl = class extends
|
|
4979
|
+
var ContentStreamImpl = class extends import_vinyl_util51.EventHostImpl {
|
|
5012
4980
|
constructor(dependencyFactories, contentType2) {
|
|
5013
4981
|
super();
|
|
5014
4982
|
__publicField(this, "contentType", contentType2);
|
|
5015
4983
|
// Assigned in the constructor body: a field initializer runs before the
|
|
5016
4984
|
// contentType param-property, so it would capture `undefined`.
|
|
5017
4985
|
__publicField(this, "logPrefix");
|
|
5018
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
4986
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util51.createDisposer)());
|
|
5019
4987
|
__publicField(this, "segmentController");
|
|
5020
4988
|
__publicField(this, "bufferingController");
|
|
5021
|
-
this.logPrefix = (0,
|
|
4989
|
+
this.logPrefix = (0, import_vinyl_util51.createLogPrefix)(`ContentStream_${contentType2}`);
|
|
5022
4990
|
const { add } = this.disposer;
|
|
5023
4991
|
const deps = add((0, import_vinyl_di.createContainer)(dependencyFactories)).dependencies;
|
|
5024
4992
|
this.segmentController = deps.segmentController;
|
|
5025
|
-
(0,
|
|
4993
|
+
(0, import_vinyl_util51.redispatchEvents)(this, this.segmentController, [
|
|
5026
4994
|
"fetchedRangesChange",
|
|
5027
4995
|
"loadSpanMeasured"
|
|
5028
4996
|
]);
|
|
5029
4997
|
this.bufferingController = deps.bufferingController;
|
|
5030
|
-
(0,
|
|
4998
|
+
(0, import_vinyl_util51.redispatchEvents)(this, this.segmentController, [
|
|
5031
4999
|
"streamingQualityChange"
|
|
5032
5000
|
]);
|
|
5033
|
-
(0,
|
|
5001
|
+
(0, import_vinyl_util51.redispatchEvents)(this, this.bufferingController, [
|
|
5034
5002
|
"bufferingQualityChange",
|
|
5035
5003
|
"playbackQualityChange",
|
|
5036
5004
|
"bufferingEnded",
|
|
5037
|
-
"hasDataChange",
|
|
5038
5005
|
"error",
|
|
5039
5006
|
"codecUnsupported"
|
|
5040
5007
|
]);
|
|
@@ -5064,9 +5031,6 @@ var ContentStreamImpl = class extends import_vinyl_util55.EventHostImpl {
|
|
|
5064
5031
|
var _a;
|
|
5065
5032
|
return (_a = this.bufferingController.playbackQuality) != null ? _a : null;
|
|
5066
5033
|
}
|
|
5067
|
-
get hasData() {
|
|
5068
|
-
return this.bufferingController.hasData;
|
|
5069
|
-
}
|
|
5070
5034
|
get bufferingEnded() {
|
|
5071
5035
|
return this.bufferingController.bufferingEnded;
|
|
5072
5036
|
}
|
|
@@ -5080,7 +5044,7 @@ var ContentStreamImpl = class extends import_vinyl_util55.EventHostImpl {
|
|
|
5080
5044
|
* for example, changing streaming quality from SD to HD.
|
|
5081
5045
|
*/
|
|
5082
5046
|
clearPrefetch() {
|
|
5083
|
-
(0,
|
|
5047
|
+
(0, import_vinyl_util51.logDebug)(this, "clearPrefetch");
|
|
5084
5048
|
this.segmentController.clear();
|
|
5085
5049
|
this.bufferingController.clear();
|
|
5086
5050
|
}
|
|
@@ -5094,7 +5058,7 @@ var ContentStreamImpl = class extends import_vinyl_util55.EventHostImpl {
|
|
|
5094
5058
|
}
|
|
5095
5059
|
activate(options) {
|
|
5096
5060
|
var _a;
|
|
5097
|
-
(0,
|
|
5061
|
+
(0, import_vinyl_util51.logDebug)(this, "activate");
|
|
5098
5062
|
this.segmentController.configure({
|
|
5099
5063
|
startTime: (_a = options.startTime) != null ? _a : 0
|
|
5100
5064
|
});
|
|
@@ -5145,15 +5109,15 @@ function filterContentTypes(contentTypes, allowedContentTypes) {
|
|
|
5145
5109
|
var import_vinyl_observable2 = require("@amazon/vinyl-observable");
|
|
5146
5110
|
|
|
5147
5111
|
// src/streaming/mediaTimelineFilter.ts
|
|
5148
|
-
var
|
|
5112
|
+
var import_vinyl_util54 = require("@amazon/vinyl-util");
|
|
5149
5113
|
|
|
5150
5114
|
// src/streaming/mediaTimelineLanguageFilter.ts
|
|
5151
|
-
var
|
|
5115
|
+
var import_vinyl_util53 = require("@amazon/vinyl-util");
|
|
5152
5116
|
|
|
5153
5117
|
// src/track/filters/languageFilter.ts
|
|
5154
|
-
var
|
|
5118
|
+
var import_vinyl_util52 = require("@amazon/vinyl-util");
|
|
5155
5119
|
function throwLanguagesUnsupported() {
|
|
5156
|
-
throw new
|
|
5120
|
+
throw new import_vinyl_util52.MediaUnsupportedError(
|
|
5157
5121
|
"No content matching preferred language",
|
|
5158
5122
|
"language"
|
|
5159
5123
|
);
|
|
@@ -5383,9 +5347,9 @@ function languageRelatedness(target, candidate) {
|
|
|
5383
5347
|
return 1;
|
|
5384
5348
|
}
|
|
5385
5349
|
function findBestLanguageMatch(target, available) {
|
|
5386
|
-
return (0,
|
|
5350
|
+
return (0, import_vinyl_util52.max)(
|
|
5387
5351
|
available,
|
|
5388
|
-
(0,
|
|
5352
|
+
(0, import_vinyl_util52.compareBy)((lang) => languageRelatedness(target, lang))
|
|
5389
5353
|
);
|
|
5390
5354
|
}
|
|
5391
5355
|
|
|
@@ -5409,7 +5373,7 @@ function createLanguageFilter(preferredLanguage, contentType2) {
|
|
|
5409
5373
|
}
|
|
5410
5374
|
return best;
|
|
5411
5375
|
};
|
|
5412
|
-
const bestScoreForPeriod = (0,
|
|
5376
|
+
const bestScoreForPeriod = (0, import_vinyl_util53.memoize)(
|
|
5413
5377
|
(array6) => {
|
|
5414
5378
|
let best = 0;
|
|
5415
5379
|
for (const quality of Array.from(array6)) {
|
|
@@ -5434,8 +5398,8 @@ function createLanguageFilter(preferredLanguage, contentType2) {
|
|
|
5434
5398
|
// src/streaming/mediaTimelineFilter.ts
|
|
5435
5399
|
function filterTimelineQualities(filter, throwError, timeline) {
|
|
5436
5400
|
if (!filter) return timeline;
|
|
5437
|
-
const mapMetadataArray = (0,
|
|
5438
|
-
(qualities) => (0,
|
|
5401
|
+
const mapMetadataArray = (0, import_vinyl_util54.memoize)(
|
|
5402
|
+
(qualities) => (0, import_vinyl_util54.map)(qualities, (q) => q.metadata),
|
|
5439
5403
|
(qualities) => qualities,
|
|
5440
5404
|
1
|
|
5441
5405
|
);
|
|
@@ -5451,8 +5415,8 @@ function filterTimelineQualities(filter, throwError, timeline) {
|
|
|
5451
5415
|
return __spreadProps(__spreadValues({}, timeline), { periods });
|
|
5452
5416
|
}
|
|
5453
5417
|
async function filterTimelineQualitiesAsync(filter, throwError, timeline) {
|
|
5454
|
-
const mapMetadataArray = (0,
|
|
5455
|
-
(qualities) => (0,
|
|
5418
|
+
const mapMetadataArray = (0, import_vinyl_util54.memoize)(
|
|
5419
|
+
(qualities) => (0, import_vinyl_util54.map)(qualities, (q) => q.metadata),
|
|
5456
5420
|
(qualities) => qualities,
|
|
5457
5421
|
1
|
|
5458
5422
|
);
|
|
@@ -5474,9 +5438,9 @@ async function filterTimelineQualitiesAsync(filter, throwError, timeline) {
|
|
|
5474
5438
|
}
|
|
5475
5439
|
|
|
5476
5440
|
// src/streaming/mediaTimelineAccessibilityFilter.ts
|
|
5477
|
-
var
|
|
5441
|
+
var import_vinyl_util55 = require("@amazon/vinyl-util");
|
|
5478
5442
|
function throwNoPlayableAudio() {
|
|
5479
|
-
throw new
|
|
5443
|
+
throw new import_vinyl_util55.MediaUnsupportedError("No playable audio rendition", "audio");
|
|
5480
5444
|
}
|
|
5481
5445
|
var AUDIO_DESCRIPTION_CHARACTERISTICS = [
|
|
5482
5446
|
"public.accessibility.describes-video",
|
|
@@ -5488,7 +5452,7 @@ function isAudioDescription(quality) {
|
|
|
5488
5452
|
);
|
|
5489
5453
|
}
|
|
5490
5454
|
function createAudioDescriptionFilter(preferDescription) {
|
|
5491
|
-
const periodFlags = (0,
|
|
5455
|
+
const periodFlags = (0, import_vinyl_util55.memoize)(
|
|
5492
5456
|
(array6) => {
|
|
5493
5457
|
let hasDescription = false;
|
|
5494
5458
|
let hasMain = false;
|
|
@@ -5515,9 +5479,9 @@ function createAudioDescriptionFilter(preferDescription) {
|
|
|
5515
5479
|
}
|
|
5516
5480
|
|
|
5517
5481
|
// src/track/filters/resourceTypeFilter.ts
|
|
5518
|
-
var
|
|
5482
|
+
var import_vinyl_util56 = require("@amazon/vinyl-util");
|
|
5519
5483
|
function throwMimeTypesUnsupported() {
|
|
5520
|
-
throw new
|
|
5484
|
+
throw new import_vinyl_util56.MediaUnsupportedError(
|
|
5521
5485
|
"No resource type supported (container/codec).",
|
|
5522
5486
|
"resource-type"
|
|
5523
5487
|
);
|
|
@@ -5528,9 +5492,9 @@ function canPlayMimeType(deps, metadata) {
|
|
|
5528
5492
|
}
|
|
5529
5493
|
|
|
5530
5494
|
// src/track/filters/keySystemFilter.ts
|
|
5531
|
-
var
|
|
5495
|
+
var import_vinyl_util57 = require("@amazon/vinyl-util");
|
|
5532
5496
|
function throwKeySystemsUnsupported() {
|
|
5533
|
-
throw new
|
|
5497
|
+
throw new import_vinyl_util57.MediaUnsupportedError("No key system supported.", "key-system");
|
|
5534
5498
|
}
|
|
5535
5499
|
async function canPlayKeySystem(deps, metadata) {
|
|
5536
5500
|
if (!metadata.contentProtections.length) return true;
|
|
@@ -5538,32 +5502,32 @@ async function canPlayKeySystem(deps, metadata) {
|
|
|
5538
5502
|
}
|
|
5539
5503
|
|
|
5540
5504
|
// src/track/filters/sampleRateFilter.ts
|
|
5541
|
-
var
|
|
5505
|
+
var import_vinyl_util58 = require("@amazon/vinyl-util");
|
|
5542
5506
|
function throwSamplingRatesUnsupported() {
|
|
5543
|
-
throw new
|
|
5544
|
-
}
|
|
5545
|
-
function
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
const samplingRate = (0,
|
|
5549
|
-
if (!samplingRate
|
|
5550
|
-
|
|
5507
|
+
throw new import_vinyl_util58.MediaUnsupportedError("No supported sample rate", "sampling-rate");
|
|
5508
|
+
}
|
|
5509
|
+
function withinAudioSampleRateRange(options, metadata, _index, array6) {
|
|
5510
|
+
var _a;
|
|
5511
|
+
if (metadata.contentType !== "audio") return true;
|
|
5512
|
+
const samplingRate = (0, import_vinyl_util58.last)(metadata.audioSamplingRate);
|
|
5513
|
+
if (!samplingRate) return true;
|
|
5514
|
+
const audioRates = () => (0, import_vinyl_util58.map)(
|
|
5515
|
+
array6,
|
|
5516
|
+
(item) => item.contentType === "audio" ? (0, import_vinyl_util58.last)(item.audioSamplingRate) : void 0
|
|
5517
|
+
).filter((rate) => rate != null);
|
|
5518
|
+
const { minSampleRate } = options;
|
|
5519
|
+
if (minSampleRate != null && samplingRate < minSampleRate) {
|
|
5520
|
+
const rates2 = audioRates();
|
|
5521
|
+
return (0, import_vinyl_util58.every)(rates2, (rate) => rate < minSampleRate) && samplingRate === (0, import_vinyl_util58.max)(rates2);
|
|
5522
|
+
}
|
|
5523
|
+
const maxSampleRate = (_a = options.maxSampleRate) != null ? _a : options.capabilities.sampleRate;
|
|
5524
|
+
if (!maxSampleRate) return true;
|
|
5525
|
+
if ((0, import_vinyl_util58.hasBrowser)(import_vinyl_util58.Browser.FIREFOX)) {
|
|
5551
5526
|
return samplingRate <= 48e3;
|
|
5552
5527
|
}
|
|
5553
5528
|
if (samplingRate <= maxSampleRate) return true;
|
|
5554
|
-
const
|
|
5555
|
-
|
|
5556
|
-
return itemSamplingRate != null && itemSamplingRate > maxSampleRate;
|
|
5557
|
-
});
|
|
5558
|
-
if (allAboveMax) {
|
|
5559
|
-
const samplingRates = (0, import_vinyl_util62.map)(
|
|
5560
|
-
array6,
|
|
5561
|
-
(item) => (0, import_vinyl_util62.last)(item.audioSamplingRate)
|
|
5562
|
-
).filter((rate) => rate != null);
|
|
5563
|
-
const lowestSamplingRate = (0, import_vinyl_util62.min)(samplingRates);
|
|
5564
|
-
return samplingRate === lowestSamplingRate;
|
|
5565
|
-
}
|
|
5566
|
-
return false;
|
|
5529
|
+
const rates = audioRates();
|
|
5530
|
+
return (0, import_vinyl_util58.every)(rates, (rate) => rate > maxSampleRate) && samplingRate === (0, import_vinyl_util58.min)(rates);
|
|
5567
5531
|
}
|
|
5568
5532
|
|
|
5569
5533
|
// src/util/media/codecOverrides.ts
|
|
@@ -5599,8 +5563,8 @@ function createDefaultMediaTimelineTransformer(deps) {
|
|
|
5599
5563
|
return canPlayMimeType(deps, quality);
|
|
5600
5564
|
}
|
|
5601
5565
|
async function transformTimeline(timeline) {
|
|
5602
|
-
var _a, _b;
|
|
5603
|
-
const codecOverrides = deps.options.value
|
|
5566
|
+
var _a, _b, _c, _d;
|
|
5567
|
+
const { audio, codecOverrides } = deps.options.value;
|
|
5604
5568
|
let t = filterTimelineQualities(
|
|
5605
5569
|
(quality) => canPlayWithOverrides(quality, codecOverrides),
|
|
5606
5570
|
throwMimeTypesUnsupported,
|
|
@@ -5611,19 +5575,31 @@ function createDefaultMediaTimelineTransformer(deps) {
|
|
|
5611
5575
|
throwKeySystemsUnsupported,
|
|
5612
5576
|
t
|
|
5613
5577
|
);
|
|
5578
|
+
if (!audio.disableSampleRateFilter) {
|
|
5579
|
+
const sampleRateOptions = {
|
|
5580
|
+
capabilities: deps.capabilities,
|
|
5581
|
+
maxSampleRate: (_a = audio.maxSampleRate) != null ? _a : null,
|
|
5582
|
+
minSampleRate: (_b = audio.minSampleRate) != null ? _b : null
|
|
5583
|
+
};
|
|
5584
|
+
t = filterTimelineQualities(
|
|
5585
|
+
(quality, index, array6) => withinAudioSampleRateRange(
|
|
5586
|
+
sampleRateOptions,
|
|
5587
|
+
quality,
|
|
5588
|
+
index,
|
|
5589
|
+
array6
|
|
5590
|
+
),
|
|
5591
|
+
throwSamplingRatesUnsupported,
|
|
5592
|
+
t
|
|
5593
|
+
);
|
|
5594
|
+
}
|
|
5595
|
+
const selection = audio.selection;
|
|
5614
5596
|
t = filterTimelineQualities(
|
|
5615
|
-
(
|
|
5616
|
-
throwSamplingRatesUnsupported,
|
|
5617
|
-
t
|
|
5618
|
-
);
|
|
5619
|
-
const selection = deps.options.value.audio.selection;
|
|
5620
|
-
t = filterTimelineQualities(
|
|
5621
|
-
createAudioDescriptionFilter((_a = selection == null ? void 0 : selection.descriptive) != null ? _a : false),
|
|
5597
|
+
createAudioDescriptionFilter((_c = selection == null ? void 0 : selection.descriptive) != null ? _c : false),
|
|
5622
5598
|
throwNoPlayableAudio,
|
|
5623
5599
|
t
|
|
5624
5600
|
);
|
|
5625
5601
|
t = filterTimelineQualities(
|
|
5626
|
-
createLanguageFilter((
|
|
5602
|
+
createLanguageFilter((_d = selection == null ? void 0 : selection.language) != null ? _d : null, "audio"),
|
|
5627
5603
|
throwLanguagesUnsupported,
|
|
5628
5604
|
t
|
|
5629
5605
|
);
|
|
@@ -5640,13 +5616,13 @@ function createDefaultMediaTimelineTransformer(deps) {
|
|
|
5640
5616
|
|
|
5641
5617
|
// src/streaming/DescriptorRecord.ts
|
|
5642
5618
|
var import_vinyl_validation9 = require("@amazon/vinyl-validation");
|
|
5643
|
-
var
|
|
5619
|
+
var import_vinyl_util59 = require("@amazon/vinyl-util");
|
|
5644
5620
|
function getDescriptorValue(record4, uri, id) {
|
|
5645
5621
|
var _a, _b;
|
|
5646
5622
|
let arr = record4[uri];
|
|
5647
5623
|
if (!arr) return null;
|
|
5648
5624
|
if (id !== void 0) arr = arr.filter((descriptor) => descriptor.id === id);
|
|
5649
|
-
return (_b = (_a = (0,
|
|
5625
|
+
return (_b = (_a = (0, import_vinyl_util59.first)(arr)) == null ? void 0 : _a.value) != null ? _b : null;
|
|
5650
5626
|
}
|
|
5651
5627
|
var descriptorValidator = /* @__PURE__ */ (0, import_vinyl_validation9.object)({
|
|
5652
5628
|
id: /* @__PURE__ */ (0, import_vinyl_validation9.string)().maybe().optional(),
|
|
@@ -5656,15 +5632,15 @@ var descriptorRecordValidator = /* @__PURE__ */ (0, import_vinyl_validation9.rec
|
|
|
5656
5632
|
|
|
5657
5633
|
// src/streaming/ManifestControllerImpl.ts
|
|
5658
5634
|
var import_vinyl_observable3 = require("@amazon/vinyl-observable");
|
|
5659
|
-
var
|
|
5635
|
+
var import_vinyl_util60 = require("@amazon/vinyl-util");
|
|
5660
5636
|
var ManifestControllerImpl = class {
|
|
5661
5637
|
constructor(deps) {
|
|
5662
5638
|
__publicField(this, "deps", deps);
|
|
5663
5639
|
__publicField(this, "_data");
|
|
5664
5640
|
__publicField(this, "_error", null);
|
|
5665
|
-
__publicField(this, "abortSlot", /* @__PURE__ */ (0,
|
|
5666
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
5667
|
-
__publicField(this, "events", /* @__PURE__ */ new
|
|
5641
|
+
__publicField(this, "abortSlot", /* @__PURE__ */ (0, import_vinyl_util60.createAbortSlot)());
|
|
5642
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util60.createDisposer)());
|
|
5643
|
+
__publicField(this, "events", /* @__PURE__ */ new import_vinyl_util60.EventHostImpl());
|
|
5668
5644
|
__publicField(this, "manifestSpanArmed", true);
|
|
5669
5645
|
__publicField(this, "__eventMapType", this.events.__eventMapType);
|
|
5670
5646
|
this._data = (0, import_vinyl_observable3.data)(this.requestManifest());
|
|
@@ -5691,7 +5667,7 @@ var ManifestControllerImpl = class {
|
|
|
5691
5667
|
return this._error;
|
|
5692
5668
|
}
|
|
5693
5669
|
refresh() {
|
|
5694
|
-
(0,
|
|
5670
|
+
(0, import_vinyl_util60.logDebug)(this, "refresh");
|
|
5695
5671
|
this._data.value = this.requestManifest();
|
|
5696
5672
|
}
|
|
5697
5673
|
requestManifest() {
|
|
@@ -5722,7 +5698,7 @@ var ManifestControllerImpl = class {
|
|
|
5722
5698
|
);
|
|
5723
5699
|
}
|
|
5724
5700
|
reset() {
|
|
5725
|
-
(0,
|
|
5701
|
+
(0, import_vinyl_util60.logDebug)(this, "reset");
|
|
5726
5702
|
if (this._error) {
|
|
5727
5703
|
this.refresh();
|
|
5728
5704
|
}
|
|
@@ -5756,7 +5732,7 @@ var ManifestControllerImpl = class {
|
|
|
5756
5732
|
};
|
|
5757
5733
|
|
|
5758
5734
|
// src/streaming/MediaQualityMetadata.ts
|
|
5759
|
-
var
|
|
5735
|
+
var import_vinyl_util61 = require("@amazon/vinyl-util");
|
|
5760
5736
|
var import_vinyl_validation10 = require("@amazon/vinyl-validation");
|
|
5761
5737
|
var ALL_CONTENT_TYPES = [
|
|
5762
5738
|
"video",
|
|
@@ -5790,8 +5766,8 @@ function createEmptyMediaFormatMetadata() {
|
|
|
5790
5766
|
}
|
|
5791
5767
|
function createEmptyMediaQualityMetadata() {
|
|
5792
5768
|
return __spreadProps(__spreadValues({}, createEmptyMediaFormatMetadata()), {
|
|
5793
|
-
decoderId: (0,
|
|
5794
|
-
qualityId: (0,
|
|
5769
|
+
decoderId: (0, import_vinyl_util61.createShortUid)(),
|
|
5770
|
+
qualityId: (0, import_vinyl_util61.createShortUid)(),
|
|
5795
5771
|
codecs: null,
|
|
5796
5772
|
bandwidth: null,
|
|
5797
5773
|
bandwidthTotal: null,
|
|
@@ -5802,7 +5778,7 @@ function createEmptyMediaQualityMetadata() {
|
|
|
5802
5778
|
width: null,
|
|
5803
5779
|
lang: null,
|
|
5804
5780
|
characteristics: [],
|
|
5805
|
-
groupId: (0,
|
|
5781
|
+
groupId: (0, import_vinyl_util61.createShortUid)(),
|
|
5806
5782
|
switchingGroupIds: null
|
|
5807
5783
|
});
|
|
5808
5784
|
}
|
|
@@ -5824,9 +5800,9 @@ var mediaQualityMetadataValidator = /* @__PURE__ */ mediaFormatMetadataValidator
|
|
|
5824
5800
|
});
|
|
5825
5801
|
|
|
5826
5802
|
// src/streaming/MediaTimeline.ts
|
|
5827
|
-
var
|
|
5803
|
+
var import_vinyl_util62 = require("@amazon/vinyl-util");
|
|
5828
5804
|
function getMediaPeriodAtTime(timeline, time) {
|
|
5829
|
-
const index = (0,
|
|
5805
|
+
const index = (0, import_vinyl_util62.sortedInsertionIndex)(timeline.periods, time, (time2, period2) => {
|
|
5830
5806
|
return time2 - period2.startTime;
|
|
5831
5807
|
}) - 1;
|
|
5832
5808
|
if (index < 0) return null;
|
|
@@ -5835,10 +5811,10 @@ function getMediaPeriodAtTime(timeline, time) {
|
|
|
5835
5811
|
}
|
|
5836
5812
|
|
|
5837
5813
|
// src/streaming/SegmentControllerImpl.ts
|
|
5838
|
-
var
|
|
5814
|
+
var import_vinyl_util66 = require("@amazon/vinyl-util");
|
|
5839
5815
|
|
|
5840
5816
|
// src/streaming/SegmentDataSlot.ts
|
|
5841
|
-
var
|
|
5817
|
+
var import_vinyl_util63 = require("@amazon/vinyl-util");
|
|
5842
5818
|
var SegmentStatus = /* @__PURE__ */ ((SegmentStatus2) => {
|
|
5843
5819
|
SegmentStatus2["INACTIVE"] = "inactive";
|
|
5844
5820
|
SegmentStatus2["PENDING"] = "pending";
|
|
@@ -5854,7 +5830,7 @@ var SegmentDataSlot = class {
|
|
|
5854
5830
|
*/
|
|
5855
5831
|
__publicField(this, "onStatusChange", null);
|
|
5856
5832
|
__publicField(this, "_status", "inactive" /* INACTIVE */);
|
|
5857
|
-
__publicField(this, "abortSlot", /* @__PURE__ */ (0,
|
|
5833
|
+
__publicField(this, "abortSlot", /* @__PURE__ */ (0, import_vinyl_util63.createAbortSlot)());
|
|
5858
5834
|
__publicField(this, "bufferPromise", null);
|
|
5859
5835
|
}
|
|
5860
5836
|
/**
|
|
@@ -5888,7 +5864,7 @@ var SegmentDataSlot = class {
|
|
|
5888
5864
|
this.status = "resolved" /* RESOLVED */;
|
|
5889
5865
|
return result;
|
|
5890
5866
|
}).catch((error) => {
|
|
5891
|
-
if ((0,
|
|
5867
|
+
if ((0, import_vinyl_util63.isSilentError)(error)) {
|
|
5892
5868
|
this.bufferPromise = null;
|
|
5893
5869
|
this.status = "inactive" /* INACTIVE */;
|
|
5894
5870
|
} else {
|
|
@@ -5909,7 +5885,7 @@ var SegmentDataSlot = class {
|
|
|
5909
5885
|
};
|
|
5910
5886
|
|
|
5911
5887
|
// src/streaming/SegmentPrefetch.ts
|
|
5912
|
-
var
|
|
5888
|
+
var import_vinyl_util64 = require("@amazon/vinyl-util");
|
|
5913
5889
|
var defaultTrackPriority = {
|
|
5914
5890
|
// Default priority is lowest, but not used. Use enqueueSegmentPrefetch to enqueue.
|
|
5915
5891
|
trackPriority: 0,
|
|
@@ -5923,8 +5899,8 @@ var immediatePrefetchPriority = {
|
|
|
5923
5899
|
segmentStartTime: 0,
|
|
5924
5900
|
prefetchStartTime: 0
|
|
5925
5901
|
};
|
|
5926
|
-
var segmentPriorityComparatorRef = /* @__PURE__ */ (0,
|
|
5927
|
-
return (0,
|
|
5902
|
+
var segmentPriorityComparatorRef = /* @__PURE__ */ (0, import_vinyl_util64.globalRef)(() => {
|
|
5903
|
+
return (0, import_vinyl_util64.compareBy)(
|
|
5928
5904
|
(e) => {
|
|
5929
5905
|
return e.segmentStartTime <= e.prefetchStartTime ? 0 : 1;
|
|
5930
5906
|
},
|
|
@@ -5932,17 +5908,17 @@ var segmentPriorityComparatorRef = /* @__PURE__ */ (0, import_vinyl_util68.globa
|
|
|
5932
5908
|
(e) => -e.trackPriority
|
|
5933
5909
|
);
|
|
5934
5910
|
});
|
|
5935
|
-
var prefetchPriorityQueuesRef = /* @__PURE__ */ (0,
|
|
5911
|
+
var prefetchPriorityQueuesRef = /* @__PURE__ */ (0, import_vinyl_util64.globalRef)(() => {
|
|
5936
5912
|
return {
|
|
5937
|
-
video: (0,
|
|
5913
|
+
video: (0, import_vinyl_util64.createTaskQueue)(
|
|
5938
5914
|
segmentPriorityComparatorRef.value,
|
|
5939
5915
|
defaultTrackPriority
|
|
5940
5916
|
),
|
|
5941
|
-
audio: (0,
|
|
5917
|
+
audio: (0, import_vinyl_util64.createTaskQueue)(
|
|
5942
5918
|
segmentPriorityComparatorRef.value,
|
|
5943
5919
|
defaultTrackPriority
|
|
5944
5920
|
),
|
|
5945
|
-
text: (0,
|
|
5921
|
+
text: (0, import_vinyl_util64.createTaskQueue)(
|
|
5946
5922
|
segmentPriorityComparatorRef.value,
|
|
5947
5923
|
defaultTrackPriority
|
|
5948
5924
|
)
|
|
@@ -5956,7 +5932,7 @@ function enqueueSegmentPrefetch(requestTask, contentType2, priority) {
|
|
|
5956
5932
|
}
|
|
5957
5933
|
|
|
5958
5934
|
// src/streaming/util/segment.ts
|
|
5959
|
-
var
|
|
5935
|
+
var import_vinyl_util65 = require("@amazon/vinyl-util");
|
|
5960
5936
|
function getSegmentAtTime(time, segments, affordance = 0) {
|
|
5961
5937
|
const index = getSegmentInsertionIndexAtTime(time + affordance, segments) - 1;
|
|
5962
5938
|
if (index < 0) return null;
|
|
@@ -5964,7 +5940,7 @@ function getSegmentAtTime(time, segments, affordance = 0) {
|
|
|
5964
5940
|
return time >= segment.endTime ? null : segment;
|
|
5965
5941
|
}
|
|
5966
5942
|
function getSegmentInsertionIndexAtTime(time, segments) {
|
|
5967
|
-
return (0,
|
|
5943
|
+
return (0, import_vinyl_util65.sortedInsertionIndex)(
|
|
5968
5944
|
segments,
|
|
5969
5945
|
time,
|
|
5970
5946
|
(time2, element2) => time2 - element2.startTime
|
|
@@ -5978,7 +5954,7 @@ var defaultSegmentControllerBaseOptions = {
|
|
|
5978
5954
|
prefetchInactive: 20,
|
|
5979
5955
|
retainTail: 30
|
|
5980
5956
|
};
|
|
5981
|
-
var SegmentControllerImpl = class extends
|
|
5957
|
+
var SegmentControllerImpl = class extends import_vinyl_util66.EventHostImpl {
|
|
5982
5958
|
constructor(deps, contentType2, options) {
|
|
5983
5959
|
super();
|
|
5984
5960
|
__publicField(this, "deps", deps);
|
|
@@ -5987,7 +5963,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
5987
5963
|
// contentType param-property, so it would capture `undefined`.
|
|
5988
5964
|
__publicField(this, "logPrefix");
|
|
5989
5965
|
__publicField(this, "_active", false);
|
|
5990
|
-
__publicField(this, "_fetchedRanges", /* @__PURE__ */ new
|
|
5966
|
+
__publicField(this, "_fetchedRanges", /* @__PURE__ */ new import_vinyl_util66.RangesImpl());
|
|
5991
5967
|
__publicField(this, "_startTime", 0);
|
|
5992
5968
|
/**
|
|
5993
5969
|
* A map of decoder id to init segment slots.
|
|
@@ -5996,9 +5972,9 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
5996
5972
|
*/
|
|
5997
5973
|
__publicField(this, "cachedInitSegments", /* @__PURE__ */ new Map());
|
|
5998
5974
|
__publicField(this, "cachedSegments", []);
|
|
5999
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
5975
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util66.createDisposer)());
|
|
6000
5976
|
__publicField(this, "options");
|
|
6001
|
-
__publicField(this, "prefetchingPriority", /* @__PURE__ */ (0,
|
|
5977
|
+
__publicField(this, "prefetchingPriority", /* @__PURE__ */ (0, import_vinyl_util66.clone)(defaultTrackPriority));
|
|
6002
5978
|
/**
|
|
6003
5979
|
* True if the last segment in the prefetch range has been cached.
|
|
6004
5980
|
*/
|
|
@@ -6013,13 +5989,13 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6013
5989
|
__publicField(this, "timeUpdateSub", null);
|
|
6014
5990
|
__publicField(this, "seekingSub", null);
|
|
6015
5991
|
// When disposed, aborts in-flight operations.
|
|
6016
|
-
__publicField(this, "abort", /* @__PURE__ */ new
|
|
5992
|
+
__publicField(this, "abort", /* @__PURE__ */ new import_vinyl_util66.Abort());
|
|
6017
5993
|
/**
|
|
6018
5994
|
* Cached last period lookup for fast repeated access.
|
|
6019
5995
|
*/
|
|
6020
5996
|
__publicField(this, "_cachedPeriod", null);
|
|
6021
5997
|
__publicField(this, "pollPrefetch", /* @__PURE__ */ this.disposer.add(
|
|
6022
|
-
/* @__PURE__ */ (0,
|
|
5998
|
+
/* @__PURE__ */ (0, import_vinyl_util66.throttle)(
|
|
6023
5999
|
() => {
|
|
6024
6000
|
if (this.error) return;
|
|
6025
6001
|
this.sweepCachedSegments();
|
|
@@ -6030,15 +6006,15 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6030
6006
|
enqueueSegmentPrefetch(
|
|
6031
6007
|
async () => {
|
|
6032
6008
|
this.abort.throwIfAborted();
|
|
6033
|
-
(0,
|
|
6009
|
+
(0, import_vinyl_util66.logDebug)(this, `Prefetching`, nextTime.toFixed(4));
|
|
6034
6010
|
const slot = await this.getSlotAtTime(nextTime);
|
|
6035
6011
|
this.abort.throwIfAborted();
|
|
6036
6012
|
if (!slot) {
|
|
6037
|
-
(0,
|
|
6013
|
+
(0, import_vinyl_util66.logDebug)(this, "prefetch ended");
|
|
6038
6014
|
this.ended = true;
|
|
6039
6015
|
return;
|
|
6040
6016
|
}
|
|
6041
|
-
await (0,
|
|
6017
|
+
await (0, import_vinyl_util66.withAbort)(
|
|
6042
6018
|
Promise.all([
|
|
6043
6019
|
this.requestInitData(slot),
|
|
6044
6020
|
this.requestSegmentData(slot)
|
|
@@ -6061,14 +6037,14 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6061
6037
|
)
|
|
6062
6038
|
));
|
|
6063
6039
|
__publicField(this, "prefetchErrorHandler", (error) => {
|
|
6064
|
-
if (!this.disposed && !(0,
|
|
6065
|
-
(0,
|
|
6040
|
+
if (!this.disposed && !(0, import_vinyl_util66.isSilentError)(error)) {
|
|
6041
|
+
(0, import_vinyl_util66.logError)(this, "Error prefetching segment", error);
|
|
6066
6042
|
this._error = error;
|
|
6067
6043
|
}
|
|
6068
6044
|
});
|
|
6069
6045
|
__publicField(this, "_streamingQuality", null);
|
|
6070
|
-
this.logPrefix = (0,
|
|
6071
|
-
(0,
|
|
6046
|
+
this.logPrefix = (0, import_vinyl_util66.createLogPrefix)(`Segment_${contentType2}`);
|
|
6047
|
+
(0, import_vinyl_util66.logDebug)(this, "constructed");
|
|
6072
6048
|
const { add } = this.disposer;
|
|
6073
6049
|
this.options = __spreadValues(__spreadValues({}, defaultSegmentControllerBaseOptions), options);
|
|
6074
6050
|
add(
|
|
@@ -6080,8 +6056,8 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6080
6056
|
})
|
|
6081
6057
|
);
|
|
6082
6058
|
add(
|
|
6083
|
-
(0,
|
|
6084
|
-
(0,
|
|
6059
|
+
(0, import_vinyl_util66.getNetworkState)().on("online", () => {
|
|
6060
|
+
(0, import_vinyl_util66.logDebug)(this, "online, resetting prefetch");
|
|
6085
6061
|
this.reset();
|
|
6086
6062
|
})
|
|
6087
6063
|
);
|
|
@@ -6163,10 +6139,10 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6163
6139
|
const cachedSegment = this.cachedSegments[i];
|
|
6164
6140
|
const { startTime, endTime } = cachedSegment;
|
|
6165
6141
|
const cachedRange = [startTime, endTime];
|
|
6166
|
-
if (!(0,
|
|
6142
|
+
if (!(0, import_vinyl_util66.rangeIntersects)(inactiveRange, cachedRange) && !(activeRange && (0, import_vinyl_util66.rangeIntersects)(activeRange, cachedRange))) {
|
|
6167
6143
|
cachedSegment.data.clear();
|
|
6168
6144
|
this.cachedSegments.splice(i, 1);
|
|
6169
|
-
(0,
|
|
6145
|
+
(0, import_vinyl_util66.logDebug)(
|
|
6170
6146
|
this,
|
|
6171
6147
|
"removing cached segment at: ",
|
|
6172
6148
|
cachedSegment.startTime
|
|
@@ -6241,15 +6217,15 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6241
6217
|
const previous = this._streamingQuality;
|
|
6242
6218
|
if ((value == null ? void 0 : value.qualityId) === (previous == null ? void 0 : previous.qualityId)) return;
|
|
6243
6219
|
this._streamingQuality = value;
|
|
6244
|
-
(0,
|
|
6220
|
+
(0, import_vinyl_util66.logDebug)(this, "streamingQualityChange", value);
|
|
6245
6221
|
this.dispatch("streamingQualityChange", {
|
|
6246
6222
|
previous,
|
|
6247
6223
|
current: value
|
|
6248
6224
|
});
|
|
6249
6225
|
}
|
|
6250
6226
|
getSegment(time, abort) {
|
|
6251
|
-
(0,
|
|
6252
|
-
const segmentReferencePromise = (0,
|
|
6227
|
+
(0, import_vinyl_util66.logDebug)(this, `requesting segment at time: ${time.toFixed(4)}`);
|
|
6228
|
+
const segmentReferencePromise = (0, import_vinyl_util66.withAbort)(
|
|
6253
6229
|
this._getSegment(Math.max(0, time)),
|
|
6254
6230
|
abort
|
|
6255
6231
|
);
|
|
@@ -6257,13 +6233,13 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6257
6233
|
() => segmentReferencePromise,
|
|
6258
6234
|
this.contentType,
|
|
6259
6235
|
immediatePrefetchPriority
|
|
6260
|
-
).catch(
|
|
6236
|
+
).catch(import_vinyl_util66.noop);
|
|
6261
6237
|
return segmentReferencePromise;
|
|
6262
6238
|
}
|
|
6263
6239
|
async _getSegment(time) {
|
|
6264
6240
|
const streamingSlot = await this.getSlotAtTime(time);
|
|
6265
6241
|
if (!streamingSlot) return null;
|
|
6266
|
-
(0,
|
|
6242
|
+
(0, import_vinyl_util66.logDebug)(
|
|
6267
6243
|
this,
|
|
6268
6244
|
`init status: ${streamingSlot.initData.status}, data status: ${streamingSlot.data.status}`
|
|
6269
6245
|
);
|
|
@@ -6277,7 +6253,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6277
6253
|
if (streamingSlot.endTime - time < minBufferTime) {
|
|
6278
6254
|
minBufferPrefetch = this.prefetchImmediate(
|
|
6279
6255
|
streamingSlot.endTime
|
|
6280
|
-
).catch(
|
|
6256
|
+
).catch(import_vinyl_util66.noop);
|
|
6281
6257
|
}
|
|
6282
6258
|
const [initData, data3] = await initAndDataPromise;
|
|
6283
6259
|
await minBufferPrefetch;
|
|
@@ -6318,7 +6294,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6318
6294
|
SEGMENT_START_AFFORDANCE
|
|
6319
6295
|
);
|
|
6320
6296
|
if (cachedSegment) return cachedSegment;
|
|
6321
|
-
const newSlot = await (0,
|
|
6297
|
+
const newSlot = await (0, import_vinyl_util66.withAbort)(
|
|
6322
6298
|
this.createSlotForTime(time),
|
|
6323
6299
|
this.abort
|
|
6324
6300
|
);
|
|
@@ -6337,11 +6313,11 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6337
6313
|
);
|
|
6338
6314
|
if (insertionIndex > 0) {
|
|
6339
6315
|
const cachedSegment2 = this.cachedSegments[insertionIndex - 1];
|
|
6340
|
-
if ((0,
|
|
6316
|
+
if ((0, import_vinyl_util66.closeTo)(newSlot.startTime, cachedSegment2.startTime)) {
|
|
6341
6317
|
return cachedSegment2;
|
|
6342
6318
|
}
|
|
6343
6319
|
}
|
|
6344
|
-
(0,
|
|
6320
|
+
(0, import_vinyl_util66.logDebug)(
|
|
6345
6321
|
this,
|
|
6346
6322
|
`created slot at ${insertionIndex} for time ${newSlot.startTime.toFixed(4)}`
|
|
6347
6323
|
);
|
|
@@ -6352,7 +6328,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6352
6328
|
* Gets a cached init segment slot for the given decoder id. If a slot is not cached, create one.
|
|
6353
6329
|
*/
|
|
6354
6330
|
getOrCreateInitSlot(decoderId, segmentDataProvider) {
|
|
6355
|
-
return (0,
|
|
6331
|
+
return (0, import_vinyl_util66.getOrSet)(this.cachedInitSegments, decoderId, () => {
|
|
6356
6332
|
return new SegmentDataSlot(segmentDataProvider);
|
|
6357
6333
|
});
|
|
6358
6334
|
}
|
|
@@ -6410,7 +6386,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6410
6386
|
*/
|
|
6411
6387
|
activate() {
|
|
6412
6388
|
if (this._active) return;
|
|
6413
|
-
(0,
|
|
6389
|
+
(0, import_vinyl_util66.logDebug)(this, "activate");
|
|
6414
6390
|
this._active = true;
|
|
6415
6391
|
this.pollPrefetch();
|
|
6416
6392
|
const playbackController = this.deps.playbackController;
|
|
@@ -6431,7 +6407,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6431
6407
|
*/
|
|
6432
6408
|
deactivate() {
|
|
6433
6409
|
if (!this._active) return;
|
|
6434
|
-
(0,
|
|
6410
|
+
(0, import_vinyl_util66.logDebug)(this, "deactivate");
|
|
6435
6411
|
this._active = false;
|
|
6436
6412
|
this.sweepCachedSegments();
|
|
6437
6413
|
this.timeUpdateSub();
|
|
@@ -6440,7 +6416,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6440
6416
|
this.seekingSub = null;
|
|
6441
6417
|
}
|
|
6442
6418
|
clear() {
|
|
6443
|
-
(0,
|
|
6419
|
+
(0, import_vinyl_util66.logDebug)(this, "clear");
|
|
6444
6420
|
this.cachedSegments.forEach((slot) => {
|
|
6445
6421
|
slot.data.onStatusChange = null;
|
|
6446
6422
|
slot.data.clear();
|
|
@@ -6456,7 +6432,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6456
6432
|
this.dispatch("fetchedRangesChange", {});
|
|
6457
6433
|
}
|
|
6458
6434
|
reset() {
|
|
6459
|
-
(0,
|
|
6435
|
+
(0, import_vinyl_util66.logDebug)(this, "reset");
|
|
6460
6436
|
this.cachedSegments.forEach((slot) => this.resetSlot(slot));
|
|
6461
6437
|
this._error = null;
|
|
6462
6438
|
this.pollPrefetch();
|
|
@@ -6467,12 +6443,12 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6467
6443
|
*/
|
|
6468
6444
|
resetSlot(slot) {
|
|
6469
6445
|
if (slot.data.status === "erred" /* ERRED */) {
|
|
6470
|
-
(0,
|
|
6446
|
+
(0, import_vinyl_util66.logDebug)(this, "resetting failed segment at time:", slot.startTime);
|
|
6471
6447
|
this.ended = false;
|
|
6472
6448
|
slot.data.clear();
|
|
6473
6449
|
}
|
|
6474
6450
|
if (slot.initData.status === "erred" /* ERRED */) {
|
|
6475
|
-
(0,
|
|
6451
|
+
(0, import_vinyl_util66.logDebug)(this, "resetting failed init segment");
|
|
6476
6452
|
this.ended = false;
|
|
6477
6453
|
slot.initData.clear();
|
|
6478
6454
|
}
|
|
@@ -6481,7 +6457,7 @@ var SegmentControllerImpl = class extends import_vinyl_util70.EventHostImpl {
|
|
|
6481
6457
|
return this.disposer.disposed;
|
|
6482
6458
|
}
|
|
6483
6459
|
dispose() {
|
|
6484
|
-
(0,
|
|
6460
|
+
(0, import_vinyl_util66.logDebug)(this, "disposing");
|
|
6485
6461
|
super.dispose();
|
|
6486
6462
|
this.disposer.dispose();
|
|
6487
6463
|
this.deactivate();
|
|
@@ -6498,7 +6474,6 @@ var ALL_STREAMING_EVENTS = [
|
|
|
6498
6474
|
"bufferingQualityChange",
|
|
6499
6475
|
"playbackQualityChange",
|
|
6500
6476
|
"bufferingEnded",
|
|
6501
|
-
"hasDataChange",
|
|
6502
6477
|
"error",
|
|
6503
6478
|
"reset",
|
|
6504
6479
|
"qualitiesChange",
|
|
@@ -6509,7 +6484,7 @@ var ALL_STREAMING_EVENTS = [
|
|
|
6509
6484
|
];
|
|
6510
6485
|
|
|
6511
6486
|
// src/text/discoverDashTextTracks.ts
|
|
6512
|
-
var
|
|
6487
|
+
var import_vinyl_util67 = require("@amazon/vinyl-util");
|
|
6513
6488
|
function discoverDashTextTracks(manifest, baseUrl) {
|
|
6514
6489
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
6515
6490
|
const out = [];
|
|
@@ -6563,17 +6538,17 @@ function isSidecarTextMime(mimeType) {
|
|
|
6563
6538
|
}
|
|
6564
6539
|
function chainBase(parent, bases) {
|
|
6565
6540
|
if (!bases || bases.length === 0) return parent;
|
|
6566
|
-
return (0,
|
|
6541
|
+
return (0, import_vinyl_util67.resolveUrl)(bases[0]._content, parent);
|
|
6567
6542
|
}
|
|
6568
6543
|
function pickRepresentationUri(base, id) {
|
|
6569
6544
|
if (base.endsWith("/")) {
|
|
6570
|
-
return (0,
|
|
6545
|
+
return (0, import_vinyl_util67.resolveUrl)(`${id}.vtt`, base);
|
|
6571
6546
|
}
|
|
6572
6547
|
return base;
|
|
6573
6548
|
}
|
|
6574
6549
|
|
|
6575
6550
|
// src/text/discoverHlsTextTracks.ts
|
|
6576
|
-
var
|
|
6551
|
+
var import_vinyl_util68 = require("@amazon/vinyl-util");
|
|
6577
6552
|
function discoverHlsTextTracks(mainPlaylist, baseUrl) {
|
|
6578
6553
|
var _a, _b;
|
|
6579
6554
|
const out = [];
|
|
@@ -6582,7 +6557,7 @@ function discoverHlsTextTracks(mainPlaylist, baseUrl) {
|
|
|
6582
6557
|
for (const rendition of mainPlaylist.alternativeRenditions) {
|
|
6583
6558
|
if (rendition.type !== "SUBTITLES") continue;
|
|
6584
6559
|
if (!rendition.uri) continue;
|
|
6585
|
-
const resolved = (0,
|
|
6560
|
+
const resolved = (0, import_vinyl_util68.resolveUrl)(rendition.uri, baseUrl);
|
|
6586
6561
|
out.push(__spreadValues({
|
|
6587
6562
|
id: `hls-text-${index++}-${rendition.groupId}-${rendition.name}`,
|
|
6588
6563
|
kind: "subtitles",
|
|
@@ -6793,23 +6768,23 @@ function createMediaTextTrackProvider(deps) {
|
|
|
6793
6768
|
}
|
|
6794
6769
|
|
|
6795
6770
|
// src/text/parseWebVtt.ts
|
|
6796
|
-
var
|
|
6771
|
+
var import_vinyl_util69 = require("@amazon/vinyl-util");
|
|
6797
6772
|
var WEBVTT_HEADER = "WEBVTT";
|
|
6798
6773
|
var TIMESTAMP_RE = /^(?:(\d+):)?([0-5]\d):([0-5]\d)\.(\d{3})/;
|
|
6799
6774
|
function parseWebVtt(input) {
|
|
6800
6775
|
if (typeof input !== "string") {
|
|
6801
|
-
throw new
|
|
6776
|
+
throw new import_vinyl_util69.ValidationError(
|
|
6802
6777
|
"WebVTT input must be a string",
|
|
6803
|
-
|
|
6778
|
+
import_vinyl_util69.ErrorOrigin.MEDIA
|
|
6804
6779
|
);
|
|
6805
6780
|
}
|
|
6806
6781
|
let text = input;
|
|
6807
6782
|
if (text.charCodeAt(0) === 65279) text = text.slice(1);
|
|
6808
6783
|
const lines = text.split(/\r\n|\r|\n/);
|
|
6809
6784
|
if (lines.length === 0 || !isWebVttHeader(lines[0])) {
|
|
6810
|
-
throw new
|
|
6785
|
+
throw new import_vinyl_util69.ValidationError(
|
|
6811
6786
|
"WebVTT must begin with a WEBVTT header",
|
|
6812
|
-
|
|
6787
|
+
import_vinyl_util69.ErrorOrigin.MEDIA
|
|
6813
6788
|
);
|
|
6814
6789
|
}
|
|
6815
6790
|
const cues = [];
|
|
@@ -6999,10 +6974,10 @@ function scoreTextTrack(track, prefs) {
|
|
|
6999
6974
|
}
|
|
7000
6975
|
|
|
7001
6976
|
// src/text/SidecarTextTrackController.ts
|
|
7002
|
-
var
|
|
6977
|
+
var import_vinyl_util71 = require("@amazon/vinyl-util");
|
|
7003
6978
|
|
|
7004
6979
|
// src/text/SidecarTextTrackLoader.ts
|
|
7005
|
-
var
|
|
6980
|
+
var import_vinyl_util70 = require("@amazon/vinyl-util");
|
|
7006
6981
|
var import_vinyl_hls_parser2 = require("@amazon/vinyl-hls-parser");
|
|
7007
6982
|
var DEFAULT_TEXT_LOOK_AHEAD = 10;
|
|
7008
6983
|
var DEFAULT_TEXT_LOOK_BEHIND = 2;
|
|
@@ -7026,9 +7001,9 @@ async function loadWebVttCues(uri, options) {
|
|
|
7026
7001
|
lookBehind
|
|
7027
7002
|
});
|
|
7028
7003
|
}
|
|
7029
|
-
const response = await (0,
|
|
7004
|
+
const response = await (0, import_vinyl_util70.requestWithRetry)(uri, init, { abort });
|
|
7030
7005
|
const contentType2 = ((_c = response.headers.get("content-type")) != null ? _c : "").toLowerCase();
|
|
7031
|
-
const body = await response
|
|
7006
|
+
const body = await (0, import_vinyl_util70.readResponseBody)(response, "text");
|
|
7032
7007
|
if (contentType2.includes("mpegurl") || body.startsWith("#EXTM3U")) {
|
|
7033
7008
|
return streamMediaPlaylistText({
|
|
7034
7009
|
text: body,
|
|
@@ -7052,10 +7027,10 @@ function looksLikeMediaPlaylist(uri) {
|
|
|
7052
7027
|
return path.toLowerCase().endsWith(".m3u8");
|
|
7053
7028
|
}
|
|
7054
7029
|
async function streamMediaPlaylist(ctx) {
|
|
7055
|
-
const response = await (0,
|
|
7030
|
+
const response = await (0, import_vinyl_util70.requestWithRetry)(ctx.uri, ctx.init, {
|
|
7056
7031
|
abort: ctx.abort
|
|
7057
7032
|
});
|
|
7058
|
-
const text = await response
|
|
7033
|
+
const text = await (0, import_vinyl_util70.readResponseBody)(response, "text");
|
|
7059
7034
|
return streamMediaPlaylistText(__spreadProps(__spreadValues({}, ctx), {
|
|
7060
7035
|
text,
|
|
7061
7036
|
baseUrl: response.url || ctx.uri
|
|
@@ -7075,16 +7050,16 @@ async function streamMediaPlaylistText(ctx) {
|
|
|
7075
7050
|
while (pending.size > 0 && !((_a = ctx.abort) == null ? void 0 : _a.aborted())) {
|
|
7076
7051
|
const idx = pickInWindow(pending, ranges, ctx);
|
|
7077
7052
|
if (idx < 0) {
|
|
7078
|
-
await (0,
|
|
7053
|
+
await (0, import_vinyl_util70.sleep)(IDLE_POLL_SECONDS, ctx.abort).catch(() => {
|
|
7079
7054
|
});
|
|
7080
7055
|
continue;
|
|
7081
7056
|
}
|
|
7082
7057
|
pending.delete(idx);
|
|
7083
|
-
const segUri = (0,
|
|
7084
|
-
const res = await (0,
|
|
7058
|
+
const segUri = (0, import_vinyl_util70.resolveUrl)(segments[idx].uri, ctx.baseUrl);
|
|
7059
|
+
const res = await (0, import_vinyl_util70.requestWithRetry)(segUri, ctx.init, {
|
|
7085
7060
|
abort: ctx.abort
|
|
7086
7061
|
});
|
|
7087
|
-
const body = await res
|
|
7062
|
+
const body = await (0, import_vinyl_util70.readResponseBody)(res, "text");
|
|
7088
7063
|
const doc = parseWebVtt(body);
|
|
7089
7064
|
if (doc.cues.length > 0) ctx.onCues(doc.cues);
|
|
7090
7065
|
if (ctx.onStyles && doc.styles.length > 0) ctx.onStyles(doc.styles);
|
|
@@ -7158,7 +7133,7 @@ function resolveSelectedTrack(tracks, options) {
|
|
|
7158
7133
|
pool = pool.filter((t) => t.forced === forced);
|
|
7159
7134
|
return pickPreferredTextTrack(pool, selection.language);
|
|
7160
7135
|
}
|
|
7161
|
-
var SidecarTextTrackController = class extends
|
|
7136
|
+
var SidecarTextTrackController = class extends import_vinyl_util71.EventHostImpl {
|
|
7162
7137
|
constructor(deps) {
|
|
7163
7138
|
super();
|
|
7164
7139
|
__publicField(this, "deps", deps);
|
|
@@ -7170,14 +7145,14 @@ var SidecarTextTrackController = class extends import_vinyl_util75.EventHostImpl
|
|
|
7170
7145
|
// The DOM text track currently rendering cues, or null when hidden. Owned by
|
|
7171
7146
|
// the provider (never created/removed here).
|
|
7172
7147
|
__publicField(this, "_ref", null);
|
|
7173
|
-
__publicField(this, "loadAbort", /* @__PURE__ */ (0,
|
|
7174
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
7148
|
+
__publicField(this, "loadAbort", /* @__PURE__ */ (0, import_vinyl_util71.createAbortSlot)());
|
|
7149
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util71.createDisposer)());
|
|
7175
7150
|
const { add } = this.disposer;
|
|
7176
7151
|
add(deps.options.onData(() => this.refreshSelection()));
|
|
7177
7152
|
add(
|
|
7178
7153
|
deps.textTracks.onData((tracksPromise) => {
|
|
7179
7154
|
tracksPromise.then((tracks) => this.setTracks(tracks)).catch((error) => {
|
|
7180
|
-
(0,
|
|
7155
|
+
(0, import_vinyl_util71.logError)(this, "text tracks promise rejected", error);
|
|
7181
7156
|
});
|
|
7182
7157
|
})
|
|
7183
7158
|
);
|
|
@@ -7204,7 +7179,7 @@ var SidecarTextTrackController = class extends import_vinyl_util75.EventHostImpl
|
|
|
7204
7179
|
setTracks(tracks) {
|
|
7205
7180
|
if (this.disposed) return;
|
|
7206
7181
|
const previous = this._tracks;
|
|
7207
|
-
if ((0,
|
|
7182
|
+
if ((0, import_vinyl_util71.equalDeep)(previous, tracks)) return;
|
|
7208
7183
|
this._tracks = tracks;
|
|
7209
7184
|
this.dispatch("textTracksChange", { previous, current: tracks });
|
|
7210
7185
|
this.refreshSelection();
|
|
@@ -7353,13 +7328,13 @@ var ALL_TEXT_TRACK_EVENTS = [
|
|
|
7353
7328
|
];
|
|
7354
7329
|
|
|
7355
7330
|
// src/track/AutoResetController.ts
|
|
7356
|
-
var
|
|
7331
|
+
var import_vinyl_util72 = require("@amazon/vinyl-util");
|
|
7357
7332
|
var defaultResetControllerOptions = {
|
|
7358
7333
|
enabled: true,
|
|
7359
7334
|
maxRetries: 30,
|
|
7360
7335
|
retryInterval: 30
|
|
7361
7336
|
};
|
|
7362
|
-
var AutoResetControllerImpl = class extends
|
|
7337
|
+
var AutoResetControllerImpl = class extends import_vinyl_util72.EventHostImpl {
|
|
7363
7338
|
constructor(deps, options) {
|
|
7364
7339
|
super();
|
|
7365
7340
|
__publicField(this, "deps", deps);
|
|
@@ -7367,11 +7342,11 @@ var AutoResetControllerImpl = class extends import_vinyl_util76.EventHostImpl {
|
|
|
7367
7342
|
__publicField(this, "_error", null);
|
|
7368
7343
|
__publicField(this, "watchSub", null);
|
|
7369
7344
|
__publicField(this, "currentRetry", 0);
|
|
7370
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
7371
|
-
(0,
|
|
7345
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util72.createDisposer)());
|
|
7346
|
+
(0, import_vinyl_util72.logDebug)(this, "constructor");
|
|
7372
7347
|
this.options = __spreadValues(__spreadValues({}, defaultResetControllerOptions), options);
|
|
7373
7348
|
this.disposer.add(
|
|
7374
|
-
(0,
|
|
7349
|
+
(0, import_vinyl_util72.onAny)(
|
|
7375
7350
|
deps.playbackController,
|
|
7376
7351
|
["play", "pause", "seeking", "playing"],
|
|
7377
7352
|
(_event) => {
|
|
@@ -7386,7 +7361,7 @@ var AutoResetControllerImpl = class extends import_vinyl_util76.EventHostImpl {
|
|
|
7386
7361
|
}
|
|
7387
7362
|
setError(error) {
|
|
7388
7363
|
if (!this.options.enabled || this._error) return;
|
|
7389
|
-
if (error instanceof
|
|
7364
|
+
if (error instanceof import_vinyl_util72.RequestError && error.response == null) {
|
|
7390
7365
|
this._error = error;
|
|
7391
7366
|
this.setResetPending(true);
|
|
7392
7367
|
}
|
|
@@ -7397,30 +7372,30 @@ var AutoResetControllerImpl = class extends import_vinyl_util76.EventHostImpl {
|
|
|
7397
7372
|
setResetPending(value) {
|
|
7398
7373
|
var _a;
|
|
7399
7374
|
if (this.resetPending === value) {
|
|
7400
|
-
(0,
|
|
7375
|
+
(0, import_vinyl_util72.logDebug)(this, "setResetPending", value, "no-op");
|
|
7401
7376
|
return;
|
|
7402
7377
|
}
|
|
7403
|
-
(0,
|
|
7378
|
+
(0, import_vinyl_util72.logDebug)(this, "setResetPending", value);
|
|
7404
7379
|
(_a = this.watchSub) == null ? void 0 : _a.call(this);
|
|
7405
7380
|
this.watchSub = null;
|
|
7406
7381
|
if (value) {
|
|
7407
|
-
const networkState = (0,
|
|
7408
|
-
const { add, dispose: watchSub } = (0,
|
|
7382
|
+
const networkState = (0, import_vinyl_util72.getNetworkState)();
|
|
7383
|
+
const { add, dispose: watchSub } = (0, import_vinyl_util72.createDisposer)();
|
|
7409
7384
|
this.watchSub = watchSub;
|
|
7410
7385
|
add(
|
|
7411
7386
|
networkState.on("online", () => {
|
|
7412
|
-
(0,
|
|
7387
|
+
(0, import_vinyl_util72.logDebug)(this, "online, emitting reset");
|
|
7413
7388
|
this.reset();
|
|
7414
7389
|
})
|
|
7415
7390
|
);
|
|
7416
7391
|
const intervalId = setTimeout(() => {
|
|
7417
7392
|
if (this.currentRetry++ < this.options.maxRetries) {
|
|
7418
7393
|
if (networkState.onLine) {
|
|
7419
|
-
(0,
|
|
7394
|
+
(0, import_vinyl_util72.logDebug)(this, "interval, emitting reset");
|
|
7420
7395
|
this.reset();
|
|
7421
7396
|
}
|
|
7422
7397
|
} else {
|
|
7423
|
-
(0,
|
|
7398
|
+
(0, import_vinyl_util72.logDebug)(this, "max retries exhausted, pausing playback");
|
|
7424
7399
|
this.setResetPending(false);
|
|
7425
7400
|
}
|
|
7426
7401
|
}, this.options.retryInterval * 1e3);
|
|
@@ -7451,14 +7426,14 @@ var AutoResetControllerImpl = class extends import_vinyl_util76.EventHostImpl {
|
|
|
7451
7426
|
};
|
|
7452
7427
|
|
|
7453
7428
|
// src/track/createSegmentDataProvider.ts
|
|
7454
|
-
var
|
|
7429
|
+
var import_vinyl_util73 = require("@amazon/vinyl-util");
|
|
7455
7430
|
var import_vinyl_mpd_parser2 = require("@amazon/vinyl-mpd-parser");
|
|
7456
7431
|
function createSegmentDataProvider(deps, options) {
|
|
7457
7432
|
return async (abort) => {
|
|
7458
7433
|
var _a;
|
|
7459
7434
|
const init = __spreadValues({}, deps.segmentRequestInit);
|
|
7460
7435
|
if (options.mediaRange) {
|
|
7461
|
-
init.headers = __spreadProps(__spreadValues({}, (0,
|
|
7436
|
+
init.headers = __spreadProps(__spreadValues({}, (0, import_vinyl_util73.normalizeHeadersInit)(init.headers)), {
|
|
7462
7437
|
Range: `bytes=${(0, import_vinyl_mpd_parser2.stringifyByteRange)(options.mediaRange)}`
|
|
7463
7438
|
});
|
|
7464
7439
|
}
|
|
@@ -7467,18 +7442,18 @@ function createSegmentDataProvider(deps, options) {
|
|
|
7467
7442
|
init
|
|
7468
7443
|
};
|
|
7469
7444
|
deps.requestInterceptor(params);
|
|
7470
|
-
const serviceId = (_a = options.serviceId) != null ? _a : (0,
|
|
7445
|
+
const serviceId = (_a = options.serviceId) != null ? _a : (0, import_vinyl_util73.getHostname)(options.url);
|
|
7471
7446
|
const requestStart = Date.now();
|
|
7472
|
-
const response = await (0,
|
|
7447
|
+
const response = await (0, import_vinyl_util73.requestWithRetry)(params.input, params.init, {
|
|
7473
7448
|
serviceId,
|
|
7474
7449
|
abort
|
|
7475
7450
|
});
|
|
7476
7451
|
const responseEnd = Date.now();
|
|
7477
|
-
const arrayBuffer = await response
|
|
7452
|
+
const arrayBuffer = await (0, import_vinyl_util73.readResponseBody)(response, "arrayBuffer");
|
|
7478
7453
|
const contentEnd = Date.now();
|
|
7479
7454
|
let responseStart = null;
|
|
7480
7455
|
if ("getEntriesByName" in performance) {
|
|
7481
|
-
const lastRequest = (0,
|
|
7456
|
+
const lastRequest = (0, import_vinyl_util73.last)(
|
|
7482
7457
|
performance.getEntriesByName(params.input)
|
|
7483
7458
|
);
|
|
7484
7459
|
if (lastRequest) {
|
|
@@ -7487,8 +7462,8 @@ function createSegmentDataProvider(deps, options) {
|
|
|
7487
7462
|
}
|
|
7488
7463
|
}
|
|
7489
7464
|
}
|
|
7490
|
-
if (options.reportDownlinkMetrics) {
|
|
7491
|
-
|
|
7465
|
+
if (options.reportDownlinkMetrics && !(abort == null ? void 0 : abort.aborted())) {
|
|
7466
|
+
import_vinyl_util73.networkMetricsController.value.addDownlinkTransferEntry({
|
|
7492
7467
|
bytes: arrayBuffer.byteLength,
|
|
7493
7468
|
serviceId,
|
|
7494
7469
|
requestStart,
|
|
@@ -7502,7 +7477,7 @@ function createSegmentDataProvider(deps, options) {
|
|
|
7502
7477
|
}
|
|
7503
7478
|
|
|
7504
7479
|
// src/track/TrackFactory.ts
|
|
7505
|
-
var
|
|
7480
|
+
var import_vinyl_util74 = require("@amazon/vinyl-util");
|
|
7506
7481
|
var import_vinyl_validation13 = require("@amazon/vinyl-validation");
|
|
7507
7482
|
var trackConfigOptionsValidator = /* @__PURE__ */ (0, import_vinyl_validation13.object)({
|
|
7508
7483
|
extra: /* @__PURE__ */ (0, import_vinyl_validation13.any)().optional(),
|
|
@@ -7517,10 +7492,10 @@ var trackLoadOptionsValidator = /* @__PURE__ */ (0, import_vinyl_validation13.ob
|
|
|
7517
7492
|
}
|
|
7518
7493
|
);
|
|
7519
7494
|
function createTrackFactory(factories) {
|
|
7520
|
-
const typeValidator = (0, import_vinyl_validation13.isOneOf)(...(0,
|
|
7495
|
+
const typeValidator = (0, import_vinyl_validation13.isOneOf)(...(0, import_vinyl_util74.ownKeys)(factories));
|
|
7521
7496
|
return {
|
|
7522
7497
|
validate(options) {
|
|
7523
|
-
typeValidator.assert(options.type,
|
|
7498
|
+
typeValidator.assert(options.type, import_vinyl_util74.ErrorOrigin.API);
|
|
7524
7499
|
factories[options.type].validate(options);
|
|
7525
7500
|
},
|
|
7526
7501
|
createTrack(options) {
|
|
@@ -7530,12 +7505,12 @@ function createTrackFactory(factories) {
|
|
|
7530
7505
|
}
|
|
7531
7506
|
|
|
7532
7507
|
// src/track/source/SourceObjectTrack.ts
|
|
7533
|
-
var
|
|
7508
|
+
var import_vinyl_util78 = require("@amazon/vinyl-util");
|
|
7534
7509
|
var import_vinyl_validation14 = require("@amazon/vinyl-validation");
|
|
7535
7510
|
|
|
7536
7511
|
// src/track/TrackBase.ts
|
|
7537
|
-
var
|
|
7538
|
-
var TrackBase = class extends
|
|
7512
|
+
var import_vinyl_util75 = require("@amazon/vinyl-util");
|
|
7513
|
+
var TrackBase = class extends import_vinyl_util75.EventHostImpl {
|
|
7539
7514
|
constructor(uri, type, deps) {
|
|
7540
7515
|
super();
|
|
7541
7516
|
__publicField(this, "uri", uri);
|
|
@@ -7547,7 +7522,7 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7547
7522
|
__publicField(this, "loadOptions", null);
|
|
7548
7523
|
__publicField(this, "errorHandler", (error) => {
|
|
7549
7524
|
if (this._error) return;
|
|
7550
|
-
if (!(0,
|
|
7525
|
+
if (!(0, import_vinyl_util75.isSilentError)(error)) {
|
|
7551
7526
|
this._error = error;
|
|
7552
7527
|
this.dispatch("error", {
|
|
7553
7528
|
target: this,
|
|
@@ -7555,8 +7530,8 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7555
7530
|
});
|
|
7556
7531
|
}
|
|
7557
7532
|
});
|
|
7558
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
7559
|
-
__publicField(this, "drmSessionAbort", /* @__PURE__ */ (0,
|
|
7533
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util75.createDisposer)());
|
|
7534
|
+
__publicField(this, "drmSessionAbort", /* @__PURE__ */ (0, import_vinyl_util75.createAbortSlot)());
|
|
7560
7535
|
/**
|
|
7561
7536
|
* Sets on handleError, cleared on 'reset'.
|
|
7562
7537
|
*/
|
|
@@ -7568,7 +7543,7 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7568
7543
|
return "TrackBase";
|
|
7569
7544
|
}
|
|
7570
7545
|
get fetchedRanges() {
|
|
7571
|
-
return
|
|
7546
|
+
return import_vinyl_util75.emptyRanges;
|
|
7572
7547
|
}
|
|
7573
7548
|
/**
|
|
7574
7549
|
* Default text track controller is null. Tracks that surface text tracks
|
|
@@ -7609,8 +7584,8 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7609
7584
|
this.loadOptions = loadOptions;
|
|
7610
7585
|
this.reset();
|
|
7611
7586
|
this._active = true;
|
|
7612
|
-
(0,
|
|
7613
|
-
this.deps.playbackController.seekTo((_a = loadOptions == null ? void 0 : loadOptions.startTime) != null ? _a : 0).catch(
|
|
7587
|
+
(0, import_vinyl_util75.logDebug)(this, "activate", this.uri);
|
|
7588
|
+
this.deps.playbackController.seekTo((_a = loadOptions == null ? void 0 : loadOptions.startTime) != null ? _a : 0).catch(import_vinyl_util75.noop);
|
|
7614
7589
|
this.deps.drmController.configure(loadOptions == null ? void 0 : loadOptions.drm);
|
|
7615
7590
|
this.onActivated(loadOptions);
|
|
7616
7591
|
}
|
|
@@ -7618,7 +7593,7 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7618
7593
|
if (!this._active) return;
|
|
7619
7594
|
this._active = false;
|
|
7620
7595
|
this.loadOptions = null;
|
|
7621
|
-
(0,
|
|
7596
|
+
(0, import_vinyl_util75.logDebug)(this, "deactivate", this.uri);
|
|
7622
7597
|
this.deps.playbackController.pause();
|
|
7623
7598
|
this.onDeactivated();
|
|
7624
7599
|
this.closeDrmSessions();
|
|
@@ -7638,10 +7613,10 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7638
7613
|
}
|
|
7639
7614
|
setSeekRange(value) {
|
|
7640
7615
|
const prev = this._seekRange;
|
|
7641
|
-
if ((0,
|
|
7616
|
+
if ((0, import_vinyl_util75.equalDeep)(prev, value)) return;
|
|
7642
7617
|
const previous = this._seekRange;
|
|
7643
7618
|
this._seekRange = value;
|
|
7644
|
-
(0,
|
|
7619
|
+
(0, import_vinyl_util75.logDebug)(this, `seekRangeChange start=${value.start}, end=${value.end}`);
|
|
7645
7620
|
this.dispatch("seekRangeChange", {
|
|
7646
7621
|
previous,
|
|
7647
7622
|
current: value
|
|
@@ -7655,7 +7630,7 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7655
7630
|
*/
|
|
7656
7631
|
reset(hard = false) {
|
|
7657
7632
|
if (!hard && !this._error) {
|
|
7658
|
-
(0,
|
|
7633
|
+
(0, import_vinyl_util75.logDebug)(this, "reset no-op");
|
|
7659
7634
|
return;
|
|
7660
7635
|
}
|
|
7661
7636
|
if (hard) {
|
|
@@ -7667,13 +7642,13 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7667
7642
|
this.onDeactivated();
|
|
7668
7643
|
this.clearPrefetch();
|
|
7669
7644
|
this.onActivated(loadOptions);
|
|
7670
|
-
playbackController.seekTo(time).catch(
|
|
7671
|
-
if (!wasPaused) playbackController.play().catch(
|
|
7645
|
+
playbackController.seekTo(time).catch(import_vinyl_util75.noop);
|
|
7646
|
+
if (!wasPaused) playbackController.play().catch(import_vinyl_util75.noop);
|
|
7672
7647
|
} else {
|
|
7673
7648
|
this.clearPrefetch();
|
|
7674
7649
|
}
|
|
7675
7650
|
}
|
|
7676
|
-
(0,
|
|
7651
|
+
(0, import_vinyl_util75.logDebug)(this, "reset, hard:", hard);
|
|
7677
7652
|
this._error = null;
|
|
7678
7653
|
this.dispatch("reset", {});
|
|
7679
7654
|
}
|
|
@@ -7686,8 +7661,8 @@ var TrackBase = class extends import_vinyl_util79.EventHostImpl {
|
|
|
7686
7661
|
};
|
|
7687
7662
|
|
|
7688
7663
|
// src/track/source/FixedPlaybackQuality.ts
|
|
7689
|
-
var
|
|
7690
|
-
var FixedPlaybackQuality = class extends
|
|
7664
|
+
var import_vinyl_util76 = require("@amazon/vinyl-util");
|
|
7665
|
+
var FixedPlaybackQuality = class extends import_vinyl_util76.EventHostImpl {
|
|
7691
7666
|
constructor(fixedQuality, deps) {
|
|
7692
7667
|
super();
|
|
7693
7668
|
__publicField(this, "deps", deps);
|
|
@@ -7784,7 +7759,7 @@ var FixedPlaybackQuality = class extends import_vinyl_util80.EventHostImpl {
|
|
|
7784
7759
|
};
|
|
7785
7760
|
|
|
7786
7761
|
// src/track/source/SourceTrackBase.ts
|
|
7787
|
-
var
|
|
7762
|
+
var import_vinyl_util77 = require("@amazon/vinyl-util");
|
|
7788
7763
|
var sourceTrackBaseOptionsValidator = /* @__PURE__ */ trackConfigOptionsValidator.extend({
|
|
7789
7764
|
qualityMetadata: /* @__PURE__ */ mediaQualityMetadataValidator.partial().maybe().optional()
|
|
7790
7765
|
});
|
|
@@ -7811,7 +7786,7 @@ var SourceTrackBase = class extends TrackBase {
|
|
|
7811
7786
|
abort: this.drmSessionAbort.value
|
|
7812
7787
|
});
|
|
7813
7788
|
});
|
|
7814
|
-
(0,
|
|
7789
|
+
(0, import_vinyl_util77.redispatchEvents)(this, this.fixedPlaybackQuality, [
|
|
7815
7790
|
"streamingQualityChange",
|
|
7816
7791
|
"bufferingQualityChange",
|
|
7817
7792
|
"playbackQualityChange"
|
|
@@ -7840,7 +7815,7 @@ var SourceTrackBase = class extends TrackBase {
|
|
|
7840
7815
|
return this.fixedPlaybackQuality.getPlaybackQuality(contentType2);
|
|
7841
7816
|
}
|
|
7842
7817
|
onActivated() {
|
|
7843
|
-
const { add, dispose } = (0,
|
|
7818
|
+
const { add, dispose } = (0, import_vinyl_util77.createDisposer)();
|
|
7844
7819
|
this.activeSub = dispose;
|
|
7845
7820
|
add(
|
|
7846
7821
|
this.deps.playbackController.on("durationChange", (event) => {
|
|
@@ -7867,7 +7842,7 @@ var SourceTrackBase = class extends TrackBase {
|
|
|
7867
7842
|
this.activeSub = null;
|
|
7868
7843
|
}
|
|
7869
7844
|
clearPrefetch() {
|
|
7870
|
-
(0,
|
|
7845
|
+
(0, import_vinyl_util77.logDebug)(this, "clearPrefetch no-op");
|
|
7871
7846
|
}
|
|
7872
7847
|
};
|
|
7873
7848
|
|
|
@@ -7880,7 +7855,7 @@ var loadOptionsValidator = /* @__PURE__ */ trackLoadOptionsValidator.extend({
|
|
|
7880
7855
|
function createSourceObjectTrackFactory(deps) {
|
|
7881
7856
|
return {
|
|
7882
7857
|
validate(options) {
|
|
7883
|
-
loadOptionsValidator.assert(options,
|
|
7858
|
+
loadOptionsValidator.assert(options, import_vinyl_util78.ErrorOrigin.API);
|
|
7884
7859
|
},
|
|
7885
7860
|
createTrack(options) {
|
|
7886
7861
|
return new SourceObjectTrack(
|
|
@@ -7910,7 +7885,7 @@ var SourceObjectTrack = class extends SourceTrackBase {
|
|
|
7910
7885
|
};
|
|
7911
7886
|
|
|
7912
7887
|
// src/track/source/SourceTrack.ts
|
|
7913
|
-
var
|
|
7888
|
+
var import_vinyl_util79 = require("@amazon/vinyl-util");
|
|
7914
7889
|
var import_vinyl_validation15 = require("@amazon/vinyl-validation");
|
|
7915
7890
|
var loadOptionsValidator2 = /* @__PURE__ */ trackLoadOptionsValidator.extend({
|
|
7916
7891
|
config: /* @__PURE__ */ sourceTrackBaseOptionsValidator.maybe().optional(),
|
|
@@ -7920,7 +7895,7 @@ var loadOptionsValidator2 = /* @__PURE__ */ trackLoadOptionsValidator.extend({
|
|
|
7920
7895
|
function createSourceTrackFactory(deps) {
|
|
7921
7896
|
return {
|
|
7922
7897
|
validate(options) {
|
|
7923
|
-
loadOptionsValidator2.assert(options,
|
|
7898
|
+
loadOptionsValidator2.assert(options, import_vinyl_util79.ErrorOrigin.API);
|
|
7924
7899
|
},
|
|
7925
7900
|
createTrack(options) {
|
|
7926
7901
|
return new SourceTrack(
|
|
@@ -7950,25 +7925,22 @@ var SourceTrack = class extends SourceTrackBase {
|
|
|
7950
7925
|
};
|
|
7951
7926
|
|
|
7952
7927
|
// src/track/dash/DashTrack.ts
|
|
7953
|
-
var
|
|
7928
|
+
var import_vinyl_util81 = require("@amazon/vinyl-util");
|
|
7954
7929
|
var import_vinyl_validation16 = require("@amazon/vinyl-validation");
|
|
7955
7930
|
|
|
7956
7931
|
// src/track/mse/MseTrack.ts
|
|
7957
|
-
var
|
|
7932
|
+
var import_vinyl_util80 = require("@amazon/vinyl-util");
|
|
7958
7933
|
var import_vinyl_di2 = require("@amazon/vinyl-di");
|
|
7959
|
-
var SEEKING_STALL_TIME_CHECK = 0.1;
|
|
7960
|
-
var PLAYHEAD_NUDGE = 0.05;
|
|
7961
7934
|
var MseTrack = class extends TrackBase {
|
|
7962
7935
|
constructor(uri, type, dependencyFactories) {
|
|
7963
7936
|
const depsContainer = (0, import_vinyl_di2.createContainer)(dependencyFactories);
|
|
7964
7937
|
const deps = depsContainer.dependencies;
|
|
7965
7938
|
super(uri, type, deps);
|
|
7966
7939
|
__publicField(this, "streams", []);
|
|
7967
|
-
__publicField(this, "
|
|
7968
|
-
__publicField(this, "disposeAbort", /* @__PURE__ */ new import_vinyl_util84.Abort());
|
|
7940
|
+
__publicField(this, "disposeAbort", /* @__PURE__ */ new import_vinyl_util80.Abort());
|
|
7969
7941
|
__publicField(this, "lastPreloadOptions", null);
|
|
7970
7942
|
__publicField(this, "allFetchedRanges", []);
|
|
7971
|
-
__publicField(this, "_fetchedRanges", /* @__PURE__ */ new
|
|
7943
|
+
__publicField(this, "_fetchedRanges", /* @__PURE__ */ new import_vinyl_util80.IntersectionRanges(
|
|
7972
7944
|
this.allFetchedRanges,
|
|
7973
7945
|
{ useCache: true }
|
|
7974
7946
|
));
|
|
@@ -7977,13 +7949,16 @@ var MseTrack = class extends TrackBase {
|
|
|
7977
7949
|
__publicField(this, "_qualitiesUnfiltered", null);
|
|
7978
7950
|
__publicField(this, "timeUpdateSub", null);
|
|
7979
7951
|
__publicField(this, "_cachedPeriod", null);
|
|
7980
|
-
(0,
|
|
7952
|
+
(0, import_vinyl_util80.logDebug)(this, "constructed");
|
|
7981
7953
|
const { add } = this.disposer;
|
|
7982
7954
|
add(depsContainer);
|
|
7983
7955
|
this.deps = deps;
|
|
7984
7956
|
add(
|
|
7985
7957
|
deps.contentTypesValue.onData((contentTypesPromise) => {
|
|
7986
|
-
contentTypesPromise.then((value) =>
|
|
7958
|
+
contentTypesPromise.then((value) => {
|
|
7959
|
+
this.setContentTypes(value);
|
|
7960
|
+
this.validateRequiredContentTypesPlayable();
|
|
7961
|
+
}).catch(this.errorHandler);
|
|
7987
7962
|
})
|
|
7988
7963
|
);
|
|
7989
7964
|
this.on("streamingQualityChange", (event) => {
|
|
@@ -8026,11 +8001,6 @@ var MseTrack = class extends TrackBase {
|
|
|
8026
8001
|
if (previous !== void 0) this.reloadStreams();
|
|
8027
8002
|
})
|
|
8028
8003
|
);
|
|
8029
|
-
add(
|
|
8030
|
-
deps.allowedContentTypes.onData((_value, previous) => {
|
|
8031
|
-
if (previous !== void 0) this.reloadStreams();
|
|
8032
|
-
})
|
|
8033
|
-
);
|
|
8034
8004
|
add(
|
|
8035
8005
|
deps.abr.onData((value, previous) => {
|
|
8036
8006
|
if (previous === void 0) return;
|
|
@@ -8079,7 +8049,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8079
8049
|
const period = getMediaPeriodAtTime(timeline, time);
|
|
8080
8050
|
this._cachedPeriod = period;
|
|
8081
8051
|
const newQualities = period ? period.qualities.map((q) => q.metadata) : null;
|
|
8082
|
-
if (!(0,
|
|
8052
|
+
if (!(0, import_vinyl_util80.equalDeep)(newQualities, this._qualities)) {
|
|
8083
8053
|
const previous = this._qualities;
|
|
8084
8054
|
this._qualities = newQualities;
|
|
8085
8055
|
if (newQualities) {
|
|
@@ -8089,8 +8059,33 @@ var MseTrack = class extends TrackBase {
|
|
|
8089
8059
|
});
|
|
8090
8060
|
}
|
|
8091
8061
|
}
|
|
8062
|
+
this.validateRequiredContentTypesPlayable();
|
|
8092
8063
|
});
|
|
8093
8064
|
}
|
|
8065
|
+
/**
|
|
8066
|
+
* Fails fast when a media content type the manifest declared (audio/video)
|
|
8067
|
+
* has no playable qualities left after timeline filtering. Its stream can
|
|
8068
|
+
* never create a source buffer, so without this the track waits forever for
|
|
8069
|
+
* a source buffer that never arrives, surfacing only as an opaque
|
|
8070
|
+
* `readyToAppend` timeout. Runs once both the required content types and the
|
|
8071
|
+
* filtered timeline qualities are known (either order).
|
|
8072
|
+
*/
|
|
8073
|
+
validateRequiredContentTypesPlayable() {
|
|
8074
|
+
const qualities = this._qualities;
|
|
8075
|
+
if (!qualities) return;
|
|
8076
|
+
const present = new Set(qualities.map((q) => q.contentType));
|
|
8077
|
+
for (const contentType2 of this._contentTypes) {
|
|
8078
|
+
if (!present.has(contentType2)) {
|
|
8079
|
+
this.errorHandler(
|
|
8080
|
+
new import_vinyl_util80.MediaUnsupportedError(
|
|
8081
|
+
`No playable ${contentType2} rendition`,
|
|
8082
|
+
`no-playable-${contentType2}`
|
|
8083
|
+
)
|
|
8084
|
+
);
|
|
8085
|
+
return;
|
|
8086
|
+
}
|
|
8087
|
+
}
|
|
8088
|
+
}
|
|
8094
8089
|
async getAds() {
|
|
8095
8090
|
const timeline = await this.deps.mediaTimeline.value;
|
|
8096
8091
|
return {
|
|
@@ -8106,7 +8101,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8106
8101
|
const time = this.deps.playbackController.currentTime;
|
|
8107
8102
|
const period = getMediaPeriodAtTime(timeline, time);
|
|
8108
8103
|
const newQualities = period ? period.qualities.map((q) => q.metadata) : null;
|
|
8109
|
-
if (!(0,
|
|
8104
|
+
if (!(0, import_vinyl_util80.equalDeep)(newQualities, this._qualitiesUnfiltered)) {
|
|
8110
8105
|
const previous = this._qualitiesUnfiltered;
|
|
8111
8106
|
this._qualitiesUnfiltered = newQualities;
|
|
8112
8107
|
if (newQualities) {
|
|
@@ -8125,7 +8120,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8125
8120
|
timeline.getDuration().then((duration) => {
|
|
8126
8121
|
var _a, _b;
|
|
8127
8122
|
if (interrupted()) return;
|
|
8128
|
-
const start = (_b = (_a = (0,
|
|
8123
|
+
const start = (_b = (_a = (0, import_vinyl_util80.first)(timeline.periods)) == null ? void 0 : _a.startTime) != null ? _b : 0;
|
|
8129
8124
|
this.setSeekRange({
|
|
8130
8125
|
start,
|
|
8131
8126
|
end: start + duration
|
|
@@ -8155,7 +8150,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8155
8150
|
*/
|
|
8156
8151
|
createStream(contentType2) {
|
|
8157
8152
|
const stream = this.deps.contentStreamFactory(contentType2);
|
|
8158
|
-
(0,
|
|
8153
|
+
(0, import_vinyl_util80.redispatchEvents)(this, stream, [
|
|
8159
8154
|
"fetchedRangesChange",
|
|
8160
8155
|
"streamingQualityChange",
|
|
8161
8156
|
"bufferingQualityChange",
|
|
@@ -8172,7 +8167,6 @@ var MseTrack = class extends TrackBase {
|
|
|
8172
8167
|
this.dispatch("bufferingEnded", {});
|
|
8173
8168
|
}
|
|
8174
8169
|
});
|
|
8175
|
-
stream.on("hasDataChange", () => this.checkStalledSeek());
|
|
8176
8170
|
stream.on("fetchedRangesChange", () => {
|
|
8177
8171
|
this._fetchedRanges.invalidate();
|
|
8178
8172
|
});
|
|
@@ -8218,7 +8212,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8218
8212
|
* for example, changing streaming quality from SD to HD.
|
|
8219
8213
|
*/
|
|
8220
8214
|
clearPrefetch() {
|
|
8221
|
-
(0,
|
|
8215
|
+
(0, import_vinyl_util80.logDebug)(this, "clearPrefetch");
|
|
8222
8216
|
this.callOnStreams("clearPrefetch");
|
|
8223
8217
|
}
|
|
8224
8218
|
/**
|
|
@@ -8227,7 +8221,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8227
8221
|
*/
|
|
8228
8222
|
reset(hard = false) {
|
|
8229
8223
|
if (!hard && !this.error) {
|
|
8230
|
-
(0,
|
|
8224
|
+
(0, import_vinyl_util80.logDebug)(this, "reset no-op");
|
|
8231
8225
|
return;
|
|
8232
8226
|
}
|
|
8233
8227
|
super.reset(hard);
|
|
@@ -8308,39 +8302,11 @@ var MseTrack = class extends TrackBase {
|
|
|
8308
8302
|
get bufferingEnded() {
|
|
8309
8303
|
return this.streams.every((stream) => stream.bufferingEnded);
|
|
8310
8304
|
}
|
|
8311
|
-
/**
|
|
8312
|
-
* A seek only completes once every stream has data at the target, but on
|
|
8313
|
-
* some platforms the element can stay stuck `seeking` even after that. Once
|
|
8314
|
-
* all streams hold data, if we're still seeking a moment later, nudge the
|
|
8315
|
-
* playhead to prod the element into completing the seek.
|
|
8316
|
-
*/
|
|
8317
|
-
checkStalledSeek() {
|
|
8318
|
-
const { playbackController } = this.deps;
|
|
8319
|
-
if (this.stallNudgeTimer !== null || !playbackController.seeking) return;
|
|
8320
|
-
if (!this.streams.length || !this.streams.every((s) => s.hasData)) {
|
|
8321
|
-
return;
|
|
8322
|
-
}
|
|
8323
|
-
this.stallNudgeTimer = setTimeout(() => {
|
|
8324
|
-
this.stallNudgeTimer = null;
|
|
8325
|
-
if (this.disposed || !playbackController.seeking) return;
|
|
8326
|
-
if (!this.streams.every((s) => s.hasData)) return;
|
|
8327
|
-
const from = playbackController.currentTime;
|
|
8328
|
-
const to = from + PLAYHEAD_NUDGE;
|
|
8329
|
-
(0, import_vinyl_util84.logDebug)(
|
|
8330
|
-
this,
|
|
8331
|
-
"nudging playhead to recover a stalled seek",
|
|
8332
|
-
from,
|
|
8333
|
-
"->",
|
|
8334
|
-
to
|
|
8335
|
-
);
|
|
8336
|
-
playbackController.seekTo(to, 0).catch(import_vinyl_util84.noop);
|
|
8337
|
-
}, SEEKING_STALL_TIME_CHECK * 1e3);
|
|
8338
|
-
}
|
|
8339
8305
|
setContentTypes(contentTypes) {
|
|
8340
8306
|
if (this.disposed) return;
|
|
8341
8307
|
const previous = this.contentTypes;
|
|
8342
|
-
if ((0,
|
|
8343
|
-
(0,
|
|
8308
|
+
if ((0, import_vinyl_util80.equalDeep)(previous, contentTypes)) return;
|
|
8309
|
+
(0, import_vinyl_util80.logDebug)(this, "content types:", contentTypes);
|
|
8344
8310
|
if (previous.size) {
|
|
8345
8311
|
this.reset(
|
|
8346
8312
|
/* hard */
|
|
@@ -8358,8 +8324,7 @@ var MseTrack = class extends TrackBase {
|
|
|
8358
8324
|
});
|
|
8359
8325
|
}
|
|
8360
8326
|
dispose() {
|
|
8361
|
-
(0,
|
|
8362
|
-
if (this.stallNudgeTimer !== null) clearTimeout(this.stallNudgeTimer);
|
|
8327
|
+
(0, import_vinyl_util80.logDebug)(this, "dispose");
|
|
8363
8328
|
this.clearStreams();
|
|
8364
8329
|
super.dispose();
|
|
8365
8330
|
}
|
|
@@ -8375,7 +8340,7 @@ var loadOptionsValidator3 = /* @__PURE__ */ trackLoadOptionsValidator.extend({
|
|
|
8375
8340
|
function createDashTrackFactory(deps) {
|
|
8376
8341
|
return {
|
|
8377
8342
|
validate(options) {
|
|
8378
|
-
loadOptionsValidator3.assert(options,
|
|
8343
|
+
loadOptionsValidator3.assert(options, import_vinyl_util81.ErrorOrigin.API);
|
|
8379
8344
|
},
|
|
8380
8345
|
createTrack(loadOptions) {
|
|
8381
8346
|
return new MseTrack(
|
|
@@ -8388,7 +8353,7 @@ function createDashTrackFactory(deps) {
|
|
|
8388
8353
|
}
|
|
8389
8354
|
|
|
8390
8355
|
// src/track/hls/HlsTrack.ts
|
|
8391
|
-
var
|
|
8356
|
+
var import_vinyl_util82 = require("@amazon/vinyl-util");
|
|
8392
8357
|
var import_vinyl_validation17 = require("@amazon/vinyl-validation");
|
|
8393
8358
|
var loadOptionsValidator4 = /* @__PURE__ */ trackLoadOptionsValidator.extend({
|
|
8394
8359
|
manifestProvider: /* @__PURE__ */ (0, import_vinyl_validation17.func)().maybe().optional(),
|
|
@@ -8399,7 +8364,7 @@ var loadOptionsValidator4 = /* @__PURE__ */ trackLoadOptionsValidator.extend({
|
|
|
8399
8364
|
function createHlsTrackFactory(deps) {
|
|
8400
8365
|
return {
|
|
8401
8366
|
validate(options) {
|
|
8402
|
-
loadOptionsValidator4.assert(options,
|
|
8367
|
+
loadOptionsValidator4.assert(options, import_vinyl_util82.ErrorOrigin.API);
|
|
8403
8368
|
},
|
|
8404
8369
|
createTrack(loadOptions) {
|
|
8405
8370
|
return new MseTrack(
|
|
@@ -8422,7 +8387,7 @@ function createVinylTrackFactories(deps) {
|
|
|
8422
8387
|
}
|
|
8423
8388
|
|
|
8424
8389
|
// src/track/dash/util/mpd.ts
|
|
8425
|
-
var
|
|
8390
|
+
var import_vinyl_util83 = require("@amazon/vinyl-util");
|
|
8426
8391
|
|
|
8427
8392
|
// src/track/mse/codec.ts
|
|
8428
8393
|
var VIDEO_CODEC_PREFIXES = [
|
|
@@ -8525,19 +8490,24 @@ function getRepresentationAncestry(representation) {
|
|
|
8525
8490
|
}
|
|
8526
8491
|
function mergeIfAnyDefined(...sources) {
|
|
8527
8492
|
if (!sources.some((source) => source)) return void 0;
|
|
8528
|
-
return (0,
|
|
8493
|
+
return (0, import_vinyl_util83.merge)(...sources);
|
|
8529
8494
|
}
|
|
8530
8495
|
function calculatePeriodTimeRange(period) {
|
|
8531
8496
|
return [calculatePeriodStart(period), calculatePeriodEnd(period)];
|
|
8532
8497
|
}
|
|
8533
8498
|
function calculatePeriodStart(period) {
|
|
8534
|
-
|
|
8535
|
-
|
|
8499
|
+
if (period.start != null) return period.start;
|
|
8500
|
+
const mpd = period.parent;
|
|
8501
|
+
const periodIndex = mpd.Period.indexOf(period);
|
|
8502
|
+
if (periodIndex <= 0) return 0;
|
|
8503
|
+
const previous = mpd.Period[periodIndex - 1];
|
|
8504
|
+
const previousStart = calculatePeriodStart(previous);
|
|
8505
|
+
return previous.duration != null ? previousStart + previous.duration : previousStart;
|
|
8536
8506
|
}
|
|
8537
8507
|
function calculatePeriodEnd(period) {
|
|
8538
8508
|
var _a;
|
|
8539
|
-
if (period.
|
|
8540
|
-
return period
|
|
8509
|
+
if (period.duration != null)
|
|
8510
|
+
return calculatePeriodStart(period) + period.duration;
|
|
8541
8511
|
const mpd = period.parent;
|
|
8542
8512
|
const periodIndex = mpd.Period.indexOf(period);
|
|
8543
8513
|
if (periodIndex < mpd.Period.length - 1)
|
|
@@ -8548,7 +8518,7 @@ function sampleToMpdTime(sampleTime, periodStart, presentationTimeOffset, timesc
|
|
|
8548
8518
|
return periodStart + (sampleTime - presentationTimeOffset) / timescale;
|
|
8549
8519
|
}
|
|
8550
8520
|
function getPeriodAtTime(manifest, time) {
|
|
8551
|
-
const index = (0,
|
|
8521
|
+
const index = (0, import_vinyl_util83.sortedInsertionIndex)(manifest.MPD.Period, time, (time2, period2) => {
|
|
8552
8522
|
return time2 - calculatePeriodStart(period2);
|
|
8553
8523
|
}) - 1;
|
|
8554
8524
|
if (index < 0) return null;
|
|
@@ -8577,7 +8547,7 @@ function calculateDuration(manifest) {
|
|
|
8577
8547
|
if (manifest.MPD.type === "dynamic") return Infinity;
|
|
8578
8548
|
const mpdDuration = manifest.MPD.mediaPresentationDuration;
|
|
8579
8549
|
if (mpdDuration != null) return mpdDuration;
|
|
8580
|
-
const lastPeriod = (0,
|
|
8550
|
+
const lastPeriod = (0, import_vinyl_util83.last)(manifest.MPD.Period);
|
|
8581
8551
|
if (!lastPeriod) {
|
|
8582
8552
|
throw new Error("Unable to determine manifest duration: no periods");
|
|
8583
8553
|
}
|
|
@@ -8589,10 +8559,10 @@ function calculateDuration(manifest) {
|
|
|
8589
8559
|
}
|
|
8590
8560
|
|
|
8591
8561
|
// src/track/dash/timeline/DashRepresentationSegmentProvider.ts
|
|
8592
|
-
var
|
|
8562
|
+
var import_vinyl_util85 = require("@amazon/vinyl-util");
|
|
8593
8563
|
|
|
8594
8564
|
// src/track/dash/util/uriResolution.ts
|
|
8595
|
-
var
|
|
8565
|
+
var import_vinyl_util84 = require("@amazon/vinyl-util");
|
|
8596
8566
|
var pickFirstBaseUrlSelector = {
|
|
8597
8567
|
selectBaseUrl(baseUrls) {
|
|
8598
8568
|
return baseUrls[0];
|
|
@@ -8607,17 +8577,17 @@ function resolveDashUri(deps, options) {
|
|
|
8607
8577
|
scopeChain.forEach((scope) => {
|
|
8608
8578
|
if (scope.BaseURL && scope.BaseURL.length) {
|
|
8609
8579
|
const selectedBaseUrl = baseUrlSelector.selectBaseUrl(scope.BaseURL);
|
|
8610
|
-
resolved = (0,
|
|
8580
|
+
resolved = (0, import_vinyl_util84.resolveUrl)(selectedBaseUrl._content, resolved);
|
|
8611
8581
|
if (selectedBaseUrl.serviceLocation)
|
|
8612
8582
|
serviceLocation = selectedBaseUrl.serviceLocation;
|
|
8613
8583
|
}
|
|
8614
8584
|
});
|
|
8615
8585
|
if (uri != null) {
|
|
8616
|
-
resolved = (0,
|
|
8586
|
+
resolved = (0, import_vinyl_util84.resolveUrl)(uri, resolved);
|
|
8617
8587
|
} else if (resolved === baseUrl) {
|
|
8618
|
-
throw new
|
|
8588
|
+
throw new import_vinyl_util84.ValidationError(
|
|
8619
8589
|
"media missing URI or BaseURL",
|
|
8620
|
-
|
|
8590
|
+
import_vinyl_util84.ErrorOrigin.MEDIA
|
|
8621
8591
|
);
|
|
8622
8592
|
}
|
|
8623
8593
|
return { url: resolved, serviceLocation };
|
|
@@ -8625,15 +8595,15 @@ function resolveDashUri(deps, options) {
|
|
|
8625
8595
|
function segmentTemplateUrl(uri, options) {
|
|
8626
8596
|
var _a, _b;
|
|
8627
8597
|
try {
|
|
8628
|
-
return (0,
|
|
8598
|
+
return (0, import_vinyl_util84.substituteIdentifiers)(uri, {
|
|
8629
8599
|
Bandwidth: options.representation.bandwidth,
|
|
8630
8600
|
Number: (_a = options.segmentNumber) != null ? _a : 0,
|
|
8631
8601
|
RepresentationID: options.representation.id,
|
|
8632
8602
|
Time: (_b = options.sampleTime) != null ? _b : 0
|
|
8633
8603
|
});
|
|
8634
8604
|
} catch (error) {
|
|
8635
|
-
if (error instanceof
|
|
8636
|
-
throw new
|
|
8605
|
+
if (error instanceof import_vinyl_util84.IllegalArgumentError) {
|
|
8606
|
+
throw new import_vinyl_util84.ValidationError(error.message, import_vinyl_util84.ErrorOrigin.MEDIA);
|
|
8637
8607
|
} else {
|
|
8638
8608
|
throw error;
|
|
8639
8609
|
}
|
|
@@ -8662,9 +8632,9 @@ function createDashRepresentationSegmentProvider(deps, baseUrl, representation)
|
|
|
8662
8632
|
}
|
|
8663
8633
|
const commonSegmentBase = (_a = segmentTemplate != null ? segmentTemplate : segmentList) != null ? _a : segmentBase;
|
|
8664
8634
|
if (!commonSegmentBase) {
|
|
8665
|
-
throw new
|
|
8635
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8666
8636
|
"Manifest must have one of SegmentList, SegmentTemplate, or SegmentBase",
|
|
8667
|
-
|
|
8637
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8668
8638
|
);
|
|
8669
8639
|
}
|
|
8670
8640
|
if (commonSegmentBase.Initialization) {
|
|
@@ -8672,9 +8642,9 @@ function createDashRepresentationSegmentProvider(deps, baseUrl, representation)
|
|
|
8672
8642
|
initRange = commonSegmentBase.Initialization.range;
|
|
8673
8643
|
}
|
|
8674
8644
|
if (!initUri && !initRange)
|
|
8675
|
-
throw new
|
|
8645
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8676
8646
|
"Missing initialization range",
|
|
8677
|
-
|
|
8647
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8678
8648
|
);
|
|
8679
8649
|
const { url: initUrl, serviceLocation: initServiceLocation } = resolveDashUri(deps, { baseUrl, representation, uri: initUri });
|
|
8680
8650
|
const initData = createSegmentDataProvider(deps, {
|
|
@@ -8693,9 +8663,13 @@ function createDashRepresentationSegmentProvider(deps, baseUrl, representation)
|
|
|
8693
8663
|
segmentTemplate
|
|
8694
8664
|
}));
|
|
8695
8665
|
} else if (segmentBase) {
|
|
8696
|
-
getSegmentReferences = () => createSegmentsFromSegmentBase(
|
|
8697
|
-
|
|
8698
|
-
|
|
8666
|
+
getSegmentReferences = () => createSegmentsFromSegmentBase(
|
|
8667
|
+
deps,
|
|
8668
|
+
__spreadProps(__spreadValues({}, options), {
|
|
8669
|
+
segmentBase
|
|
8670
|
+
}),
|
|
8671
|
+
initData
|
|
8672
|
+
);
|
|
8699
8673
|
}
|
|
8700
8674
|
return {
|
|
8701
8675
|
async getSegment(time, affordance = 0) {
|
|
@@ -8752,14 +8726,14 @@ function createSegmentsFromSegmentList(deps, options) {
|
|
|
8752
8726
|
);
|
|
8753
8727
|
} else {
|
|
8754
8728
|
if (segmentList.href) {
|
|
8755
|
-
throw new
|
|
8729
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8756
8730
|
"SegmentList.href currently unsupported",
|
|
8757
|
-
|
|
8731
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8758
8732
|
);
|
|
8759
8733
|
} else {
|
|
8760
|
-
throw new
|
|
8734
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8761
8735
|
"could not determine segments from SegmentList",
|
|
8762
|
-
|
|
8736
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8763
8737
|
);
|
|
8764
8738
|
}
|
|
8765
8739
|
}
|
|
@@ -8768,9 +8742,9 @@ function createSegmentsFromSegmentTemplate(deps, options) {
|
|
|
8768
8742
|
var _a, _b;
|
|
8769
8743
|
const { baseUrl, periodTimeRange, representation, segmentTemplate } = options;
|
|
8770
8744
|
if (!segmentTemplate.media) {
|
|
8771
|
-
throw new
|
|
8745
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8772
8746
|
"SegmentTemplate.media required",
|
|
8773
|
-
|
|
8747
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8774
8748
|
);
|
|
8775
8749
|
}
|
|
8776
8750
|
const media = segmentTemplate.media;
|
|
@@ -8807,13 +8781,17 @@ function createSegmentsFromSegmentTemplate(deps, options) {
|
|
|
8807
8781
|
}
|
|
8808
8782
|
);
|
|
8809
8783
|
}
|
|
8810
|
-
async function createSegmentsFromSegmentBase(deps, options) {
|
|
8784
|
+
async function createSegmentsFromSegmentBase(deps, options, initData) {
|
|
8811
8785
|
var _a;
|
|
8812
8786
|
const { baseUrl, periodTimeRange, representation, segmentBase } = options;
|
|
8813
8787
|
if (segmentBase.indexRange) {
|
|
8788
|
+
const { mimeType } = getRepresentationMimeInfo(representation);
|
|
8789
|
+
if (mimeType == null ? void 0 : mimeType.includes("webm")) {
|
|
8790
|
+
return createSegmentsFromWebmCues(deps, options, initData);
|
|
8791
|
+
}
|
|
8814
8792
|
const indexRange = segmentBase.indexRange;
|
|
8815
8793
|
const { url: indexUrl, serviceLocation: indexServiceLocation } = resolveDashUri(deps, { baseUrl, representation });
|
|
8816
|
-
const sidx = (0,
|
|
8794
|
+
const sidx = (0, import_vinyl_util85.parseSidxBox)(
|
|
8817
8795
|
await createSegmentDataProvider(deps, {
|
|
8818
8796
|
url: indexUrl,
|
|
8819
8797
|
mediaRange: indexRange,
|
|
@@ -8821,7 +8799,7 @@ async function createSegmentsFromSegmentBase(deps, options) {
|
|
|
8821
8799
|
reportDownlinkMetrics: false
|
|
8822
8800
|
})()
|
|
8823
8801
|
);
|
|
8824
|
-
const sampleTimes = (0,
|
|
8802
|
+
const sampleTimes = (0, import_vinyl_util85.getSidxSampleTimes)(sidx);
|
|
8825
8803
|
let rangeStart = Number(sidx.firstOffset) + indexRange[1] + 1;
|
|
8826
8804
|
return createTimeline(
|
|
8827
8805
|
{
|
|
@@ -8844,8 +8822,58 @@ async function createSegmentsFromSegmentBase(deps, options) {
|
|
|
8844
8822
|
}
|
|
8845
8823
|
);
|
|
8846
8824
|
} else {
|
|
8847
|
-
throw new
|
|
8825
|
+
throw new import_vinyl_util85.ValidationError("Manifest missing segments");
|
|
8826
|
+
}
|
|
8827
|
+
}
|
|
8828
|
+
async function createSegmentsFromWebmCues(deps, options, initData) {
|
|
8829
|
+
var _a, _b;
|
|
8830
|
+
const { baseUrl, periodTimeRange, representation, segmentBase } = options;
|
|
8831
|
+
const indexRange = segmentBase.indexRange;
|
|
8832
|
+
const { url, serviceLocation } = resolveDashUri(deps, {
|
|
8833
|
+
baseUrl,
|
|
8834
|
+
representation
|
|
8835
|
+
});
|
|
8836
|
+
const [{ segmentDataStart, timecodeScale }, cues] = await Promise.all([
|
|
8837
|
+
Promise.resolve(initData()).then(import_vinyl_util85.parseWebmInit),
|
|
8838
|
+
createSegmentDataProvider(deps, {
|
|
8839
|
+
url,
|
|
8840
|
+
mediaRange: indexRange,
|
|
8841
|
+
serviceId: serviceLocation,
|
|
8842
|
+
reportDownlinkMetrics: false
|
|
8843
|
+
})().then(import_vinyl_util85.parseWebmCues)
|
|
8844
|
+
]);
|
|
8845
|
+
if (!cues.length) {
|
|
8846
|
+
throw new import_vinyl_util85.ValidationError("WebM Cues contained no cue points");
|
|
8848
8847
|
}
|
|
8848
|
+
const ticksPerSecond = Math.round(1e9 / timecodeScale);
|
|
8849
|
+
const manifestTimescale = (_a = segmentBase.timescale) != null ? _a : ticksPerSecond;
|
|
8850
|
+
const presentationTimeOffset = ((_b = segmentBase.presentationTimeOffset) != null ? _b : 0) * ticksPerSecond / manifestTimescale;
|
|
8851
|
+
const [, periodEnd] = periodTimeRange;
|
|
8852
|
+
if (periodEnd == null)
|
|
8853
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8854
|
+
"MPD.mediaPresentationDuration or Period.duration required",
|
|
8855
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8856
|
+
);
|
|
8857
|
+
const sampleTimes = cues.map((cue) => cue.time);
|
|
8858
|
+
sampleTimes.push(periodEnd * ticksPerSecond);
|
|
8859
|
+
return createTimeline(
|
|
8860
|
+
{
|
|
8861
|
+
sampleTimes,
|
|
8862
|
+
periodTimeRange,
|
|
8863
|
+
presentationTimeOffset,
|
|
8864
|
+
timescale: ticksPerSecond
|
|
8865
|
+
},
|
|
8866
|
+
(i) => {
|
|
8867
|
+
const start = segmentDataStart + cues[i].clusterPosition;
|
|
8868
|
+
const end = i < cues.length - 1 ? segmentDataStart + cues[i + 1].clusterPosition - 1 : null;
|
|
8869
|
+
return createSegmentDataProvider(deps, {
|
|
8870
|
+
url,
|
|
8871
|
+
mediaRange: [start, end],
|
|
8872
|
+
serviceId: serviceLocation,
|
|
8873
|
+
reportDownlinkMetrics: true
|
|
8874
|
+
});
|
|
8875
|
+
}
|
|
8876
|
+
);
|
|
8849
8877
|
}
|
|
8850
8878
|
function calculateSegmentSampleTimes(options) {
|
|
8851
8879
|
const { multipleSegmentBase, periodTimeRange } = options;
|
|
@@ -8886,9 +8914,9 @@ function calculateFixedSegmentSampleTimes(options) {
|
|
|
8886
8914
|
const { sampleDuration, timescale } = options;
|
|
8887
8915
|
const [periodStart, periodEnd] = options.periodTimeRange;
|
|
8888
8916
|
if (periodEnd == null)
|
|
8889
|
-
throw new
|
|
8917
|
+
throw new import_vinyl_util85.ValidationError(
|
|
8890
8918
|
"MPD.mediaPresentationDuration or Period.duration required",
|
|
8891
|
-
|
|
8919
|
+
import_vinyl_util85.ErrorOrigin.MEDIA
|
|
8892
8920
|
);
|
|
8893
8921
|
const numSegments = (_a = options.numSegments) != null ? _a : Math.ceil((periodEnd - periodStart) / (sampleDuration / timescale));
|
|
8894
8922
|
const out = new Array(numSegments + 1);
|
|
@@ -8931,12 +8959,12 @@ function createTimeline({
|
|
|
8931
8959
|
}
|
|
8932
8960
|
function getTimescale(multipleSegmentBase) {
|
|
8933
8961
|
if (!multipleSegmentBase.timescale)
|
|
8934
|
-
throw new
|
|
8962
|
+
throw new import_vinyl_util85.ValidationError("invalid timescale", import_vinyl_util85.ErrorOrigin.MEDIA);
|
|
8935
8963
|
return multipleSegmentBase.timescale;
|
|
8936
8964
|
}
|
|
8937
8965
|
function getSampleDuration(multipleSegmentBase) {
|
|
8938
8966
|
if (!multipleSegmentBase.duration)
|
|
8939
|
-
throw new
|
|
8967
|
+
throw new import_vinyl_util85.ValidationError("invalid duration", import_vinyl_util85.ErrorOrigin.MEDIA);
|
|
8940
8968
|
return multipleSegmentBase.duration;
|
|
8941
8969
|
}
|
|
8942
8970
|
|
|
@@ -8975,10 +9003,10 @@ function buildDashMediaTimeline(deps, data3) {
|
|
|
8975
9003
|
}
|
|
8976
9004
|
|
|
8977
9005
|
// src/track/dash/createDashContentStreamFactories.ts
|
|
8978
|
-
var
|
|
9006
|
+
var import_vinyl_util86 = require("@amazon/vinyl-util");
|
|
8979
9007
|
var import_vinyl_di3 = require("@amazon/vinyl-di");
|
|
8980
9008
|
function createDashContentStreamFactories(options) {
|
|
8981
|
-
return (deps) => (0,
|
|
9009
|
+
return (deps) => (0, import_vinyl_util86.memoize)(
|
|
8982
9010
|
(contentType2) => {
|
|
8983
9011
|
return (0, import_vinyl_di3.validateFactories)(__spreadProps(__spreadValues({}, (0, import_vinyl_di3.externalDependencies)(deps)), {
|
|
8984
9012
|
sourceBufferControllerFactory: (deps2) => () => new SourceBufferControllerImpl(deps2, contentType2),
|
|
@@ -9019,10 +9047,10 @@ function getContentTypes(deps, manifest) {
|
|
|
9019
9047
|
}
|
|
9020
9048
|
|
|
9021
9049
|
// src/track/dash/createDefaultDashManifestTransformer.ts
|
|
9022
|
-
var
|
|
9050
|
+
var import_vinyl_util88 = require("@amazon/vinyl-util");
|
|
9023
9051
|
|
|
9024
9052
|
// src/track/dash/manifestTransformUtils.ts
|
|
9025
|
-
var
|
|
9053
|
+
var import_vinyl_util87 = require("@amazon/vinyl-util");
|
|
9026
9054
|
function manifestIsPlayable(manifest) {
|
|
9027
9055
|
return manifest.MPD.Period.every(
|
|
9028
9056
|
(period) => {
|
|
@@ -9037,7 +9065,7 @@ function manifestIsPlayable(manifest) {
|
|
|
9037
9065
|
);
|
|
9038
9066
|
}
|
|
9039
9067
|
function filterDashRepresentations(filter, throwError, manifest) {
|
|
9040
|
-
const result = (0,
|
|
9068
|
+
const result = (0, import_vinyl_util87.clone)(manifest);
|
|
9041
9069
|
for (const period of result.MPD.Period) {
|
|
9042
9070
|
if (period.AdaptationSet) {
|
|
9043
9071
|
for (const adaptationSet of period.AdaptationSet) {
|
|
@@ -9053,7 +9081,7 @@ function filterDashRepresentations(filter, throwError, manifest) {
|
|
|
9053
9081
|
return result;
|
|
9054
9082
|
}
|
|
9055
9083
|
function filterDashAdaptationSets(filter, throwError, manifest) {
|
|
9056
|
-
const result = (0,
|
|
9084
|
+
const result = (0, import_vinyl_util87.clone)(manifest);
|
|
9057
9085
|
for (const period of result.MPD.Period) {
|
|
9058
9086
|
if (period.AdaptationSet) {
|
|
9059
9087
|
period.AdaptationSet = period.AdaptationSet.filter(filter);
|
|
@@ -9066,14 +9094,14 @@ function filterDashAdaptationSets(filter, throwError, manifest) {
|
|
|
9066
9094
|
}
|
|
9067
9095
|
function sortDashAdaptationSets(comparator, manifest) {
|
|
9068
9096
|
var _a;
|
|
9069
|
-
const result = (0,
|
|
9097
|
+
const result = (0, import_vinyl_util87.clone)(manifest);
|
|
9070
9098
|
for (const period of result.MPD.Period) {
|
|
9071
9099
|
(_a = period.AdaptationSet) == null ? void 0 : _a.sort(comparator);
|
|
9072
9100
|
}
|
|
9073
9101
|
return result;
|
|
9074
9102
|
}
|
|
9075
9103
|
function sortDashRepresentations(comparator, manifest) {
|
|
9076
|
-
const result = (0,
|
|
9104
|
+
const result = (0, import_vinyl_util87.clone)(manifest);
|
|
9077
9105
|
for (const period of result.MPD.Period) {
|
|
9078
9106
|
if (period.AdaptationSet) {
|
|
9079
9107
|
for (const adaptationSet of period.AdaptationSet) {
|
|
@@ -9108,21 +9136,21 @@ function createDefaultDashManifestTransformer(deps) {
|
|
|
9108
9136
|
});
|
|
9109
9137
|
}
|
|
9110
9138
|
function createDefaultAdaptationSetComparator() {
|
|
9111
|
-
return (0,
|
|
9139
|
+
return (0, import_vinyl_util88.compareBy)((adaptationSet) => -adaptationSet.selectionPriority);
|
|
9112
9140
|
}
|
|
9113
9141
|
function createDefaultRepresentationComparator() {
|
|
9114
|
-
return (0,
|
|
9142
|
+
return (0, import_vinyl_util88.compareBy)(
|
|
9115
9143
|
(representation) => representation.qualityRanking,
|
|
9116
9144
|
(representation) => -representation.bandwidth
|
|
9117
9145
|
);
|
|
9118
9146
|
}
|
|
9119
9147
|
|
|
9120
9148
|
// src/track/dash/DashMediaQualityMetadataResolver.ts
|
|
9121
|
-
var
|
|
9149
|
+
var import_vinyl_util89 = require("@amazon/vinyl-util");
|
|
9122
9150
|
var import_vinyl_mpd_parser3 = require("@amazon/vinyl-mpd-parser");
|
|
9123
9151
|
var ADAPTATION_SET_SWITCHING_SCHEME = "urn:mpeg:dash:adaptation-set-switching:2016";
|
|
9124
9152
|
function createDefaultDashMediaQualityMetadataResolver(deps) {
|
|
9125
|
-
return (0,
|
|
9153
|
+
return (0, import_vinyl_util89.memoize)(
|
|
9126
9154
|
(representation) => createMediaQualityMetadataFromDashRepresentation(
|
|
9127
9155
|
representation,
|
|
9128
9156
|
deps
|
|
@@ -9135,9 +9163,9 @@ function createMediaQualityMetadataFromDashRepresentation(representation, deps)
|
|
|
9135
9163
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9136
9164
|
const { contentType: contentType2, mimeType } = getRepresentationMimeInfo(representation);
|
|
9137
9165
|
if (!contentType2 || !mimeType)
|
|
9138
|
-
throw new
|
|
9166
|
+
throw new import_vinyl_util89.ValidationError(
|
|
9139
9167
|
"mimeType cannot be inferred",
|
|
9140
|
-
|
|
9168
|
+
import_vinyl_util89.ErrorOrigin.MEDIA
|
|
9141
9169
|
);
|
|
9142
9170
|
const adaptationSet = representation.parent;
|
|
9143
9171
|
const period = adaptationSet.parent;
|
|
@@ -9211,21 +9239,20 @@ function estimatePeakBandwidth(representation, contentType2) {
|
|
|
9211
9239
|
if (!own || own.length === 0) return representation.bandwidth;
|
|
9212
9240
|
const ownIndex = Math.max(
|
|
9213
9241
|
0,
|
|
9214
|
-
(0,
|
|
9242
|
+
(0, import_vinyl_util89.sortedInsertionIndex)(own, representation.bandwidth, (a, b) => b - a) - 1
|
|
9215
9243
|
);
|
|
9216
|
-
const position = own.length <= 1 ? 0 : ownIndex / (own.length - 1);
|
|
9217
9244
|
let total = representation.bandwidth;
|
|
9218
9245
|
for (const [ct, bandwidths] of sortedByType) {
|
|
9219
9246
|
if (ct === contentType2) continue;
|
|
9220
9247
|
const peerIndex = Math.min(
|
|
9221
|
-
|
|
9222
|
-
bandwidths.length - 1
|
|
9248
|
+
bandwidths.length - 1,
|
|
9249
|
+
Math.ceil((ownIndex + 1) / own.length * bandwidths.length) - 1
|
|
9223
9250
|
);
|
|
9224
9251
|
total += bandwidths[peerIndex];
|
|
9225
9252
|
}
|
|
9226
9253
|
return total;
|
|
9227
9254
|
}
|
|
9228
|
-
var getPeriodSortedBandwidths = /* @__PURE__ */ (0,
|
|
9255
|
+
var getPeriodSortedBandwidths = /* @__PURE__ */ (0, import_vinyl_util89.memoize)(
|
|
9229
9256
|
(period) => {
|
|
9230
9257
|
var _a, _b;
|
|
9231
9258
|
const byType = /* @__PURE__ */ new Map();
|
|
@@ -9233,11 +9260,11 @@ var getPeriodSortedBandwidths = /* @__PURE__ */ (0, import_vinyl_util93.memoize)
|
|
|
9233
9260
|
for (const rep of (_b = as.Representation) != null ? _b : []) {
|
|
9234
9261
|
const contentType2 = getRepresentationMimeInfo(rep).contentType;
|
|
9235
9262
|
if (!contentType2) continue;
|
|
9236
|
-
const arr = (0,
|
|
9263
|
+
const arr = (0, import_vinyl_util89.getOrSet)(byType, contentType2, () => []);
|
|
9237
9264
|
if (!arr.some(
|
|
9238
9265
|
(existing) => Math.abs(existing - rep.bandwidth) / existing < 0.1
|
|
9239
9266
|
)) {
|
|
9240
|
-
const index = (0,
|
|
9267
|
+
const index = (0, import_vinyl_util89.sortedInsertionIndex)(
|
|
9241
9268
|
arr,
|
|
9242
9269
|
rep.bandwidth,
|
|
9243
9270
|
(a, b) => b - a
|
|
@@ -9266,7 +9293,7 @@ function mapDescriptors(descriptors) {
|
|
|
9266
9293
|
var _a, _b;
|
|
9267
9294
|
const out = {};
|
|
9268
9295
|
for (const descriptor of descriptors) {
|
|
9269
|
-
const arr = (0,
|
|
9296
|
+
const arr = (0, import_vinyl_util89.getOrSetProp)(out, descriptor.schemeIdUri, () => []);
|
|
9270
9297
|
arr.push({
|
|
9271
9298
|
id: (_a = descriptor.id) != null ? _a : null,
|
|
9272
9299
|
value: (_b = descriptor.value) != null ? _b : null
|
|
@@ -9291,27 +9318,27 @@ function resolveAdaptationSetSwitchingGroupIds(adaptationSet, periodId, adaptati
|
|
|
9291
9318
|
var import_vinyl_di4 = require("@amazon/vinyl-di");
|
|
9292
9319
|
|
|
9293
9320
|
// src/track/dash/urlDashManifestProvider.ts
|
|
9294
|
-
var
|
|
9295
|
-
var
|
|
9296
|
-
var
|
|
9321
|
+
var import_vinyl_util90 = require("@amazon/vinyl-util");
|
|
9322
|
+
var import_vinyl_util91 = require("@amazon/vinyl-util");
|
|
9323
|
+
var import_vinyl_util92 = require("@amazon/vinyl-util");
|
|
9297
9324
|
var import_vinyl_mpd_parser4 = require("@amazon/vinyl-mpd-parser");
|
|
9298
|
-
function urlDashManifestProvider(input, init, requestInterceptor =
|
|
9325
|
+
function urlDashManifestProvider(input, init, requestInterceptor = import_vinyl_util90.noop) {
|
|
9299
9326
|
return async (abort) => {
|
|
9300
9327
|
var _a;
|
|
9301
9328
|
const params = {
|
|
9302
|
-
input: (0,
|
|
9303
|
-
init: (_a = (0,
|
|
9329
|
+
input: (0, import_vinyl_util91.resolveUrl)(input, (0, import_vinyl_util91.getLocation)().href),
|
|
9330
|
+
init: (_a = (0, import_vinyl_util91.clone)(init)) != null ? _a : {}
|
|
9304
9331
|
};
|
|
9305
9332
|
requestInterceptor(params);
|
|
9306
|
-
const response = await (0,
|
|
9333
|
+
const response = await (0, import_vinyl_util92.requestWithRetry)(params.input, params.init, {
|
|
9307
9334
|
abort
|
|
9308
9335
|
});
|
|
9309
|
-
const xml = await response
|
|
9336
|
+
const xml = await (0, import_vinyl_util92.readResponseBody)(response, "text");
|
|
9310
9337
|
const manifest = (0, import_vinyl_mpd_parser4.parseDashManifest)(xml);
|
|
9311
9338
|
const baseInput = response.url || params.input;
|
|
9312
9339
|
return {
|
|
9313
9340
|
manifest,
|
|
9314
|
-
baseUrl: (0,
|
|
9341
|
+
baseUrl: (0, import_vinyl_util91.resolveUrl)("./", baseInput)
|
|
9315
9342
|
};
|
|
9316
9343
|
};
|
|
9317
9344
|
}
|
|
@@ -9395,7 +9422,7 @@ function hlsByteRangeToMediaRange(byteRange) {
|
|
|
9395
9422
|
}
|
|
9396
9423
|
|
|
9397
9424
|
// src/track/hls/util/hlsSegmentTime.ts
|
|
9398
|
-
var
|
|
9425
|
+
var import_vinyl_util93 = require("@amazon/vinyl-util");
|
|
9399
9426
|
function buildSegmentTimeline(deps, baseUrl, segments) {
|
|
9400
9427
|
const out = new Array(
|
|
9401
9428
|
segments.length
|
|
@@ -9405,7 +9432,7 @@ function buildSegmentTimeline(deps, baseUrl, segments) {
|
|
|
9405
9432
|
const seg = segments[i];
|
|
9406
9433
|
const startTime = time;
|
|
9407
9434
|
const endTime = time + seg.duration;
|
|
9408
|
-
const url = (0,
|
|
9435
|
+
const url = (0, import_vinyl_util93.resolveUrl)(seg.uri, baseUrl);
|
|
9409
9436
|
out[i] = {
|
|
9410
9437
|
timestampOffset: startTime,
|
|
9411
9438
|
startTime,
|
|
@@ -9422,7 +9449,7 @@ function buildSegmentTimeline(deps, baseUrl, segments) {
|
|
|
9422
9449
|
}
|
|
9423
9450
|
|
|
9424
9451
|
// src/track/hls/buildHlsMediaTimeline.ts
|
|
9425
|
-
var
|
|
9452
|
+
var import_vinyl_util94 = require("@amazon/vinyl-util");
|
|
9426
9453
|
var import_vinyl_transmux = require("@amazon/vinyl-transmux");
|
|
9427
9454
|
function buildHlsMediaTimeline(deps, data3) {
|
|
9428
9455
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -9524,7 +9551,7 @@ function createHlsQualityData(deps, data3, baseUrl, playlistUri, metadata) {
|
|
|
9524
9551
|
async getSegment(time, affordance = 0) {
|
|
9525
9552
|
var _a;
|
|
9526
9553
|
const playlist = await data3.getMediaPlaylist(playlistUri);
|
|
9527
|
-
const playlistBaseUrl = (0,
|
|
9554
|
+
const playlistBaseUrl = (0, import_vinyl_util94.resolveUrl)(playlistUri, baseUrl);
|
|
9528
9555
|
const segments = buildSegmentTimeline(
|
|
9529
9556
|
deps,
|
|
9530
9557
|
playlistBaseUrl,
|
|
@@ -9538,7 +9565,7 @@ function createHlsQualityData(deps, data3, baseUrl, playlistUri, metadata) {
|
|
|
9538
9565
|
quality: metadata
|
|
9539
9566
|
}, segment), {
|
|
9540
9567
|
initData: createSegmentDataProvider(deps, {
|
|
9541
|
-
url: (0,
|
|
9568
|
+
url: (0, import_vinyl_util94.resolveUrl)(hlsMap.uri, playlistBaseUrl),
|
|
9542
9569
|
mediaRange: hlsMap.byteRange ? hlsByteRangeToMediaRange(hlsMap.byteRange) : void 0,
|
|
9543
9570
|
reportDownlinkMetrics: false
|
|
9544
9571
|
})
|
|
@@ -9571,7 +9598,7 @@ async function discoverAdsFromManifest(data3) {
|
|
|
9571
9598
|
const variant = data3.mainPlaylist.variants[0];
|
|
9572
9599
|
const media = await data3.getMediaPlaylist(variant.uri);
|
|
9573
9600
|
const contentDuration = media.ended ? media.segments.reduce((sum, s) => sum + s.duration, 0) : null;
|
|
9574
|
-
const playlistBaseUrl = (0,
|
|
9601
|
+
const playlistBaseUrl = (0, import_vinyl_util94.resolveUrl)(variant.uri, data3.baseUrl);
|
|
9575
9602
|
return discoverHlsInterstitials(media, playlistBaseUrl, contentDuration);
|
|
9576
9603
|
}
|
|
9577
9604
|
|
|
@@ -9591,10 +9618,10 @@ function createDefaultHlsManifestTransformer(deps) {
|
|
|
9591
9618
|
}
|
|
9592
9619
|
|
|
9593
9620
|
// src/track/hls/createHlsContentStreamFactories.ts
|
|
9594
|
-
var
|
|
9621
|
+
var import_vinyl_util95 = require("@amazon/vinyl-util");
|
|
9595
9622
|
var import_vinyl_di5 = require("@amazon/vinyl-di");
|
|
9596
9623
|
function createHlsContentStreamFactories(options) {
|
|
9597
|
-
return (deps) => (0,
|
|
9624
|
+
return (deps) => (0, import_vinyl_util95.memoize)(
|
|
9598
9625
|
(contentType2) => {
|
|
9599
9626
|
return (0, import_vinyl_di5.validateFactories)(__spreadProps(__spreadValues({}, (0, import_vinyl_di5.externalDependencies)(deps)), {
|
|
9600
9627
|
sourceBufferControllerFactory: (deps2) => () => new SourceBufferControllerImpl(deps2, contentType2),
|
|
@@ -9679,19 +9706,19 @@ var import_vinyl_di6 = require("@amazon/vinyl-di");
|
|
|
9679
9706
|
|
|
9680
9707
|
// src/track/hls/createUrlHlsManifestProvider.ts
|
|
9681
9708
|
var import_vinyl_hls_parser3 = require("@amazon/vinyl-hls-parser");
|
|
9682
|
-
var
|
|
9709
|
+
var import_vinyl_util96 = require("@amazon/vinyl-util");
|
|
9683
9710
|
function createUrlHlsManifestProvider(url, requestInit) {
|
|
9684
9711
|
return async (abort) => {
|
|
9685
|
-
const mainResponse = await (0,
|
|
9712
|
+
const mainResponse = await (0, import_vinyl_util96.requestWithRetry)(url, requestInit, {
|
|
9686
9713
|
abort
|
|
9687
9714
|
});
|
|
9688
|
-
const mainText = await mainResponse
|
|
9715
|
+
const mainText = await (0, import_vinyl_util96.readResponseBody)(mainResponse, "text");
|
|
9689
9716
|
const baseUrl = mainResponse.url || url;
|
|
9690
9717
|
const mainPlaylist = (0, import_vinyl_hls_parser3.parseMainPlaylist)(
|
|
9691
9718
|
mainText,
|
|
9692
9719
|
parseQueryParams(baseUrl)
|
|
9693
9720
|
);
|
|
9694
|
-
const getMediaPlaylist = (0,
|
|
9721
|
+
const getMediaPlaylist = (0, import_vinyl_util96.memoize)(
|
|
9695
9722
|
(uri) => fetchMediaPlaylist({
|
|
9696
9723
|
uri,
|
|
9697
9724
|
baseUrl,
|
|
@@ -9710,9 +9737,9 @@ function createUrlHlsManifestProvider(url, requestInit) {
|
|
|
9710
9737
|
}
|
|
9711
9738
|
async function fetchMediaPlaylist(options) {
|
|
9712
9739
|
const { uri, baseUrl, defines, requestInit, abort } = options;
|
|
9713
|
-
const variantUrl = (0,
|
|
9714
|
-
const response = await (0,
|
|
9715
|
-
const text = await response
|
|
9740
|
+
const variantUrl = (0, import_vinyl_util96.resolveUrl)(uri, baseUrl);
|
|
9741
|
+
const response = await (0, import_vinyl_util96.requestWithRetry)(variantUrl, requestInit, { abort });
|
|
9742
|
+
const text = await (0, import_vinyl_util96.readResponseBody)(response, "text");
|
|
9716
9743
|
const queryParams = parseQueryParams(response.url || variantUrl);
|
|
9717
9744
|
return (0, import_vinyl_hls_parser3.parseMediaPlaylist)(text, defines, queryParams);
|
|
9718
9745
|
}
|
|
@@ -9786,7 +9813,7 @@ function createHlsFactories(options) {
|
|
|
9786
9813
|
}
|
|
9787
9814
|
|
|
9788
9815
|
// src/track/TrackController.ts
|
|
9789
|
-
var
|
|
9816
|
+
var import_vinyl_util97 = require("@amazon/vinyl-util");
|
|
9790
9817
|
var ALL_TRACK_CONTROLLER_EVENTS = [
|
|
9791
9818
|
"trackActivated",
|
|
9792
9819
|
"trackDeactivated",
|
|
@@ -9801,14 +9828,14 @@ var defaultTrackControllerImplOptions = {
|
|
|
9801
9828
|
var trackPriority = {
|
|
9802
9829
|
value: 0
|
|
9803
9830
|
};
|
|
9804
|
-
var TrackControllerImpl = class extends
|
|
9831
|
+
var TrackControllerImpl = class extends import_vinyl_util97.EventHostImpl {
|
|
9805
9832
|
constructor(deps, initialOptions) {
|
|
9806
9833
|
super();
|
|
9807
9834
|
__publicField(this, "deps", deps);
|
|
9808
9835
|
// When tracks are preloaded, the cache capacity may expand automatically to accommodate.
|
|
9809
9836
|
__publicField(this, "_autoPreloadCapacity", 0);
|
|
9810
9837
|
// The primary content track cache. Bounded by preloadCapacity + prefetch.
|
|
9811
|
-
__publicField(this, "trackCache", /* @__PURE__ */ new
|
|
9838
|
+
__publicField(this, "trackCache", /* @__PURE__ */ new import_vinyl_util97.LruCache(0));
|
|
9812
9839
|
// A monotonically increasing id for a queue change, to allow for queue changes during events.
|
|
9813
9840
|
__publicField(this, "queueIdx", 0);
|
|
9814
9841
|
__publicField(this, "_queue", []);
|
|
@@ -9824,7 +9851,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9824
9851
|
// Ad tracks keyed by parent content URI, kept out of the content cache.
|
|
9825
9852
|
// Pegged to the parent: disposed when the parent is evicted (see onEvict).
|
|
9826
9853
|
__publicField(this, "adTracksByParent", /* @__PURE__ */ new Map());
|
|
9827
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
9854
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util97.createDisposer)());
|
|
9828
9855
|
__publicField(this, "_options", defaultTrackControllerImplOptions);
|
|
9829
9856
|
/**
|
|
9830
9857
|
* The current track has ended naturally. On the next tick advance the queue or emit queue ended.
|
|
@@ -9834,28 +9861,30 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9834
9861
|
if (this.currentTrackIsAdTrack) return;
|
|
9835
9862
|
const track = this._current;
|
|
9836
9863
|
if (!track) {
|
|
9837
|
-
(0,
|
|
9864
|
+
(0, import_vinyl_util97.logWarn)(this, "an ended event was received with no current track");
|
|
9838
9865
|
return;
|
|
9839
9866
|
}
|
|
9840
9867
|
const interrupted = this.getQueueInterrupted();
|
|
9841
9868
|
adController.enterPostroll().then((postroll) => {
|
|
9869
|
+
if (interrupted()) return;
|
|
9842
9870
|
if (postroll) {
|
|
9843
|
-
(0,
|
|
9871
|
+
(0, import_vinyl_util97.logDebug)(this, "postroll entered");
|
|
9844
9872
|
} else {
|
|
9845
|
-
(0,
|
|
9873
|
+
(0, import_vinyl_util97.logDebug)(this, "trackEnded");
|
|
9846
9874
|
this.dispatch("trackEnded", { track });
|
|
9847
9875
|
queueMicrotask(() => {
|
|
9848
9876
|
if (interrupted()) return;
|
|
9849
9877
|
if (this.hasNext()) {
|
|
9850
9878
|
this.next();
|
|
9851
9879
|
} else {
|
|
9852
|
-
(0,
|
|
9880
|
+
(0, import_vinyl_util97.logInfo)(this, "queueEnded");
|
|
9853
9881
|
this.dispatch("queueEnded", {});
|
|
9854
9882
|
}
|
|
9855
9883
|
});
|
|
9856
9884
|
}
|
|
9857
9885
|
}).catch((error) => {
|
|
9858
|
-
(
|
|
9886
|
+
if (interrupted()) return;
|
|
9887
|
+
(0, import_vinyl_util97.logError)(this, "enterPostroll failed", error);
|
|
9859
9888
|
});
|
|
9860
9889
|
});
|
|
9861
9890
|
__publicField(this, "validateLoadOptions", (loadOptions) => this.deps.trackFactory.validate(loadOptions));
|
|
@@ -9865,7 +9894,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9865
9894
|
return this.getPrefetched().find((value) => value.uri === track.uri) == null;
|
|
9866
9895
|
};
|
|
9867
9896
|
this.trackCache.onEvict = (track) => {
|
|
9868
|
-
(0,
|
|
9897
|
+
(0, import_vinyl_util97.logDebug)(this, `Disposing track: ${track.uri}`);
|
|
9869
9898
|
this.disposeAdTracksFor(track.uri);
|
|
9870
9899
|
track.dispose();
|
|
9871
9900
|
return true;
|
|
@@ -9890,7 +9919,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9890
9919
|
adController.on("adEntered", (event) => {
|
|
9891
9920
|
const adParent = this.adParent;
|
|
9892
9921
|
if (!adParent) {
|
|
9893
|
-
(0,
|
|
9922
|
+
(0, import_vinyl_util97.logDebug)(this, "ad entered, no parent track");
|
|
9894
9923
|
return;
|
|
9895
9924
|
}
|
|
9896
9925
|
const interrupted = () => this.adParent !== adParent || adController.currentAd !== event.ad;
|
|
@@ -9908,7 +9937,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9908
9937
|
config: {}
|
|
9909
9938
|
}
|
|
9910
9939
|
);
|
|
9911
|
-
playbackController.play().catch(
|
|
9940
|
+
playbackController.play().catch(import_vinyl_util97.noop);
|
|
9912
9941
|
}
|
|
9913
9942
|
}).catch((error) => {
|
|
9914
9943
|
if (!interrupted()) adController.failAd(error);
|
|
@@ -9919,46 +9948,46 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9919
9948
|
add(
|
|
9920
9949
|
adController.on("adBreakCompleted", (event) => {
|
|
9921
9950
|
var _a;
|
|
9922
|
-
(0,
|
|
9951
|
+
(0, import_vinyl_util97.logDebug)(this, "adBreakCompleted");
|
|
9923
9952
|
const adParent = this.adParent;
|
|
9924
9953
|
if (!adParent) {
|
|
9925
|
-
(0,
|
|
9954
|
+
(0, import_vinyl_util97.logDebug)(this, "ad break completed, no parent track");
|
|
9926
9955
|
return;
|
|
9927
9956
|
}
|
|
9928
9957
|
if (adController.currentAdBreak) {
|
|
9929
|
-
(0,
|
|
9930
|
-
return;
|
|
9931
|
-
}
|
|
9932
|
-
if (adParent.active) {
|
|
9933
|
-
(0, import_vinyl_util101.logDebug)(this, "no ads began");
|
|
9958
|
+
(0, import_vinyl_util97.logDebug)(this, "more adbreaks");
|
|
9934
9959
|
return;
|
|
9935
9960
|
}
|
|
9936
9961
|
const adParentLoad = this._current;
|
|
9937
9962
|
const placement = event.adBreak.placement;
|
|
9938
9963
|
const isPreroll = placement === "preroll";
|
|
9939
9964
|
const isPostroll = placement === "postroll";
|
|
9965
|
+
const noAdBegan = adParent.active;
|
|
9966
|
+
const resumeContent = (startTime) => this.setCurrentTrack(adParent, {
|
|
9967
|
+
config: __spreadProps(__spreadValues({}, adParentLoad.config), { startTime }),
|
|
9968
|
+
isAd: false,
|
|
9969
|
+
checkPreroll: false
|
|
9970
|
+
});
|
|
9940
9971
|
if (isPostroll) {
|
|
9941
|
-
(0,
|
|
9972
|
+
(0, import_vinyl_util97.logDebug)(this, "trackEnded after postroll");
|
|
9942
9973
|
this.dispatch("trackEnded", { track: adParentLoad });
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
} else {
|
|
9947
|
-
const startTime = isPreroll ? (_a = adParentLoad.config) == null ? void 0 : _a.startTime : event.resumePosition;
|
|
9948
|
-
this.setCurrentTrack(adParent, {
|
|
9949
|
-
config: __spreadProps(__spreadValues({}, adParentLoad.config), {
|
|
9950
|
-
startTime
|
|
9951
|
-
}),
|
|
9952
|
-
isAd: false,
|
|
9953
|
-
checkPreroll: false
|
|
9954
|
-
});
|
|
9955
|
-
if (isPostroll) {
|
|
9956
|
-
(0, import_vinyl_util101.logInfo)(this, "queueEnded after postroll ad(s)");
|
|
9957
|
-
this.dispatch("queueEnded", {});
|
|
9958
|
-
} else {
|
|
9959
|
-
playbackController.play().catch(import_vinyl_util101.noop);
|
|
9974
|
+
if (this.hasNext()) {
|
|
9975
|
+
this.next();
|
|
9976
|
+
return;
|
|
9960
9977
|
}
|
|
9978
|
+
if (!noAdBegan) resumeContent(event.resumePosition);
|
|
9979
|
+
(0, import_vinyl_util97.logInfo)(this, "queueEnded after postroll");
|
|
9980
|
+
this.dispatch("queueEnded", {});
|
|
9981
|
+
return;
|
|
9982
|
+
}
|
|
9983
|
+
if (noAdBegan) {
|
|
9984
|
+
(0, import_vinyl_util97.logDebug)(this, "no ads began");
|
|
9985
|
+
return;
|
|
9961
9986
|
}
|
|
9987
|
+
resumeContent(
|
|
9988
|
+
isPreroll ? (_a = adParentLoad.config) == null ? void 0 : _a.startTime : event.resumePosition
|
|
9989
|
+
);
|
|
9990
|
+
playbackController.play().catch(import_vinyl_util97.noop);
|
|
9962
9991
|
})
|
|
9963
9992
|
);
|
|
9964
9993
|
}
|
|
@@ -9974,7 +10003,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9974
10003
|
* @param options
|
|
9975
10004
|
*/
|
|
9976
10005
|
configure(options) {
|
|
9977
|
-
(0,
|
|
10006
|
+
(0, import_vinyl_util97.logDebug)(this, "configure", options);
|
|
9978
10007
|
this._options = __spreadValues(__spreadValues({}, this._options), options);
|
|
9979
10008
|
this.checkCacheCapacity();
|
|
9980
10009
|
}
|
|
@@ -9984,7 +10013,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
9984
10013
|
checkCacheCapacity() {
|
|
9985
10014
|
const capacity = this.preloadCapacity + this._options.trackPrefetchCount + 1;
|
|
9986
10015
|
if (capacity !== this.trackCache.capacity) {
|
|
9987
|
-
(0,
|
|
10016
|
+
(0, import_vinyl_util97.logDebug)(this, "track cache capacity changed:", capacity);
|
|
9988
10017
|
this.trackCache.capacity = capacity;
|
|
9989
10018
|
}
|
|
9990
10019
|
}
|
|
@@ -10022,14 +10051,14 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10022
10051
|
);
|
|
10023
10052
|
}
|
|
10024
10053
|
preload(...loadOptionsList) {
|
|
10025
|
-
(0,
|
|
10054
|
+
(0, import_vinyl_util97.logDebug)(this, `preload ${loadOptionsList.length} items`);
|
|
10026
10055
|
loadOptionsList.forEach(this.validateLoadOptions);
|
|
10027
10056
|
this._preload(loadOptionsList);
|
|
10028
10057
|
}
|
|
10029
10058
|
_preload(loadOptionsList) {
|
|
10030
10059
|
var _a;
|
|
10031
10060
|
const prefetched = this.getPrefetched();
|
|
10032
|
-
const requiredPreloadCapacity = (0,
|
|
10061
|
+
const requiredPreloadCapacity = (0, import_vinyl_util97.countElements)(
|
|
10033
10062
|
loadOptionsList,
|
|
10034
10063
|
(loadOptions) => {
|
|
10035
10064
|
return prefetched.find((element2) => {
|
|
@@ -10046,7 +10075,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10046
10075
|
for (const loadOptions of loadOptionsList) {
|
|
10047
10076
|
const track = this.getOrCreateTrack(loadOptions);
|
|
10048
10077
|
const prefetchPriority = priority--;
|
|
10049
|
-
(0,
|
|
10078
|
+
(0, import_vinyl_util97.logVerbose)(
|
|
10050
10079
|
this,
|
|
10051
10080
|
`preloading track ${track.uri} with priority ${prefetchPriority}`
|
|
10052
10081
|
);
|
|
@@ -10063,7 +10092,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10063
10092
|
parentTrack.getAds().then(async (trackAds) => {
|
|
10064
10093
|
for (const [index, adBreak] of trackAds.adBreaks.entries()) {
|
|
10065
10094
|
if (adBreak.placement !== "preroll") continue;
|
|
10066
|
-
const ads = await (0,
|
|
10095
|
+
const ads = await (0, import_vinyl_util97.resolveValueProvider)(adBreak.ads);
|
|
10067
10096
|
for (const ad of ads) {
|
|
10068
10097
|
await this.preloadAd({
|
|
10069
10098
|
parentTrack,
|
|
@@ -10076,7 +10105,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10076
10105
|
}
|
|
10077
10106
|
}
|
|
10078
10107
|
}).catch((error) => {
|
|
10079
|
-
(0,
|
|
10108
|
+
(0, import_vinyl_util97.logVerbose)(
|
|
10080
10109
|
this,
|
|
10081
10110
|
`preroll ad preload failed for ${parentTrack.uri}`,
|
|
10082
10111
|
error
|
|
@@ -10092,12 +10121,12 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10092
10121
|
preloadBreakAds(parentTrack, adBreak) {
|
|
10093
10122
|
trackPriority.value += 1;
|
|
10094
10123
|
const prefetchPriority = trackPriority.value;
|
|
10095
|
-
(0,
|
|
10124
|
+
(0, import_vinyl_util97.resolveValueProvider)(adBreak.ads).then(async (ads) => {
|
|
10096
10125
|
for (const ad of ads) {
|
|
10097
10126
|
await this.preloadAd({ parentTrack, prefetchPriority, ad });
|
|
10098
10127
|
}
|
|
10099
10128
|
}).catch((error) => {
|
|
10100
|
-
(0,
|
|
10129
|
+
(0, import_vinyl_util97.logVerbose)(
|
|
10101
10130
|
this,
|
|
10102
10131
|
`ad preload failed for break ${adBreak.id}`,
|
|
10103
10132
|
error
|
|
@@ -10113,8 +10142,8 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10113
10142
|
var _a;
|
|
10114
10143
|
const { adTrackLoadOptionsProvider } = this.deps;
|
|
10115
10144
|
const loadOptions = await adTrackLoadOptionsProvider(ad);
|
|
10116
|
-
if (parentTrack.disposed) return;
|
|
10117
|
-
(0,
|
|
10145
|
+
if (parentTrack.disposed || this.disposed) return;
|
|
10146
|
+
(0, import_vinyl_util97.logVerbose)(
|
|
10118
10147
|
this,
|
|
10119
10148
|
`preloading ad id=${ad.id} uri=${ad.uri} priority=${prefetchPriority}`
|
|
10120
10149
|
);
|
|
@@ -10127,7 +10156,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10127
10156
|
);
|
|
10128
10157
|
}
|
|
10129
10158
|
load(...loadOptionsList) {
|
|
10130
|
-
(0,
|
|
10159
|
+
(0, import_vinyl_util97.logDebug)(this, `load ${loadOptionsList.length} items`);
|
|
10131
10160
|
loadOptionsList.forEach(this.validateLoadOptions);
|
|
10132
10161
|
this.setQueue(loadOptionsList[0], loadOptionsList.slice(1));
|
|
10133
10162
|
}
|
|
@@ -10135,7 +10164,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10135
10164
|
this.load();
|
|
10136
10165
|
}
|
|
10137
10166
|
enqueue(...loadOptionsList) {
|
|
10138
|
-
(0,
|
|
10167
|
+
(0, import_vinyl_util97.logDebug)(this, `enqueue ${loadOptionsList.length} items`);
|
|
10139
10168
|
loadOptionsList.forEach(this.validateLoadOptions);
|
|
10140
10169
|
this.setQueue(this._current, this._queue.concat(loadOptionsList));
|
|
10141
10170
|
if (this._currentTrack == null && this.hasNext()) this.next();
|
|
@@ -10146,12 +10175,12 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10146
10175
|
next() {
|
|
10147
10176
|
const playbackController = this.deps.playbackController;
|
|
10148
10177
|
const shouldPlay = playbackController.ended || !playbackController.paused;
|
|
10149
|
-
const next = (0,
|
|
10150
|
-
(0,
|
|
10178
|
+
const next = (0, import_vinyl_util97.first)(this._queue);
|
|
10179
|
+
(0, import_vinyl_util97.logDebug)(this, "next, nextTrack:", next);
|
|
10151
10180
|
this.setQueue(next, this._queue.slice(1), { shouldPlay });
|
|
10152
10181
|
}
|
|
10153
10182
|
clearTrackCache() {
|
|
10154
|
-
(0,
|
|
10183
|
+
(0, import_vinyl_util97.logDebug)(this, "clearTrackCache");
|
|
10155
10184
|
this.trackCache.forEach((track) => {
|
|
10156
10185
|
this.disposeAdTracksFor(track.uri);
|
|
10157
10186
|
track.dispose();
|
|
@@ -10177,7 +10206,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10177
10206
|
* @private
|
|
10178
10207
|
*/
|
|
10179
10208
|
getOrCreateTrack(loadOptions) {
|
|
10180
|
-
return (0,
|
|
10209
|
+
return (0, import_vinyl_util97.getOrSet)(
|
|
10181
10210
|
this.trackCache,
|
|
10182
10211
|
loadOptions.uri,
|
|
10183
10212
|
() => this.deps.trackFactory.createTrack(loadOptions)
|
|
@@ -10193,12 +10222,12 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10193
10222
|
* @private
|
|
10194
10223
|
*/
|
|
10195
10224
|
getOrCreateAdTrack(parentUri, loadOptions) {
|
|
10196
|
-
const parentTracks = (0,
|
|
10225
|
+
const parentTracks = (0, import_vinyl_util97.getOrSet)(
|
|
10197
10226
|
this.adTracksByParent,
|
|
10198
10227
|
parentUri,
|
|
10199
10228
|
() => /* @__PURE__ */ new Map()
|
|
10200
10229
|
);
|
|
10201
|
-
return (0,
|
|
10230
|
+
return (0, import_vinyl_util97.getOrSet)(
|
|
10202
10231
|
parentTracks,
|
|
10203
10232
|
loadOptions.uri,
|
|
10204
10233
|
() => this.deps.trackFactory.createTrack(loadOptions)
|
|
@@ -10229,13 +10258,13 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10229
10258
|
}
|
|
10230
10259
|
);
|
|
10231
10260
|
if (options == null ? void 0 : options.shouldPlay) {
|
|
10232
|
-
playbackController.play().catch(
|
|
10261
|
+
playbackController.play().catch(import_vinyl_util97.noop);
|
|
10233
10262
|
}
|
|
10234
10263
|
} else {
|
|
10235
10264
|
this._queue = queue;
|
|
10236
10265
|
}
|
|
10237
10266
|
this._preload(this.getPrefetched());
|
|
10238
|
-
(0,
|
|
10267
|
+
(0, import_vinyl_util97.logDebug)(
|
|
10239
10268
|
this,
|
|
10240
10269
|
`track change, previous: ${previous == null ? void 0 : previous.uri} current: ${current == null ? void 0 : current.uri}`
|
|
10241
10270
|
);
|
|
@@ -10246,7 +10275,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10246
10275
|
});
|
|
10247
10276
|
}
|
|
10248
10277
|
if (interrupted()) {
|
|
10249
|
-
throw new
|
|
10278
|
+
throw new import_vinyl_util97.IllegalStateError(
|
|
10250
10279
|
`cannot change the queue on a 'queueChange' or 'trackDeactivated' event`
|
|
10251
10280
|
);
|
|
10252
10281
|
}
|
|
@@ -10268,7 +10297,7 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10268
10297
|
const previousTrack = this._currentTrack;
|
|
10269
10298
|
const previousWasActive = (_a = previousTrack == null ? void 0 : previousTrack.active) != null ? _a : false;
|
|
10270
10299
|
this._currentTrack = newTrack;
|
|
10271
|
-
const interrupted = () => this._currentTrack !== newTrack;
|
|
10300
|
+
const interrupted = () => this.disposed || this._currentTrack !== newTrack;
|
|
10272
10301
|
previousTrack == null ? void 0 : previousTrack.deactivate();
|
|
10273
10302
|
if (previousTrack && previousWasActive) {
|
|
10274
10303
|
this.dispatch("trackDeactivated", { track: previousTrack });
|
|
@@ -10296,7 +10325,8 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10296
10325
|
if (preroll) return;
|
|
10297
10326
|
activate();
|
|
10298
10327
|
}).catch((error) => {
|
|
10299
|
-
(
|
|
10328
|
+
if (interrupted()) return;
|
|
10329
|
+
(0, import_vinyl_util97.logError)(this, "enterPreroll failed", error);
|
|
10300
10330
|
activate();
|
|
10301
10331
|
});
|
|
10302
10332
|
}
|
|
@@ -10331,25 +10361,21 @@ var TrackControllerImpl = class extends import_vinyl_util101.EventHostImpl {
|
|
|
10331
10361
|
return this.disposer.disposed;
|
|
10332
10362
|
}
|
|
10333
10363
|
dispose() {
|
|
10334
|
-
(0,
|
|
10364
|
+
(0, import_vinyl_util97.logDebug)(this, "dispose");
|
|
10335
10365
|
super.dispose();
|
|
10336
10366
|
this.clearTrackCache();
|
|
10337
10367
|
this.disposer.dispose();
|
|
10338
10368
|
}
|
|
10339
10369
|
};
|
|
10340
10370
|
|
|
10341
|
-
// src/
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
var defaultPatchOptions = /* @__PURE__ */ (0, import_vinyl_util102.lazy)(() => {
|
|
10347
|
-
return {
|
|
10348
|
-
media: defaultMediaElementPatchOptions.value
|
|
10349
|
-
};
|
|
10350
|
-
});
|
|
10371
|
+
// src/util/media/mimeType.ts
|
|
10372
|
+
function mimeSubtype(mimeType) {
|
|
10373
|
+
var _a;
|
|
10374
|
+
return (_a = mimeType.split(";", 1)[0].trim().toLowerCase().split("/")[1]) != null ? _a : "";
|
|
10375
|
+
}
|
|
10351
10376
|
|
|
10352
10377
|
// src/vinyl/createVinylFactories.ts
|
|
10378
|
+
var import_vinyl_util98 = require("@amazon/vinyl-util");
|
|
10353
10379
|
var import_vinyl_di7 = require("@amazon/vinyl-di");
|
|
10354
10380
|
|
|
10355
10381
|
// src/vinyl/VinylOptions.ts
|
|
@@ -10393,27 +10419,19 @@ function playerConfigFactory(defaults, validator) {
|
|
|
10393
10419
|
|
|
10394
10420
|
// src/vinyl/createVinylFactories.ts
|
|
10395
10421
|
function createVinylFactories(options) {
|
|
10396
|
-
var _a;
|
|
10397
|
-
const patches = (0, import_vinyl_util103.mergeDeep)([
|
|
10398
|
-
defaultPatchOptions.value,
|
|
10399
|
-
(_a = options.patches) != null ? _a : {}
|
|
10400
|
-
]);
|
|
10401
10422
|
return (0, import_vinyl_di7.validateFactories)({
|
|
10402
10423
|
options: playerConfigFactory(
|
|
10403
10424
|
defaultVinylOptions,
|
|
10404
10425
|
vinylOptionsValidator
|
|
10405
10426
|
),
|
|
10406
|
-
|
|
10407
|
-
return patchMediaElement(options.media, patches.media);
|
|
10408
|
-
},
|
|
10409
|
-
media: (deps) => deps.patchedMedia.patched,
|
|
10427
|
+
media: () => options.media,
|
|
10410
10428
|
// One provider per media element (the player container creates each
|
|
10411
10429
|
// dependency once), so text tracks are reused rather than accumulated.
|
|
10412
10430
|
textTrackProvider: (deps) => createMediaTextTrackProvider({ media: deps.media }),
|
|
10413
10431
|
// App-provided cue renderer (or null for native rendering).
|
|
10414
10432
|
textTrackRenderer: () => {
|
|
10415
|
-
var
|
|
10416
|
-
return (
|
|
10433
|
+
var _a;
|
|
10434
|
+
return (_a = options.textTrackRenderer) != null ? _a : null;
|
|
10417
10435
|
},
|
|
10418
10436
|
playbackController: (deps) => new PlaybackControllerImpl(deps, options.playbackController),
|
|
10419
10437
|
playbackSource: (deps) => new PlaybackSourceImpl(deps),
|
|
@@ -10421,7 +10439,7 @@ function createVinylFactories(options) {
|
|
|
10421
10439
|
options: deps.options.pick("loudnessNormalization")
|
|
10422
10440
|
}),
|
|
10423
10441
|
capabilities: (deps) => new CapabilitiesImpl(deps),
|
|
10424
|
-
requestInterceptor: () =>
|
|
10442
|
+
requestInterceptor: () => import_vinyl_util98.noop,
|
|
10425
10443
|
trackFactory: (deps) => createTrackFactory(createVinylTrackFactories(deps)),
|
|
10426
10444
|
adTrackLoadOptionsProvider: () => defaultAdLoadOptionsResolver,
|
|
10427
10445
|
trackController: (deps) => new TrackControllerImpl(deps, options.trackController),
|
|
@@ -10436,9 +10454,9 @@ function createVinylFactories(options) {
|
|
|
10436
10454
|
}
|
|
10437
10455
|
|
|
10438
10456
|
// src/vinyl/VinylPlayer.ts
|
|
10439
|
-
var
|
|
10457
|
+
var import_vinyl_util99 = require("@amazon/vinyl-util");
|
|
10440
10458
|
var import_vinyl_di8 = require("@amazon/vinyl-di");
|
|
10441
|
-
var VinylPlayer = class extends
|
|
10459
|
+
var VinylPlayer = class extends import_vinyl_util99.EventHostImpl {
|
|
10442
10460
|
/**
|
|
10443
10461
|
* Constructs a new VinylPlayer with the given dependency factories.
|
|
10444
10462
|
* This constructor is protected, use {@link createVinylPlayer} to construct a new player.
|
|
@@ -10455,7 +10473,7 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10455
10473
|
*/
|
|
10456
10474
|
__publicField(this, "client");
|
|
10457
10475
|
__publicField(this, "_error", null);
|
|
10458
|
-
__publicField(this, "disposer", /* @__PURE__ */ (0,
|
|
10476
|
+
__publicField(this, "disposer", /* @__PURE__ */ (0, import_vinyl_util99.createDisposer)());
|
|
10459
10477
|
const add = this.disposer.add;
|
|
10460
10478
|
this.deps = add((0, import_vinyl_di8.createContainer)(factories)).dependencies;
|
|
10461
10479
|
this.client = {
|
|
@@ -10484,20 +10502,20 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10484
10502
|
redispatchSubControllerEvents() {
|
|
10485
10503
|
const add = this.disposer.add;
|
|
10486
10504
|
add(
|
|
10487
|
-
(0,
|
|
10505
|
+
(0, import_vinyl_util99.redispatchEvents)(
|
|
10488
10506
|
this,
|
|
10489
10507
|
this.playbackController,
|
|
10490
10508
|
ALL_PLAYBACK_STATE_EVENTS.filter(notResetEvent)
|
|
10491
10509
|
)
|
|
10492
10510
|
);
|
|
10493
10511
|
add(
|
|
10494
|
-
(0,
|
|
10512
|
+
(0, import_vinyl_util99.redispatchEvents)(
|
|
10495
10513
|
this,
|
|
10496
10514
|
this.trackController,
|
|
10497
10515
|
ALL_TRACK_CONTROLLER_EVENTS
|
|
10498
10516
|
)
|
|
10499
10517
|
);
|
|
10500
|
-
add((0,
|
|
10518
|
+
add((0, import_vinyl_util99.redispatchEvents)(this, this.drmController, ["error"]));
|
|
10501
10519
|
add(
|
|
10502
10520
|
this.drmController.on("loadSpanMeasured", (measurement) => {
|
|
10503
10521
|
const trackUri = measurement.trackUri;
|
|
@@ -10506,14 +10524,14 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10506
10524
|
}
|
|
10507
10525
|
})
|
|
10508
10526
|
);
|
|
10509
|
-
add((0,
|
|
10527
|
+
add((0, import_vinyl_util99.redispatchEvents)(this, this.deps.adController, ALL_AD_EVENTS));
|
|
10510
10528
|
this.on("error", (event) => {
|
|
10511
10529
|
this._error = event.error;
|
|
10512
10530
|
});
|
|
10513
10531
|
add(
|
|
10514
10532
|
this.on("codecUnsupported", (event) => {
|
|
10515
10533
|
if (this.deps.adController.currentAdBreak) return;
|
|
10516
|
-
(0,
|
|
10534
|
+
(0, import_vinyl_util99.logWarn)(
|
|
10517
10535
|
this,
|
|
10518
10536
|
"codec unsupported, reloading track:",
|
|
10519
10537
|
event.mimeType
|
|
@@ -10546,7 +10564,7 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10546
10564
|
metricSub == null ? void 0 : metricSub();
|
|
10547
10565
|
metricSub = null;
|
|
10548
10566
|
if (current) {
|
|
10549
|
-
sub = (0,
|
|
10567
|
+
sub = (0, import_vinyl_util99.redispatchEvents)(
|
|
10550
10568
|
this,
|
|
10551
10569
|
current,
|
|
10552
10570
|
ALL_STREAMING_EVENTS.filter(notResetEvent).filter(
|
|
@@ -10566,7 +10584,7 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10566
10584
|
}
|
|
10567
10585
|
);
|
|
10568
10586
|
if (current.textTrackController) {
|
|
10569
|
-
textSub = (0,
|
|
10587
|
+
textSub = (0, import_vinyl_util99.redispatchEvents)(
|
|
10570
10588
|
this,
|
|
10571
10589
|
current.textTrackController,
|
|
10572
10590
|
ALL_TEXT_TRACK_EVENTS
|
|
@@ -10651,9 +10669,9 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10651
10669
|
* @param options
|
|
10652
10670
|
*/
|
|
10653
10671
|
configure(options) {
|
|
10654
|
-
(0,
|
|
10672
|
+
(0, import_vinyl_util99.logDebug)(this, "configure", options);
|
|
10655
10673
|
const newValue = __spreadValues(__spreadValues({}, this.options), options);
|
|
10656
|
-
if (!(0,
|
|
10674
|
+
if (!(0, import_vinyl_util99.equalDeep)(newValue, this.options)) {
|
|
10657
10675
|
this.deps.options.value = newValue;
|
|
10658
10676
|
}
|
|
10659
10677
|
}
|
|
@@ -10783,10 +10801,10 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10783
10801
|
}
|
|
10784
10802
|
reset(hard = false) {
|
|
10785
10803
|
if (!this._error) {
|
|
10786
|
-
(0,
|
|
10804
|
+
(0, import_vinyl_util99.logDebug)(this, "reset no-op");
|
|
10787
10805
|
return;
|
|
10788
10806
|
}
|
|
10789
|
-
(0,
|
|
10807
|
+
(0, import_vinyl_util99.logDebug)(this, "reset");
|
|
10790
10808
|
this._error = null;
|
|
10791
10809
|
this.drmController.reset();
|
|
10792
10810
|
this.playbackController.reset();
|
|
@@ -10850,7 +10868,7 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
10850
10868
|
*/
|
|
10851
10869
|
get fetchedRanges() {
|
|
10852
10870
|
var _a, _b;
|
|
10853
|
-
return (_b = (_a = this.activeTrack) == null ? void 0 : _a.fetchedRanges) != null ? _b :
|
|
10871
|
+
return (_b = (_a = this.activeTrack) == null ? void 0 : _a.fetchedRanges) != null ? _b : import_vinyl_util99.emptyRanges;
|
|
10854
10872
|
}
|
|
10855
10873
|
/**
|
|
10856
10874
|
* Returns the time of the prefetch end.
|
|
@@ -11031,7 +11049,7 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
11031
11049
|
* Disposes this player and sub-systems.
|
|
11032
11050
|
*/
|
|
11033
11051
|
dispose() {
|
|
11034
|
-
(0,
|
|
11052
|
+
(0, import_vinyl_util99.logDebug)(this, "dispose");
|
|
11035
11053
|
super.dispose();
|
|
11036
11054
|
this.disposer.dispose();
|
|
11037
11055
|
playerRegistryRef.value.removePlayer(this);
|
|
@@ -11039,7 +11057,7 @@ var VinylPlayer = class extends import_vinyl_util104.EventHostImpl {
|
|
|
11039
11057
|
};
|
|
11040
11058
|
function createVinylPlayer(options, factoryOverrides) {
|
|
11041
11059
|
const player = new VinylPlayer(__spreadValues(__spreadValues({}, createVinylFactories(options)), factoryOverrides));
|
|
11042
|
-
(0,
|
|
11060
|
+
(0, import_vinyl_util99.logInfo)(player, `VinylPlayer initialized`);
|
|
11043
11061
|
return player;
|
|
11044
11062
|
}
|
|
11045
11063
|
function notResetEvent(type) {
|