@amazon/vinyl 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +24 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +33 -13
- package/dist/index.js.map +3 -3
- package/dist/test/integ.es5.js +62 -62
- package/dist/test/integ.js +119 -6
- package/dist/test/integ.js.map +2 -2
- package/dist/types/current/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/current/ad/AdBreakInfo.d.ts.map +1 -0
- package/dist/types/current/ad/AdBreakInfo.js +5 -0
- package/dist/types/current/ad/AdController.d.ts +229 -0
- package/dist/types/current/ad/AdController.d.ts.map +1 -0
- package/dist/types/current/ad/AdController.js +19 -0
- package/dist/types/current/ad/AdControllerImpl.d.ts +162 -0
- package/dist/types/current/ad/AdControllerImpl.d.ts.map +1 -0
- package/dist/types/current/ad/AdControllerImpl.js +741 -0
- package/dist/types/current/ad/AdError.d.ts +6 -0
- package/dist/types/current/ad/AdError.d.ts.map +1 -0
- package/dist/types/current/ad/AdError.js +14 -0
- package/dist/types/current/ad/AdsProvider.d.ts +28 -0
- package/dist/types/current/ad/AdsProvider.d.ts.map +1 -0
- package/dist/types/current/ad/AdsProvider.js +5 -0
- package/dist/types/current/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/current/ad/defaultAdLoadOptionsResolver.d.ts.map +1 -0
- package/dist/types/current/ad/defaultAdLoadOptionsResolver.js +26 -0
- package/dist/types/current/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/current/ad/discoverHlsInterstitials.d.ts.map +1 -0
- package/dist/types/current/ad/discoverHlsInterstitials.js +248 -0
- package/dist/types/current/drm/DrmControllerImpl.d.ts +6 -0
- package/dist/types/current/drm/DrmControllerImpl.d.ts.map +1 -1
- package/dist/types/current/drm/DrmControllerImpl.js +23 -1
- package/dist/types/current/playback/PlaybackControllerImpl.d.ts +1 -1
- 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 +99 -0
- package/dist/types/current/streaming/AudioOptions.d.ts +66 -0
- package/dist/types/current/streaming/AudioOptions.d.ts.map +1 -0
- package/dist/types/current/streaming/AudioOptions.js +19 -0
- package/dist/types/current/streaming/LoadMetric.d.ts +72 -0
- package/dist/types/current/streaming/LoadMetric.d.ts.map +1 -0
- package/dist/types/current/streaming/LoadMetric.js +5 -0
- package/dist/types/current/streaming/ManifestControllerImpl.d.ts +43 -0
- package/dist/types/current/streaming/ManifestControllerImpl.d.ts.map +1 -0
- package/dist/types/current/streaming/ManifestControllerImpl.js +104 -0
- package/dist/types/current/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/current/streaming/buffering/codecDenylist.d.ts.map +1 -0
- package/dist/types/current/streaming/buffering/codecDenylist.js +62 -0
- package/dist/types/current/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/current/streaming/createAllowedContentTypesValue.d.ts.map +1 -0
- package/dist/types/current/streaming/createAllowedContentTypesValue.js +43 -0
- package/dist/types/current/streaming/createTimelineContentTypesValue.d.ts +21 -0
- package/dist/types/current/streaming/createTimelineContentTypesValue.d.ts.map +1 -0
- package/dist/types/current/streaming/createTimelineContentTypesValue.js +25 -0
- package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.d.ts.map +1 -0
- package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.js +75 -0
- package/dist/types/current/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/current/text/HtmlTextTrackRenderer.d.ts.map +1 -0
- package/dist/types/current/text/HtmlTextTrackRenderer.js +231 -0
- package/dist/types/current/text/SidecarTextTrackController.d.ts +103 -0
- package/dist/types/current/text/SidecarTextTrackController.d.ts.map +1 -0
- package/dist/types/current/text/SidecarTextTrackController.js +250 -0
- package/dist/types/current/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/current/text/SidecarTextTrackLoader.d.ts.map +1 -0
- package/dist/types/current/text/SidecarTextTrackLoader.js +150 -0
- package/dist/types/current/text/TextTrack.d.ts +179 -0
- package/dist/types/current/text/TextTrack.d.ts.map +1 -0
- package/dist/types/current/text/TextTrack.js +29 -0
- package/dist/types/current/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/current/text/TextTrackRenderer.d.ts.map +1 -0
- package/dist/types/current/text/TextTrackRenderer.js +5 -0
- package/dist/types/current/text/VttCueStyle.d.ts +41 -0
- package/dist/types/current/text/VttCueStyle.d.ts.map +1 -0
- package/dist/types/current/text/VttCueStyle.js +45 -0
- package/dist/types/current/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/current/text/discoverDashTextTracks.d.ts.map +1 -0
- package/dist/types/current/text/discoverDashTextTracks.js +110 -0
- package/dist/types/current/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/current/text/discoverHlsTextTracks.d.ts.map +1 -0
- package/dist/types/current/text/discoverHlsTextTracks.js +49 -0
- package/dist/types/current/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/current/text/mediaTextTrackProvider.d.ts.map +1 -0
- package/dist/types/current/text/mediaTextTrackProvider.js +42 -0
- package/dist/types/current/text/parseWebVtt.d.ts +60 -0
- package/dist/types/current/text/parseWebVtt.d.ts.map +1 -0
- package/dist/types/current/text/parseWebVtt.js +249 -0
- package/dist/types/current/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/current/text/pickPreferredTextTrack.d.ts.map +1 -0
- package/dist/types/current/text/pickPreferredTextTrack.js +71 -0
- package/dist/types/current/track/SeekRange.d.ts +9 -0
- package/dist/types/current/track/SeekRange.d.ts.map +1 -0
- package/dist/types/current/track/SeekRange.js +5 -0
- package/dist/types/current/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/current/track/hls/HlsManifestData.d.ts.map +1 -0
- package/dist/types/current/track/hls/HlsManifestData.js +5 -0
- package/dist/types/current/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/current/track/hls/createHlsManifestProvider.d.ts.map +1 -0
- package/dist/types/current/track/hls/createHlsManifestProvider.js +9 -0
- package/dist/types/current/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/current/track/inferLoadOptionsFromUri.d.ts.map +1 -0
- package/dist/types/current/track/inferLoadOptionsFromUri.js +55 -0
- package/dist/types/current/track/mse/MseTrack.d.ts +0 -1
- package/dist/types/current/track/mse/MseTrack.d.ts.map +1 -1
- package/dist/types/current/track/mse/MseTrack.js +4 -5
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/current/util/media/codecOverrides.d.ts.map +1 -0
- package/dist/types/current/util/media/codecOverrides.js +37 -0
- package/dist/types/current/util/media/codecSupport.d.ts +6 -0
- package/dist/types/current/util/media/codecSupport.d.ts.map +1 -0
- package/dist/types/current/util/media/codecSupport.js +17 -0
- 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/ts3.7/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/ts3.7/ad/AdController.d.ts +243 -0
- package/dist/types/ts3.7/ad/AdControllerImpl.d.ts +162 -0
- package/dist/types/ts3.7/ad/AdError.d.ts +6 -0
- package/dist/types/ts3.7/ad/AdsProvider.d.ts +28 -0
- package/dist/types/ts3.7/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/ts3.7/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/ts3.7/drm/DrmControllerImpl.d.ts +6 -0
- package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +1 -1
- 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 +66 -0
- package/dist/types/ts3.7/streaming/LoadMetric.d.ts +72 -0
- package/dist/types/ts3.7/streaming/ManifestControllerImpl.d.ts +40 -0
- package/dist/types/ts3.7/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/ts3.7/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/ts3.7/streaming/createTimelineContentTypesValue.d.ts +21 -0
- package/dist/types/ts3.7/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/ts3.7/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/ts3.7/text/SidecarTextTrackController.d.ts +103 -0
- package/dist/types/ts3.7/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/ts3.7/text/TextTrack.d.ts +183 -0
- package/dist/types/ts3.7/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/ts3.7/text/VttCueStyle.d.ts +41 -0
- package/dist/types/ts3.7/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/ts3.7/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/ts3.7/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/ts3.7/text/parseWebVtt.d.ts +60 -0
- package/dist/types/ts3.7/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/ts3.7/track/SeekRange.d.ts +9 -0
- package/dist/types/ts3.7/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/ts3.7/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/ts3.7/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/ts3.7/track/mse/MseTrack.d.ts +0 -1
- package/dist/types/ts3.7/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/ts3.7/util/media/codecSupport.d.ts +6 -0
- package/dist/types/ts3.7/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.1/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/ts4.1/ad/AdController.d.ts +243 -0
- package/dist/types/ts4.1/ad/AdControllerImpl.d.ts +162 -0
- package/dist/types/ts4.1/ad/AdError.d.ts +6 -0
- package/dist/types/ts4.1/ad/AdsProvider.d.ts +28 -0
- package/dist/types/ts4.1/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/ts4.1/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/ts4.1/drm/DrmControllerImpl.d.ts +6 -0
- package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +1 -1
- 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 +66 -0
- package/dist/types/ts4.1/streaming/LoadMetric.d.ts +72 -0
- package/dist/types/ts4.1/streaming/ManifestControllerImpl.d.ts +40 -0
- package/dist/types/ts4.1/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/ts4.1/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/ts4.1/streaming/createTimelineContentTypesValue.d.ts +21 -0
- package/dist/types/ts4.1/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/ts4.1/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/ts4.1/text/SidecarTextTrackController.d.ts +104 -0
- package/dist/types/ts4.1/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/ts4.1/text/TextTrack.d.ts +183 -0
- package/dist/types/ts4.1/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/ts4.1/text/VttCueStyle.d.ts +41 -0
- package/dist/types/ts4.1/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/ts4.1/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/ts4.1/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/ts4.1/text/parseWebVtt.d.ts +60 -0
- package/dist/types/ts4.1/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/ts4.1/track/SeekRange.d.ts +9 -0
- package/dist/types/ts4.1/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/ts4.1/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/ts4.1/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/ts4.1/track/mse/MseTrack.d.ts +0 -1
- package/dist/types/ts4.1/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/ts4.1/util/media/codecSupport.d.ts +6 -0
- package/dist/types/ts4.1/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.7/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/ts4.7/ad/AdController.d.ts +243 -0
- package/dist/types/ts4.7/ad/AdControllerImpl.d.ts +162 -0
- package/dist/types/ts4.7/ad/AdError.d.ts +6 -0
- package/dist/types/ts4.7/ad/AdsProvider.d.ts +28 -0
- package/dist/types/ts4.7/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/ts4.7/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/ts4.7/drm/DrmControllerImpl.d.ts +6 -0
- package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +1 -1
- 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 +66 -0
- package/dist/types/ts4.7/streaming/LoadMetric.d.ts +72 -0
- package/dist/types/ts4.7/streaming/ManifestControllerImpl.d.ts +43 -0
- package/dist/types/ts4.7/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/ts4.7/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/ts4.7/streaming/createTimelineContentTypesValue.d.ts +21 -0
- package/dist/types/ts4.7/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/ts4.7/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/ts4.7/text/SidecarTextTrackController.d.ts +103 -0
- package/dist/types/ts4.7/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/ts4.7/text/TextTrack.d.ts +183 -0
- package/dist/types/ts4.7/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/ts4.7/text/VttCueStyle.d.ts +41 -0
- package/dist/types/ts4.7/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/ts4.7/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/ts4.7/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/ts4.7/text/parseWebVtt.d.ts +60 -0
- package/dist/types/ts4.7/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/ts4.7/track/SeekRange.d.ts +9 -0
- package/dist/types/ts4.7/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/ts4.7/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/ts4.7/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/ts4.7/track/mse/MseTrack.d.ts +0 -1
- package/dist/types/ts4.7/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/ts4.7/util/media/codecSupport.d.ts +6 -0
- package/dist/types/ts4.7/util/media/mimeType.d.ts +8 -0
- package/dist/unit/types/current/ad/AdController.test.d.ts +2 -0
- package/dist/unit/types/current/ad/AdController.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/AdController.test.js +10 -0
- package/dist/unit/types/current/ad/AdControllerImpl.test.d.ts +2 -0
- package/dist/unit/types/current/ad/AdControllerImpl.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/AdControllerImpl.test.js +1654 -0
- package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.d.ts +2 -0
- package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.js +56 -0
- package/dist/unit/types/current/ad/discoverHlsInterstitials.test.d.ts +2 -0
- package/dist/unit/types/current/ad/discoverHlsInterstitials.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/discoverHlsInterstitials.test.js +757 -0
- package/dist/unit/types/current/drm/DrmControllerImpl.test.js +96 -2
- 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 +163 -0
- package/dist/unit/types/current/streaming/ManifestControllerImpl.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/ManifestControllerImpl.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/ManifestControllerImpl.test.js +197 -0
- package/dist/unit/types/current/streaming/MseTrack.test.js +15 -0
- package/dist/unit/types/current/streaming/buffering/codecDenylist.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/buffering/codecDenylist.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/buffering/codecDenylist.test.js +56 -0
- package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.js +77 -0
- package/dist/unit/types/current/streaming/createTimelineContentTypesValue.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/createTimelineContentTypesValue.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/createTimelineContentTypesValue.test.js +57 -0
- package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.js +99 -0
- package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts +2 -0
- package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.js +231 -0
- package/dist/unit/types/current/text/SidecarTextTrackController.test.d.ts +2 -0
- package/dist/unit/types/current/text/SidecarTextTrackController.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/SidecarTextTrackController.test.js +686 -0
- package/dist/unit/types/current/text/SidecarTextTrackLoader.test.d.ts +2 -0
- package/dist/unit/types/current/text/SidecarTextTrackLoader.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/SidecarTextTrackLoader.test.js +365 -0
- package/dist/unit/types/current/text/TextTrack.test.d.ts +2 -0
- package/dist/unit/types/current/text/TextTrack.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/TextTrack.test.js +12 -0
- package/dist/unit/types/current/text/VttCueStyle.test.d.ts +2 -0
- package/dist/unit/types/current/text/VttCueStyle.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/VttCueStyle.test.js +76 -0
- package/dist/unit/types/current/text/discoverDashTextTracks.test.d.ts +2 -0
- package/dist/unit/types/current/text/discoverDashTextTracks.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/discoverDashTextTracks.test.js +216 -0
- package/dist/unit/types/current/text/discoverHlsTextTracks.test.d.ts +2 -0
- package/dist/unit/types/current/text/discoverHlsTextTracks.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/discoverHlsTextTracks.test.js +177 -0
- package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts +2 -0
- package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/mediaTextTrackProvider.test.js +86 -0
- package/dist/unit/types/current/text/parseWebVtt.test.d.ts +2 -0
- package/dist/unit/types/current/text/parseWebVtt.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/parseWebVtt.test.js +419 -0
- package/dist/unit/types/current/text/pickPreferredTextTrack.test.d.ts +2 -0
- package/dist/unit/types/current/text/pickPreferredTextTrack.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/pickPreferredTextTrack.test.js +78 -0
- package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.d.ts +2 -0
- package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.d.ts.map +1 -0
- package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.js +165 -0
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/unit/types/current/util/media/codecOverrides.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/codecOverrides.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/codecOverrides.test.js +42 -0
- package/dist/unit/types/current/util/media/codecSupport.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/codecSupport.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/codecSupport.test.js +26 -0
- 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/VinylPlayerAdBreaks.test.d.ts +2 -0
- package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.d.ts.map +1 -0
- package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.js +142 -0
- package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.d.ts +2 -0
- package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.d.ts.map +1 -0
- package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.js +188 -0
- package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.d.ts.map +1 -0
- package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.js +26 -0
- package/dist/vinylTestUtil/types/current/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts +10 -0
- package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts.map +1 -0
- package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.js +14 -0
- package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/types/ts3.7/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/ts3.7/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/ts3.7/mock/text/MockTextTrackController.d.ts +10 -0
- package/dist/vinylTestUtil/types/ts4.1/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/ts4.1/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/ts4.1/mock/text/MockTextTrackController.d.ts +10 -0
- package/dist/vinylTestUtil/types/ts4.7/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/ts4.7/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/ts4.7/mock/text/MockTextTrackController.d.ts +10 -0
- package/package.json +10 -11
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { createAbortSlot, createDisposer, equalDeep, EventHostImpl, logError, } from '@amazon/vinyl-util';
|
|
6
|
+
import { loadWebVttCues } from './SidecarTextTrackLoader';
|
|
7
|
+
import { pickPreferredTextTrack } from './pickPreferredTextTrack';
|
|
8
|
+
import { applyVttCueStyle, isVttCue } from './VttCueStyle';
|
|
9
|
+
/**
|
|
10
|
+
* Selects the text track that matches the given options, or null for none.
|
|
11
|
+
*
|
|
12
|
+
* The `enabled` mode gates everything: `'off'` renders nothing (default is
|
|
13
|
+
* `'forced'`). Otherwise an explicit {@link TextTrackSelection.id} wins; else
|
|
14
|
+
* the best language match is chosen among tracks filtered by kind and
|
|
15
|
+
* forced-ness. Forced-ness comes from {@link TextTrackSelection.forced} when
|
|
16
|
+
* set, otherwise from the mode (`'forced'` keeps only forced tracks, `'on'`
|
|
17
|
+
* only full tracks).
|
|
18
|
+
*
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
export function resolveSelectedTrack(tracks, options) {
|
|
22
|
+
const mode = options.enabled ?? 'forced';
|
|
23
|
+
if (mode === 'off')
|
|
24
|
+
return null;
|
|
25
|
+
const selection = options.selection ?? {};
|
|
26
|
+
if (selection.id != null) {
|
|
27
|
+
return tracks.find((t) => t.id === selection.id) ?? null;
|
|
28
|
+
}
|
|
29
|
+
let pool = tracks;
|
|
30
|
+
if (selection.kind != null) {
|
|
31
|
+
pool = pool.filter((t) => t.kind === selection.kind);
|
|
32
|
+
}
|
|
33
|
+
// Explicit forced filter overrides the mode's forced/full split.
|
|
34
|
+
const forced = selection.forced ?? mode === 'forced';
|
|
35
|
+
pool = pool.filter((t) => t.forced === forced);
|
|
36
|
+
// pickPreferredTextTrack falls back to navigator.languages when no language
|
|
37
|
+
// preference is supplied.
|
|
38
|
+
return pickPreferredTextTrack(pool, selection.language);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Manages a sidecar WebVTT-based text track lifecycle:
|
|
42
|
+
*
|
|
43
|
+
* - tracks the discovered {@link TextTrackInfo} list (from the `textTracks`
|
|
44
|
+
* observable) and the current selection (from the `options` observable)
|
|
45
|
+
* - on selection, fetches the chosen track's WebVTT and pushes cues to a DOM
|
|
46
|
+
* `TextTrack` obtained from the {@link MediaTextTrackProvider}
|
|
47
|
+
* - clears cues and hides the DOM track when the selection changes or clears
|
|
48
|
+
*
|
|
49
|
+
* The controller is agnostic of HLS/DASH discovery details; its inputs are the
|
|
50
|
+
* observables supplied by the manifest layer.
|
|
51
|
+
*/
|
|
52
|
+
export class SidecarTextTrackController extends EventHostImpl {
|
|
53
|
+
deps;
|
|
54
|
+
get [Symbol.toStringTag]() {
|
|
55
|
+
return 'SidecarTextTrackController';
|
|
56
|
+
}
|
|
57
|
+
// Whether the owning media track is current (rendering allowed). Toggled by
|
|
58
|
+
// activate()/deactivate() across suspensions such as ad breaks.
|
|
59
|
+
_active = false;
|
|
60
|
+
_tracks = [];
|
|
61
|
+
_activeTextTrack = null;
|
|
62
|
+
// The DOM text track currently rendering cues, or null when hidden. Owned by
|
|
63
|
+
// the provider (never created/removed here).
|
|
64
|
+
_ref = null;
|
|
65
|
+
loadAbort = createAbortSlot();
|
|
66
|
+
disposer = createDisposer();
|
|
67
|
+
constructor(deps) {
|
|
68
|
+
super();
|
|
69
|
+
this.deps = deps;
|
|
70
|
+
const { add } = this.disposer;
|
|
71
|
+
// Both fire immediately with the current value, resolving the initial
|
|
72
|
+
// track list and selection on construction.
|
|
73
|
+
add(deps.options.onData(() => this.refreshSelection()));
|
|
74
|
+
add(deps.textTracks.onData((tracksPromise) => {
|
|
75
|
+
tracksPromise
|
|
76
|
+
.then((tracks) => this.setTracks(tracks))
|
|
77
|
+
.catch((error) => {
|
|
78
|
+
// Manifest errors surface through the manifest
|
|
79
|
+
// controller; just note and don't double-report.
|
|
80
|
+
logError(this, 'text tracks promise rejected', error);
|
|
81
|
+
});
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
get textTracks() {
|
|
85
|
+
return this._tracks;
|
|
86
|
+
}
|
|
87
|
+
get activeTextTrack() {
|
|
88
|
+
return this._activeTextTrack;
|
|
89
|
+
}
|
|
90
|
+
get active() {
|
|
91
|
+
return this._active;
|
|
92
|
+
}
|
|
93
|
+
get disposed() {
|
|
94
|
+
return this.disposer.disposed;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Replaces the discovered track list, emits `textTracksChange`, then
|
|
98
|
+
* re-applies the current selection against the new list.
|
|
99
|
+
*/
|
|
100
|
+
setTracks(tracks) {
|
|
101
|
+
if (this.disposed)
|
|
102
|
+
return;
|
|
103
|
+
const previous = this._tracks;
|
|
104
|
+
if (equalDeep(previous, tracks))
|
|
105
|
+
return;
|
|
106
|
+
this._tracks = tracks;
|
|
107
|
+
this.dispatch('textTracksChange', { previous, current: tracks });
|
|
108
|
+
this.refreshSelection();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Recomputes the selection from the current options and track list,
|
|
112
|
+
* emitting `activeTextTrackChange` on change and (re)rendering when active.
|
|
113
|
+
*/
|
|
114
|
+
refreshSelection() {
|
|
115
|
+
const previous = this._activeTextTrack;
|
|
116
|
+
const target = resolveSelectedTrack(this._tracks, this.deps.options.value);
|
|
117
|
+
const trackChanged = target?.id !== previous?.id;
|
|
118
|
+
if (trackChanged) {
|
|
119
|
+
this._activeTextTrack = target;
|
|
120
|
+
this.dispatch('activeTextTrackChange', {
|
|
121
|
+
previous,
|
|
122
|
+
current: target,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (!this._active)
|
|
126
|
+
return;
|
|
127
|
+
// Cues carry their own authored styling, so only a track change (not a
|
|
128
|
+
// same-track options change) needs a (re)load.
|
|
129
|
+
if (!target)
|
|
130
|
+
this.hideCurrent();
|
|
131
|
+
else if (trackChanged || !this._ref)
|
|
132
|
+
this.startLoad(target);
|
|
133
|
+
}
|
|
134
|
+
deactivate() {
|
|
135
|
+
this._active = false;
|
|
136
|
+
this.hideCurrent();
|
|
137
|
+
}
|
|
138
|
+
activate() {
|
|
139
|
+
this._active = true;
|
|
140
|
+
// Rebuild only when a selection exists and it isn't already rendering.
|
|
141
|
+
if (!this._activeTextTrack || this._ref)
|
|
142
|
+
return;
|
|
143
|
+
this.startLoad(this._activeTextTrack);
|
|
144
|
+
}
|
|
145
|
+
startLoad(track) {
|
|
146
|
+
// Hide the previously-rendering track (a different rendition) so its
|
|
147
|
+
// cues don't linger alongside the new one; this also aborts any prior
|
|
148
|
+
// in-flight load and arms a fresh abort for this one.
|
|
149
|
+
this.hideCurrent();
|
|
150
|
+
const abort = this.loadAbort.value;
|
|
151
|
+
const ref = this.deps.textTrackProvider.getOrCreate(track.kind, track.label, track.language ?? undefined);
|
|
152
|
+
// With an injected renderer the browser must not paint (the renderer
|
|
153
|
+
// does), but the track still needs to be active for cue timing — hence
|
|
154
|
+
// 'hidden'. Without one, 'showing' uses native rendering. Set the mode
|
|
155
|
+
// before clearing: `cues` reads null while disabled.
|
|
156
|
+
const renderer = this.deps.textTrackRenderer;
|
|
157
|
+
ref.track.mode = renderer ? 'hidden' : 'showing';
|
|
158
|
+
ref.clear();
|
|
159
|
+
this._ref = ref;
|
|
160
|
+
renderer?.setTextTrack(ref.track);
|
|
161
|
+
const CueCtor = getVttCueConstructor();
|
|
162
|
+
// Adjacent HLS caption segments commonly repeat the boundary cue in both
|
|
163
|
+
// segments (so a client that only fetches one still renders the overlap).
|
|
164
|
+
// Track seen keys per active load so we don't push the same cue twice.
|
|
165
|
+
const seen = new Set();
|
|
166
|
+
// Accumulate authored STYLE-block CSS and forward it to the renderer as
|
|
167
|
+
// it arrives — only wired when the renderer can actually consume styles.
|
|
168
|
+
const styles = new Set();
|
|
169
|
+
const setStyles = renderer?.setStyles?.bind(renderer);
|
|
170
|
+
loadWebVttCues(track.uri, {
|
|
171
|
+
abort,
|
|
172
|
+
requestInit: this.deps.requestInit,
|
|
173
|
+
variables: track.variables,
|
|
174
|
+
getCurrentTime: () => this.deps.playbackController.currentTime,
|
|
175
|
+
onCues: (cues) => {
|
|
176
|
+
if (abort.aborted())
|
|
177
|
+
return;
|
|
178
|
+
if (CueCtor)
|
|
179
|
+
this.appendCues(ref.track, CueCtor, cues, seen);
|
|
180
|
+
},
|
|
181
|
+
onStyles: setStyles
|
|
182
|
+
? (blocks) => {
|
|
183
|
+
if (abort.aborted())
|
|
184
|
+
return;
|
|
185
|
+
for (const block of blocks)
|
|
186
|
+
styles.add(block);
|
|
187
|
+
setStyles([...styles]);
|
|
188
|
+
}
|
|
189
|
+
: undefined,
|
|
190
|
+
}).catch((error) => {
|
|
191
|
+
if (abort.aborted())
|
|
192
|
+
return;
|
|
193
|
+
this.dispatch('textTrackError', {
|
|
194
|
+
track,
|
|
195
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
appendCues(dom, CueCtor, cues, seen) {
|
|
200
|
+
for (const cue of cues) {
|
|
201
|
+
const key = `${cue.startTime}|${cue.endTime}|${cue.text}`;
|
|
202
|
+
if (seen.has(key))
|
|
203
|
+
continue;
|
|
204
|
+
seen.add(key);
|
|
205
|
+
const domCue = new CueCtor(cue.startTime, cue.endTime, cue.text);
|
|
206
|
+
if (cue.id != null)
|
|
207
|
+
domCue.id = cue.id;
|
|
208
|
+
// Preserve the cue's own authored WebVTT settings (position, line,
|
|
209
|
+
// size, align, …). Only VTTCues carry these properties.
|
|
210
|
+
if (cue.settings && isVttCue(domCue)) {
|
|
211
|
+
applyVttCueStyle(domCue, cue.settings);
|
|
212
|
+
}
|
|
213
|
+
dom.addCue(domCue);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Clears cues from the current DOM track and hides it, keeping the track for
|
|
218
|
+
* later reuse via the provider.
|
|
219
|
+
*/
|
|
220
|
+
hideCurrent() {
|
|
221
|
+
// Cancel any in-flight load: its cues are no longer wanted, and a late
|
|
222
|
+
// rejection must not surface as a textTrackError.
|
|
223
|
+
this.loadAbort.abort();
|
|
224
|
+
const ref = this._ref;
|
|
225
|
+
if (!ref)
|
|
226
|
+
return;
|
|
227
|
+
this.deps.textTrackRenderer?.setTextTrack(null);
|
|
228
|
+
ref.clear();
|
|
229
|
+
ref.track.mode = 'disabled';
|
|
230
|
+
this._ref = null;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Cancels any in-flight load, hides the DOM text track, and resets state.
|
|
234
|
+
* Called by the host when the underlying media is unloaded.
|
|
235
|
+
*/
|
|
236
|
+
dispose() {
|
|
237
|
+
if (this.disposed)
|
|
238
|
+
return;
|
|
239
|
+
super.dispose();
|
|
240
|
+
this.loadAbort.abort();
|
|
241
|
+
this.hideCurrent();
|
|
242
|
+
this.disposer.dispose();
|
|
243
|
+
this._tracks = [];
|
|
244
|
+
this._activeTextTrack = null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function getVttCueConstructor() {
|
|
248
|
+
const g = globalThis;
|
|
249
|
+
return g.VTTCue ?? g.TextTrackCue ?? null;
|
|
250
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Maybe, ReadonlyAbort, RequestInitOptions } from '@amazon/vinyl-util';
|
|
2
|
+
import { type WebVttCue } from './parseWebVtt';
|
|
3
|
+
/**
|
|
4
|
+
* Seconds ahead of the playhead to keep cues buffered. Mirrors the media
|
|
5
|
+
* pipeline's default HLS `minBufferTime` so captions stay in step with the
|
|
6
|
+
* audio/video buffer.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_TEXT_LOOK_AHEAD = 10;
|
|
9
|
+
/**
|
|
10
|
+
* Seconds behind the playhead to keep cues buffered. Small window so that a
|
|
11
|
+
* short rewind (e.g. accidental skip-back) doesn't force a refetch.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_TEXT_LOOK_BEHIND = 2;
|
|
14
|
+
export interface LoadWebVttCuesOptions {
|
|
15
|
+
readonly abort?: Maybe<ReadonlyAbort>;
|
|
16
|
+
readonly requestInit?: Maybe<RequestInitOptions>;
|
|
17
|
+
/**
|
|
18
|
+
* HLS EXT-X-DEFINE variables to make available for `IMPORT` and for
|
|
19
|
+
* substitution of segment URIs when loading from an HLS media playlist.
|
|
20
|
+
*/
|
|
21
|
+
readonly variables?: Maybe<Readonly<Record<string, string>>>;
|
|
22
|
+
/**
|
|
23
|
+
* Invoked with each batch of cues as soon as they are parsed. Called once
|
|
24
|
+
* per HLS segment, or once for a direct `.vtt` document.
|
|
25
|
+
*/
|
|
26
|
+
readonly onCues: (cues: readonly WebVttCue[]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Invoked with the CSS body of any `STYLE` blocks parsed from a document.
|
|
29
|
+
* Only called when a document actually declares styles.
|
|
30
|
+
*/
|
|
31
|
+
readonly onStyles?: Maybe<(styles: readonly string[]) => void>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the current playback time (seconds on the presentation
|
|
34
|
+
* timeline). Used to fetch caption segments in a window around the
|
|
35
|
+
* playhead rather than draining the entire playlist up front.
|
|
36
|
+
*/
|
|
37
|
+
readonly getCurrentTime: () => number;
|
|
38
|
+
/**
|
|
39
|
+
* Seconds ahead of the playhead to keep buffered. Default 10s.
|
|
40
|
+
*/
|
|
41
|
+
readonly lookAhead?: Maybe<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Seconds behind the playhead to keep buffered. Default 2s.
|
|
44
|
+
*/
|
|
45
|
+
readonly lookBehind?: Maybe<number>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Loads WebVTT cues from a URI, streaming them by playhead position.
|
|
49
|
+
*
|
|
50
|
+
* Two URI shapes are accepted:
|
|
51
|
+
* - Direct `.vtt` document: fetched once and delivered via `onCues`.
|
|
52
|
+
* - HLS media playlist (`.m3u8`): the playlist is parsed, then segments
|
|
53
|
+
* whose time range overlaps the buffer window around `getCurrentTime()`
|
|
54
|
+
* are fetched (closest to the playhead first), one at a time. Each
|
|
55
|
+
* segment's cues are delivered via `onCues` as it is parsed.
|
|
56
|
+
*
|
|
57
|
+
* Cue start/end times are expected to already be on the presentation
|
|
58
|
+
* timeline (Shaka packager's default WebVTT output), so segments are joined
|
|
59
|
+
* without offset.
|
|
60
|
+
*
|
|
61
|
+
* The returned promise resolves once every segment has been fetched, or the
|
|
62
|
+
* abort signal fires. Fetch failures reject the promise.
|
|
63
|
+
*/
|
|
64
|
+
export declare function loadWebVttCues(uri: string, options: LoadWebVttCuesOptions): Promise<void>;
|
|
65
|
+
//# sourceMappingURL=SidecarTextTrackLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidecarTextTrackLoader.d.ts","sourceRoot":"","sources":["../../../../src/text/SidecarTextTrackLoader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACR,KAAK,EACL,aAAa,EACb,kBAAkB,EACrB,MAAM,oBAAoB,CAAA;AAQ3B,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAEzC;;;GAGG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAA;AAQzC,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAEhD;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAE5D;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,KAAK,IAAI,CAAA;IAErD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC,CAAA;IAE9D;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,MAAM,CAAA;IAErC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAElC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACtC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,cAAc,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA0Cf"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { readResponseBody, requestWithRetry, resolveUrl, sleep, } from '@amazon/vinyl-util';
|
|
6
|
+
import { parseMediaPlaylist } from '@amazon/vinyl-hls-parser';
|
|
7
|
+
import { parseWebVtt } from './parseWebVtt';
|
|
8
|
+
/**
|
|
9
|
+
* Seconds ahead of the playhead to keep cues buffered. Mirrors the media
|
|
10
|
+
* pipeline's default HLS `minBufferTime` so captions stay in step with the
|
|
11
|
+
* audio/video buffer.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_TEXT_LOOK_AHEAD = 10;
|
|
14
|
+
/**
|
|
15
|
+
* Seconds behind the playhead to keep cues buffered. Small window so that a
|
|
16
|
+
* short rewind (e.g. accidental skip-back) doesn't force a refetch.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_TEXT_LOOK_BEHIND = 2;
|
|
19
|
+
/**
|
|
20
|
+
* Polling interval, in seconds, when no segment is currently in the buffer
|
|
21
|
+
* window. Short enough to feel responsive after a seek without spinning.
|
|
22
|
+
*/
|
|
23
|
+
const IDLE_POLL_SECONDS = 0.25;
|
|
24
|
+
/**
|
|
25
|
+
* Loads WebVTT cues from a URI, streaming them by playhead position.
|
|
26
|
+
*
|
|
27
|
+
* Two URI shapes are accepted:
|
|
28
|
+
* - Direct `.vtt` document: fetched once and delivered via `onCues`.
|
|
29
|
+
* - HLS media playlist (`.m3u8`): the playlist is parsed, then segments
|
|
30
|
+
* whose time range overlaps the buffer window around `getCurrentTime()`
|
|
31
|
+
* are fetched (closest to the playhead first), one at a time. Each
|
|
32
|
+
* segment's cues are delivered via `onCues` as it is parsed.
|
|
33
|
+
*
|
|
34
|
+
* Cue start/end times are expected to already be on the presentation
|
|
35
|
+
* timeline (Shaka packager's default WebVTT output), so segments are joined
|
|
36
|
+
* without offset.
|
|
37
|
+
*
|
|
38
|
+
* The returned promise resolves once every segment has been fetched, or the
|
|
39
|
+
* abort signal fires. Fetch failures reject the promise.
|
|
40
|
+
*/
|
|
41
|
+
export async function loadWebVttCues(uri, options) {
|
|
42
|
+
const { abort, requestInit, variables, onCues, onStyles, getCurrentTime } = options;
|
|
43
|
+
const lookAhead = options.lookAhead ?? DEFAULT_TEXT_LOOK_AHEAD;
|
|
44
|
+
const lookBehind = options.lookBehind ?? DEFAULT_TEXT_LOOK_BEHIND;
|
|
45
|
+
const init = requestInit ?? undefined;
|
|
46
|
+
if (looksLikeMediaPlaylist(uri)) {
|
|
47
|
+
return streamMediaPlaylist({
|
|
48
|
+
uri,
|
|
49
|
+
init,
|
|
50
|
+
abort,
|
|
51
|
+
variables: variables ?? undefined,
|
|
52
|
+
onCues,
|
|
53
|
+
onStyles,
|
|
54
|
+
getCurrentTime,
|
|
55
|
+
lookAhead,
|
|
56
|
+
lookBehind,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const response = await requestWithRetry(uri, init, { abort });
|
|
60
|
+
const contentType = (response.headers.get('content-type') ?? '').toLowerCase();
|
|
61
|
+
const body = await readResponseBody(response, 'text');
|
|
62
|
+
if (contentType.includes('mpegurl') || body.startsWith('#EXTM3U')) {
|
|
63
|
+
return streamMediaPlaylistText({
|
|
64
|
+
text: body,
|
|
65
|
+
baseUrl: response.url || uri,
|
|
66
|
+
init,
|
|
67
|
+
abort,
|
|
68
|
+
variables: variables ?? undefined,
|
|
69
|
+
onCues,
|
|
70
|
+
onStyles,
|
|
71
|
+
getCurrentTime,
|
|
72
|
+
lookAhead,
|
|
73
|
+
lookBehind,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const doc = parseWebVtt(body);
|
|
77
|
+
if (doc.cues.length > 0)
|
|
78
|
+
onCues(doc.cues);
|
|
79
|
+
if (onStyles && doc.styles.length > 0)
|
|
80
|
+
onStyles(doc.styles);
|
|
81
|
+
}
|
|
82
|
+
function looksLikeMediaPlaylist(uri) {
|
|
83
|
+
const path = uri.split(/[?#]/)[0];
|
|
84
|
+
return path.toLowerCase().endsWith('.m3u8');
|
|
85
|
+
}
|
|
86
|
+
async function streamMediaPlaylist(ctx) {
|
|
87
|
+
const response = await requestWithRetry(ctx.uri, ctx.init, {
|
|
88
|
+
abort: ctx.abort,
|
|
89
|
+
});
|
|
90
|
+
const text = await readResponseBody(response, 'text');
|
|
91
|
+
return streamMediaPlaylistText({
|
|
92
|
+
...ctx,
|
|
93
|
+
text,
|
|
94
|
+
baseUrl: response.url || ctx.uri,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async function streamMediaPlaylistText(ctx) {
|
|
98
|
+
const playlist = parseMediaPlaylist(ctx.text, ctx.variables);
|
|
99
|
+
const segments = playlist.segments;
|
|
100
|
+
// Precompute each segment's [start, end] on the presentation timeline.
|
|
101
|
+
const ranges = [];
|
|
102
|
+
let cursor = 0;
|
|
103
|
+
for (const seg of segments) {
|
|
104
|
+
ranges.push({ start: cursor, end: cursor + seg.duration });
|
|
105
|
+
cursor += seg.duration;
|
|
106
|
+
}
|
|
107
|
+
const pending = new Set(segments.map((_, i) => i));
|
|
108
|
+
while (pending.size > 0 && !ctx.abort?.aborted()) {
|
|
109
|
+
const idx = pickInWindow(pending, ranges, ctx);
|
|
110
|
+
if (idx < 0) {
|
|
111
|
+
await sleep(IDLE_POLL_SECONDS, ctx.abort).catch(() => { });
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
pending.delete(idx);
|
|
115
|
+
const segUri = resolveUrl(segments[idx].uri, ctx.baseUrl);
|
|
116
|
+
const res = await requestWithRetry(segUri, ctx.init, {
|
|
117
|
+
abort: ctx.abort,
|
|
118
|
+
});
|
|
119
|
+
const body = await readResponseBody(res, 'text');
|
|
120
|
+
const doc = parseWebVtt(body);
|
|
121
|
+
if (doc.cues.length > 0)
|
|
122
|
+
ctx.onCues(doc.cues);
|
|
123
|
+
if (ctx.onStyles && doc.styles.length > 0)
|
|
124
|
+
ctx.onStyles(doc.styles);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Selects the pending segment closest to the playhead whose time range
|
|
129
|
+
* overlaps [now - lookBehind, now + lookAhead]. Returns -1 when no pending
|
|
130
|
+
* segment intersects the window — the caller should sleep and re-check.
|
|
131
|
+
*/
|
|
132
|
+
function pickInWindow(pending, ranges, ctx) {
|
|
133
|
+
const now = ctx.getCurrentTime();
|
|
134
|
+
const windowStart = now - ctx.lookBehind;
|
|
135
|
+
const windowEnd = now + ctx.lookAhead;
|
|
136
|
+
let best = -1;
|
|
137
|
+
let bestDist = Number.POSITIVE_INFINITY;
|
|
138
|
+
for (const idx of pending) {
|
|
139
|
+
const r = ranges[idx];
|
|
140
|
+
if (r.end < windowStart || r.start > windowEnd)
|
|
141
|
+
continue;
|
|
142
|
+
const mid = (r.start + r.end) / 2;
|
|
143
|
+
const dist = Math.abs(mid - now);
|
|
144
|
+
if (dist < bestDist) {
|
|
145
|
+
bestDist = dist;
|
|
146
|
+
best = idx;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return best;
|
|
150
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { ChangeEvent } from '../event/ChangeEvent';
|
|
2
|
+
import type { ReadonlyEventHost } from '@amazon/vinyl-util';
|
|
3
|
+
import type { ObjectSchema } from '@amazon/vinyl-validation';
|
|
4
|
+
/**
|
|
5
|
+
* Categorizes the role of a text track. Mirrors HTMLMediaElement.TextTrackKind.
|
|
6
|
+
*/
|
|
7
|
+
export type TextTrackKind = 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
8
|
+
/**
|
|
9
|
+
* Identifies and describes an available text track.
|
|
10
|
+
* One TextTrackInfo is produced per discovered subtitle rendition.
|
|
11
|
+
*/
|
|
12
|
+
export interface TextTrackInfo {
|
|
13
|
+
/**
|
|
14
|
+
* A stable, unique identifier within the current media presentation.
|
|
15
|
+
*/
|
|
16
|
+
readonly id: string;
|
|
17
|
+
/**
|
|
18
|
+
* The text track kind. Defaults to 'subtitles' when not otherwise specified.
|
|
19
|
+
*/
|
|
20
|
+
readonly kind: TextTrackKind;
|
|
21
|
+
/**
|
|
22
|
+
* The BCP 47 language tag for the cues in this track, or null if unknown.
|
|
23
|
+
*/
|
|
24
|
+
readonly language: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* A human-readable label for the track.
|
|
27
|
+
*/
|
|
28
|
+
readonly label: string;
|
|
29
|
+
/**
|
|
30
|
+
* Set when the source manifest signals this track as the default selection.
|
|
31
|
+
*/
|
|
32
|
+
readonly default: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether this is a forced track: it carries essential text (e.g.
|
|
35
|
+
* translations of foreign-language dialogue) meant to be shown even when
|
|
36
|
+
* the user has not enabled subtitles. Two tracks may share a language and
|
|
37
|
+
* differ only by this flag, so selection must distinguish them.
|
|
38
|
+
*/
|
|
39
|
+
readonly forced: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Media characteristics / accessibility roles describing the track, e.g.
|
|
42
|
+
* `public.accessibility.transcribes-spoken-dialog` (HLS CHARACTERISTICS) or
|
|
43
|
+
* a DASH role/accessibility scheme value. Empty when none are signaled.
|
|
44
|
+
*/
|
|
45
|
+
readonly characteristics: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* The full URL of the underlying text resource (typically a WebVTT file).
|
|
48
|
+
*/
|
|
49
|
+
readonly uri: string;
|
|
50
|
+
/**
|
|
51
|
+
* The MIME type signaled by the source manifest, when known.
|
|
52
|
+
*/
|
|
53
|
+
readonly mimeType: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* HLS EXT-X-DEFINE variables inherited from the parent multivariant
|
|
56
|
+
* playlist. Sidecar text-track media playlists commonly `IMPORT` these
|
|
57
|
+
* names and reference them in segment URIs. Present only for HLS-sourced
|
|
58
|
+
* tracks whose parent playlist declared any variables.
|
|
59
|
+
*/
|
|
60
|
+
readonly variables?: Readonly<Record<string, string>>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Events dispatched by a {@link TextTrackController}.
|
|
64
|
+
*/
|
|
65
|
+
export interface TextTrackEventMap {
|
|
66
|
+
/**
|
|
67
|
+
* Emitted when the available text tracks change.
|
|
68
|
+
*/
|
|
69
|
+
readonly textTracksChange: ChangeEvent<readonly TextTrackInfo[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Emitted when the active text track changes.
|
|
72
|
+
*/
|
|
73
|
+
readonly activeTextTrackChange: ChangeEvent<TextTrackInfo | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Emitted when an error occurs while loading or activating a text track.
|
|
76
|
+
*/
|
|
77
|
+
readonly textTrackError: TextTrackErrorEvent;
|
|
78
|
+
}
|
|
79
|
+
export interface TextTrackErrorEvent {
|
|
80
|
+
readonly track: TextTrackInfo;
|
|
81
|
+
readonly error: Error;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Which captions render:
|
|
85
|
+
* - `'off'` — nothing renders (not even forced narrative captions).
|
|
86
|
+
* - `'forced'` — only forced (narrative) tracks, so nothing shows unless the
|
|
87
|
+
* content carries a forced track for the preferred language.
|
|
88
|
+
* - `'on'` — the full (non-forced) subtitle track for the preferred language.
|
|
89
|
+
*/
|
|
90
|
+
export type CaptionMode = 'on' | 'off' | 'forced';
|
|
91
|
+
/**
|
|
92
|
+
* Criteria used to pick which text track to render. Applied in priority order:
|
|
93
|
+
* an explicit {@link id} wins; otherwise the best {@link language} match is
|
|
94
|
+
* chosen among tracks filtered by {@link kind} and by forced-ness (from
|
|
95
|
+
* {@link forced} when set, else from the controller's
|
|
96
|
+
* {@link TextTrackControllerOptions.enabled} mode).
|
|
97
|
+
*/
|
|
98
|
+
export interface TextTrackSelection {
|
|
99
|
+
/**
|
|
100
|
+
* Selects the text track with this exact identifier, ignoring the other
|
|
101
|
+
* criteria (but still gated by the `'off'` mode). If no track has this id,
|
|
102
|
+
* nothing is selected.
|
|
103
|
+
*/
|
|
104
|
+
readonly id?: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Restricts selection to tracks of this kind (e.g. `'captions'`). Unset
|
|
107
|
+
* considers all kinds.
|
|
108
|
+
*/
|
|
109
|
+
readonly kind?: TextTrackKind | null;
|
|
110
|
+
/**
|
|
111
|
+
* Preferred caption language(s), most-preferred first, as RFC 5646 tags.
|
|
112
|
+
* When unset (or empty) selection falls back to the platform's
|
|
113
|
+
* `navigator.languages`.
|
|
114
|
+
*/
|
|
115
|
+
readonly language?: string | readonly string[] | null;
|
|
116
|
+
/**
|
|
117
|
+
* Explicit forced-ness filter. When set, only tracks whose `forced` flag
|
|
118
|
+
* equals this value are considered, overriding the forced/full split
|
|
119
|
+
* implied by the `enabled` mode. Unset means the mode decides.
|
|
120
|
+
*/
|
|
121
|
+
readonly forced?: boolean | null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Declarative configuration for a {@link TextTrackController}. Rendering is
|
|
125
|
+
* driven entirely by this value (via `VinylOptions.text`); there is no
|
|
126
|
+
* imperative track-select call.
|
|
127
|
+
*/
|
|
128
|
+
export interface TextTrackControllerOptions {
|
|
129
|
+
/**
|
|
130
|
+
* Which captions render (see {@link CaptionMode}). Unset defaults to
|
|
131
|
+
* `'forced'`.
|
|
132
|
+
*/
|
|
133
|
+
readonly enabled?: CaptionMode | null;
|
|
134
|
+
/**
|
|
135
|
+
* The selection criteria (language / id / kind). When unset, the preferred
|
|
136
|
+
* languages fall back to the platform's `navigator.languages`.
|
|
137
|
+
*/
|
|
138
|
+
readonly selection?: TextTrackSelection | null;
|
|
139
|
+
}
|
|
140
|
+
export declare const textTrackControllerOptionsValidator: ObjectSchema<TextTrackControllerOptions>;
|
|
141
|
+
export declare const ALL_TEXT_TRACK_EVENTS: readonly ["textTracksChange", "activeTextTrackChange", "textTrackError"];
|
|
142
|
+
/**
|
|
143
|
+
* Read-only view of available text tracks and the active selection.
|
|
144
|
+
*/
|
|
145
|
+
export interface ReadonlyTextTrackController extends ReadonlyEventHost<TextTrackEventMap> {
|
|
146
|
+
/**
|
|
147
|
+
* The list of currently discovered text tracks.
|
|
148
|
+
*/
|
|
149
|
+
readonly textTracks: readonly TextTrackInfo[];
|
|
150
|
+
/**
|
|
151
|
+
* The currently active text track, or null if none is active.
|
|
152
|
+
*/
|
|
153
|
+
readonly activeTextTrack: TextTrackInfo | null;
|
|
154
|
+
/**
|
|
155
|
+
* Returns true if this text track controller is active.
|
|
156
|
+
*/
|
|
157
|
+
get active(): boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Full controller for the current media's text tracks. Selection is driven
|
|
161
|
+
* declaratively through the controller's options (`VinylOptions.text`); this
|
|
162
|
+
* interface only adds the render lifecycle used by the owning media track.
|
|
163
|
+
*/
|
|
164
|
+
export interface TextTrackController extends ReadonlyTextTrackController {
|
|
165
|
+
/**
|
|
166
|
+
* Suspends cue rendering without changing the active selection: cancels any
|
|
167
|
+
* in-flight load and hides the DOM text track (so its cues stop showing).
|
|
168
|
+
* Called when the owning media track is deactivated — e.g. while an ad
|
|
169
|
+
* plays over the suspended content. {@link activate} rebuilds it.
|
|
170
|
+
*/
|
|
171
|
+
deactivate(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Resumes rendering the active selection after a {@link deactivate},
|
|
174
|
+
* reloading its cues. No-op when nothing is selected or already rendering.
|
|
175
|
+
* Called when the owning media track is reactivated.
|
|
176
|
+
*/
|
|
177
|
+
activate(): void;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=TextTrack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextTrack.d.ts","sourceRoot":"","sources":["../../../../src/text/TextTrack.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAS5D;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,CAAA;AAEvE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAE5B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IAExB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;IAE3C;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CAAC,SAAS,aAAa,EAAE,CAAC,CAAA;IAEhE;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,WAAW,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IAEjE;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAAA;CAC/C;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACxB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,QAAQ,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAErD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACvC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAErC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjD;AAmBD,eAAO,MAAM,mCAAmC,EAAE,YAAY,CAAC,0BAA0B,CAInF,CAAA;AAEN,eAAO,MAAM,qBAAqB,0EAIuB,CAAA;AAEzD;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB,CAAC,iBAAiB,CAAC;IACrF;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAA;IAE7C;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,aAAa,GAAG,IAAI,CAAA;IAE9C;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAAA;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,2BAA2B;IACpE;;;;;OAKG;IACH,UAAU,IAAI,IAAI,CAAA;IAElB;;;;OAIG;IACH,QAAQ,IAAI,IAAI,CAAA;CACnB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { array, boolean, isOneOf, object, string, } from '@amazon/vinyl-validation';
|
|
6
|
+
const TEXT_TRACK_KINDS = [
|
|
7
|
+
'subtitles',
|
|
8
|
+
'captions',
|
|
9
|
+
'descriptions',
|
|
10
|
+
'chapters',
|
|
11
|
+
'metadata',
|
|
12
|
+
];
|
|
13
|
+
const textTrackSelectionValidator = object({
|
|
14
|
+
id: string().orNull().optional(),
|
|
15
|
+
kind: isOneOf(...TEXT_TRACK_KINDS)
|
|
16
|
+
.orNull()
|
|
17
|
+
.optional(),
|
|
18
|
+
language: string().or(array(string()).readonly()).orNull().optional(),
|
|
19
|
+
forced: boolean().orNull().optional(),
|
|
20
|
+
});
|
|
21
|
+
export const textTrackControllerOptionsValidator = object({
|
|
22
|
+
enabled: isOneOf('on', 'off', 'forced').orNull().optional(),
|
|
23
|
+
selection: textTrackSelectionValidator.orNull().optional(),
|
|
24
|
+
});
|
|
25
|
+
export const ALL_TEXT_TRACK_EVENTS = [
|
|
26
|
+
'textTracksChange',
|
|
27
|
+
'activeTextTrackChange',
|
|
28
|
+
'textTrackError',
|
|
29
|
+
];
|