@amazon/vinyl 2.0.0 → 3.0.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.
Files changed (167) hide show
  1. package/dist/index.cjs +603 -317
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/index.js +622 -329
  4. package/dist/index.js.map +4 -4
  5. package/dist/test/benchmark.es5.js +8 -5
  6. package/dist/test/benchmark.js +228 -0
  7. package/dist/test/benchmark.js.map +4 -4
  8. package/dist/test/integ.es5.js +182 -156
  9. package/dist/test/integ.js +1853 -796
  10. package/dist/test/integ.js.map +4 -4
  11. package/dist/types/current/index.d.ts +4 -0
  12. package/dist/types/current/index.d.ts.map +1 -1
  13. package/dist/types/current/index.js +4 -0
  14. package/dist/types/current/streaming/AudioOptions.d.ts +39 -0
  15. package/dist/types/current/streaming/AudioOptions.d.ts.map +1 -0
  16. package/dist/types/current/streaming/AudioOptions.js +15 -0
  17. package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.d.ts +2 -2
  18. package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.d.ts.map +1 -1
  19. package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.js +5 -5
  20. package/dist/types/current/text/HtmlTextTrackRenderer.d.ts +60 -0
  21. package/dist/types/current/text/HtmlTextTrackRenderer.d.ts.map +1 -0
  22. package/dist/types/current/text/HtmlTextTrackRenderer.js +231 -0
  23. package/dist/types/current/text/SidecarTextTrackController.d.ts +65 -53
  24. package/dist/types/current/text/SidecarTextTrackController.d.ts.map +1 -1
  25. package/dist/types/current/text/SidecarTextTrackController.js +167 -154
  26. package/dist/types/current/text/SidecarTextTrackLoader.d.ts +5 -0
  27. package/dist/types/current/text/SidecarTextTrackLoader.d.ts.map +1 -1
  28. package/dist/types/current/text/SidecarTextTrackLoader.js +13 -7
  29. package/dist/types/current/text/TextTrack.d.ts +74 -20
  30. package/dist/types/current/text/TextTrack.d.ts.map +1 -1
  31. package/dist/types/current/text/TextTrack.js +20 -0
  32. package/dist/types/current/text/TextTrackRenderer.d.ts +24 -0
  33. package/dist/types/current/text/TextTrackRenderer.d.ts.map +1 -0
  34. package/dist/types/current/text/TextTrackRenderer.js +5 -0
  35. package/dist/types/current/text/mediaTextTrackProvider.d.ts +34 -0
  36. package/dist/types/current/text/mediaTextTrackProvider.d.ts.map +1 -0
  37. package/dist/types/current/text/mediaTextTrackProvider.js +42 -0
  38. package/dist/types/current/text/parseWebVtt.d.ts +16 -2
  39. package/dist/types/current/text/parseWebVtt.d.ts.map +1 -1
  40. package/dist/types/current/text/parseWebVtt.js +176 -48
  41. package/dist/types/current/text/pickPreferredTextTrack.d.ts +2 -1
  42. package/dist/types/current/text/pickPreferredTextTrack.d.ts.map +1 -1
  43. package/dist/types/current/text/pickPreferredTextTrack.js +6 -3
  44. package/dist/types/current/track/Track.d.ts +1 -1
  45. package/dist/types/current/track/dash/createDashFactories.d.ts +21 -10
  46. package/dist/types/current/track/dash/createDashFactories.d.ts.map +1 -1
  47. package/dist/types/current/track/dash/createDashFactories.js +9 -21
  48. package/dist/types/current/track/hls/createHlsFactories.d.ts +21 -10
  49. package/dist/types/current/track/hls/createHlsFactories.d.ts.map +1 -1
  50. package/dist/types/current/track/hls/createHlsFactories.js +9 -21
  51. package/dist/types/current/track/mse/MseTrack.d.ts +1 -2
  52. package/dist/types/current/track/mse/MseTrack.d.ts.map +1 -1
  53. package/dist/types/current/track/mse/MseTrack.js +3 -7
  54. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  55. package/dist/types/current/vinyl/VinylOptions.d.ts +18 -40
  56. package/dist/types/current/vinyl/VinylOptions.d.ts.map +1 -1
  57. package/dist/types/current/vinyl/VinylOptions.js +12 -11
  58. package/dist/types/current/vinyl/VinylPlayer.d.ts +0 -6
  59. package/dist/types/current/vinyl/VinylPlayer.d.ts.map +1 -1
  60. package/dist/types/current/vinyl/VinylPlayer.js +2 -23
  61. package/dist/types/current/vinyl/createVinylFactories.d.ts +32 -18
  62. package/dist/types/current/vinyl/createVinylFactories.d.ts.map +1 -1
  63. package/dist/types/current/vinyl/createVinylFactories.js +6 -0
  64. package/dist/types/ts3.7/index.d.ts +4 -0
  65. package/dist/types/ts3.7/streaming/AudioOptions.d.ts +39 -0
  66. package/dist/types/ts3.7/streaming/createDefaultMediaTimelineTransformer.d.ts +2 -2
  67. package/dist/types/ts3.7/text/HtmlTextTrackRenderer.d.ts +60 -0
  68. package/dist/types/ts3.7/text/SidecarTextTrackController.d.ts +65 -53
  69. package/dist/types/ts3.7/text/SidecarTextTrackLoader.d.ts +5 -0
  70. package/dist/types/ts3.7/text/TextTrack.d.ts +74 -20
  71. package/dist/types/ts3.7/text/TextTrackRenderer.d.ts +24 -0
  72. package/dist/types/ts3.7/text/mediaTextTrackProvider.d.ts +34 -0
  73. package/dist/types/ts3.7/text/parseWebVtt.d.ts +16 -2
  74. package/dist/types/ts3.7/text/pickPreferredTextTrack.d.ts +2 -1
  75. package/dist/types/ts3.7/track/Track.d.ts +1 -1
  76. package/dist/types/ts3.7/track/dash/createDashFactories.d.ts +21 -10
  77. package/dist/types/ts3.7/track/hls/createHlsFactories.d.ts +21 -10
  78. package/dist/types/ts3.7/track/mse/MseTrack.d.ts +1 -2
  79. package/dist/types/ts3.7/vinyl/VinylOptions.d.ts +18 -40
  80. package/dist/types/ts3.7/vinyl/VinylPlayer.d.ts +0 -6
  81. package/dist/types/ts3.7/vinyl/createVinylFactories.d.ts +32 -18
  82. package/dist/types/ts4.1/index.d.ts +4 -0
  83. package/dist/types/ts4.1/streaming/AudioOptions.d.ts +39 -0
  84. package/dist/types/ts4.1/streaming/createDefaultMediaTimelineTransformer.d.ts +2 -2
  85. package/dist/types/ts4.1/text/HtmlTextTrackRenderer.d.ts +60 -0
  86. package/dist/types/ts4.1/text/SidecarTextTrackController.d.ts +65 -53
  87. package/dist/types/ts4.1/text/SidecarTextTrackLoader.d.ts +5 -0
  88. package/dist/types/ts4.1/text/TextTrack.d.ts +74 -20
  89. package/dist/types/ts4.1/text/TextTrackRenderer.d.ts +24 -0
  90. package/dist/types/ts4.1/text/mediaTextTrackProvider.d.ts +34 -0
  91. package/dist/types/ts4.1/text/parseWebVtt.d.ts +16 -2
  92. package/dist/types/ts4.1/text/pickPreferredTextTrack.d.ts +2 -1
  93. package/dist/types/ts4.1/track/Track.d.ts +1 -1
  94. package/dist/types/ts4.1/track/dash/createDashFactories.d.ts +21 -10
  95. package/dist/types/ts4.1/track/hls/createHlsFactories.d.ts +21 -10
  96. package/dist/types/ts4.1/track/mse/MseTrack.d.ts +1 -2
  97. package/dist/types/ts4.1/vinyl/VinylOptions.d.ts +18 -40
  98. package/dist/types/ts4.1/vinyl/VinylPlayer.d.ts +0 -6
  99. package/dist/types/ts4.1/vinyl/createVinylFactories.d.ts +32 -18
  100. package/dist/types/ts4.7/index.d.ts +4 -0
  101. package/dist/types/ts4.7/streaming/AudioOptions.d.ts +39 -0
  102. package/dist/types/ts4.7/streaming/createDefaultMediaTimelineTransformer.d.ts +2 -2
  103. package/dist/types/ts4.7/text/HtmlTextTrackRenderer.d.ts +60 -0
  104. package/dist/types/ts4.7/text/SidecarTextTrackController.d.ts +65 -53
  105. package/dist/types/ts4.7/text/SidecarTextTrackLoader.d.ts +5 -0
  106. package/dist/types/ts4.7/text/TextTrack.d.ts +74 -20
  107. package/dist/types/ts4.7/text/TextTrackRenderer.d.ts +24 -0
  108. package/dist/types/ts4.7/text/mediaTextTrackProvider.d.ts +34 -0
  109. package/dist/types/ts4.7/text/parseWebVtt.d.ts +16 -2
  110. package/dist/types/ts4.7/text/pickPreferredTextTrack.d.ts +2 -1
  111. package/dist/types/ts4.7/track/Track.d.ts +1 -1
  112. package/dist/types/ts4.7/track/dash/createDashFactories.d.ts +21 -10
  113. package/dist/types/ts4.7/track/hls/createHlsFactories.d.ts +21 -10
  114. package/dist/types/ts4.7/track/mse/MseTrack.d.ts +1 -2
  115. package/dist/types/ts4.7/vinyl/VinylOptions.d.ts +18 -40
  116. package/dist/types/ts4.7/vinyl/VinylPlayer.d.ts +0 -6
  117. package/dist/types/ts4.7/vinyl/createVinylFactories.d.ts +32 -18
  118. package/dist/unit/types/current/index.d.ts +2 -0
  119. package/dist/unit/types/current/index.d.ts.map +1 -1
  120. package/dist/unit/types/current/index.js +2 -0
  121. package/dist/unit/types/current/streaming/MseTrack.test.js +13 -7
  122. package/dist/unit/types/current/streaming/createDefaultMediaTimelineTransformer.test.js +8 -4
  123. package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts +2 -0
  124. package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts.map +1 -0
  125. package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.js +231 -0
  126. package/dist/unit/types/current/text/SidecarTextTrackController.test.js +432 -333
  127. package/dist/unit/types/current/text/SidecarTextTrackLoader.test.js +29 -0
  128. package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts +2 -0
  129. package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts.map +1 -0
  130. package/dist/unit/types/current/text/mediaTextTrackProvider.test.js +86 -0
  131. package/dist/unit/types/current/text/parseWebVtt.test.js +187 -6
  132. package/dist/unit/types/current/text/pickPreferredTextTrack.test.js +12 -1
  133. package/dist/unit/types/current/track/dash/createDashFactories.test.js +1 -2
  134. package/dist/unit/types/current/track/hls/buildHlsMediaTimeline.test.js +1 -2
  135. package/dist/unit/types/current/track/hls/createHlsFactories.test.js +1 -2
  136. package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
  137. package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.js +102 -177
  138. package/dist/unit/types/current/vinyl/createVinylFactories.test.js +2 -0
  139. package/dist/vinylTestUtil/index.js +14 -8
  140. package/dist/vinylTestUtil/index.js.map +2 -2
  141. package/dist/vinylTestUtil/types/current/mock/player/MockVinylPlayerDependencies.d.ts +3 -2
  142. package/dist/vinylTestUtil/types/current/mock/player/MockVinylPlayerDependencies.d.ts.map +1 -1
  143. package/dist/vinylTestUtil/types/current/mock/player/MockVinylPlayerDependencies.js +5 -2
  144. package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts +3 -3
  145. package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts.map +1 -1
  146. package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.js +3 -3
  147. package/dist/vinylTestUtil/types/current/mock/track/dash/createMockDashDependencies.d.ts +1 -2
  148. package/dist/vinylTestUtil/types/current/mock/track/dash/createMockDashDependencies.d.ts.map +1 -1
  149. package/dist/vinylTestUtil/types/current/mock/track/dash/createMockDashDependencies.js +3 -2
  150. package/dist/vinylTestUtil/types/current/mock/track/hls/createMockHlsDependencies.d.ts +1 -2
  151. package/dist/vinylTestUtil/types/current/mock/track/hls/createMockHlsDependencies.d.ts.map +1 -1
  152. package/dist/vinylTestUtil/types/current/mock/track/hls/createMockHlsDependencies.js +3 -2
  153. package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
  154. package/dist/vinylTestUtil/types/ts3.7/mock/player/MockVinylPlayerDependencies.d.ts +3 -2
  155. package/dist/vinylTestUtil/types/ts3.7/mock/text/MockTextTrackController.d.ts +3 -3
  156. package/dist/vinylTestUtil/types/ts3.7/mock/track/dash/createMockDashDependencies.d.ts +1 -2
  157. package/dist/vinylTestUtil/types/ts3.7/mock/track/hls/createMockHlsDependencies.d.ts +1 -2
  158. package/dist/vinylTestUtil/types/ts4.1/mock/player/MockVinylPlayerDependencies.d.ts +3 -2
  159. package/dist/vinylTestUtil/types/ts4.1/mock/text/MockTextTrackController.d.ts +3 -3
  160. package/dist/vinylTestUtil/types/ts4.1/mock/track/dash/createMockDashDependencies.d.ts +1 -2
  161. package/dist/vinylTestUtil/types/ts4.1/mock/track/hls/createMockHlsDependencies.d.ts +1 -2
  162. package/dist/vinylTestUtil/types/ts4.7/mock/player/MockVinylPlayerDependencies.d.ts +3 -2
  163. package/dist/vinylTestUtil/types/ts4.7/mock/text/MockTextTrackController.d.ts +3 -3
  164. package/dist/vinylTestUtil/types/ts4.7/mock/track/dash/createMockDashDependencies.d.ts +1 -2
  165. package/dist/vinylTestUtil/types/ts4.7/mock/track/hls/createMockHlsDependencies.d.ts +1 -2
  166. package/docs/USAGE.md +82 -31
  167. package/package.json +12 -12
@@ -3,7 +3,8 @@ import { ObjectSchema } from '@amazon/vinyl-validation';
3
3
  import { CodecOverrides } from '../util/media/codecOverrides';
4
4
  import { RestrictableContentType } from '../streaming/MediaQualityMetadata';
5
5
  import { LoudnessNormalizationControllerImplOptions } from '../playback/loudness/LoudnessNormalizationControllerImplOptions';
6
- import { VttCueStyle } from '../text/VttCueStyle';
6
+ import { TextTrackControllerOptions } from '../text/TextTrack';
7
+ import { AudioOptions } from '../streaming/AudioOptions';
7
8
  export interface VinylOptions {
8
9
  /**
9
10
  * Configuration for the default adaptive bitrate selector.
@@ -11,40 +12,16 @@ export interface VinylOptions {
11
12
  readonly abr: QualitySelectorImplOptions;
12
13
  readonly loudnessNormalization: LoudnessNormalizationControllerImplOptions;
13
14
  /**
14
- * Preferred language(s) for audio content, as RFC 5646 codes (e.g. `'en'`,
15
- * `'ja'`, `'fr-CA'`). May be a single tag or an ordered list of tags —
16
- * earlier entries are preferred, with the best relatedness match kept for
17
- * each period (audio without a language tag is always kept). `null` (the
18
- * default) is NOT "no preference": it orders by the platform's
19
- * `navigator.languages`. To keep every language, this option is not the
20
- * mechanism — omit language content or pass a tag matching all.
21
- */
22
- readonly preferredAudioLanguage: string | readonly string[] | null;
23
- /**
24
- * Preferred language(s) for text tracks (subtitles / closed captions), as
25
- * RFC 5646 codes (e.g. `'en'`, `'ja'`, `'fr-CA'`). May be a single tag or
26
- * an ordered list of tags — earlier entries are preferred, with the best
27
- * relatedness match chosen among the discovered text tracks. When set, the
28
- * matching text track is selected automatically and the choice carries
29
- * across track changes (e.g. across an ad break), mirroring how
30
- * {@link preferredAudioLanguage} drives audio selection.
15
+ * Audio (language / audio-description) configuration. See
16
+ * {@link AudioOptions}.
31
17
  *
32
- * Unlike audio, `null` (the default) means *no caption preference*: it does
33
- * NOT fall back to `navigator.languages` and does NOT force captions on —
34
- * forced narrative subtitles still auto-display as usual. Setting it to a
35
- * language turns captions on in that language; setting it back to `null`
36
- * after a prior selection turns captions off.
37
- */
38
- readonly preferredTextLanguage: string | readonly string[] | null;
39
- /**
40
- * Opt in to audio-description (a.k.a. described-video / DVS) audio: audio
41
- * renditions carrying an accessibility "describes video" characteristic that
42
- * narrate on-screen action. `false` (the default) keeps them out of the
43
- * automatic default-audio selection — they are chosen only when this is set.
44
- * When `true`, a description rendition is preferred where one exists for the
45
- * selected language. Changing this reselects audio immediately.
18
+ * The default is `{ selection: { language: null, descriptive: false } }`:
19
+ * audio is ordered by the platform's `navigator.languages` and
20
+ * audio-description renditions are excluded. Set `selection.language` to
21
+ * prefer specific language(s) and `selection.descriptive` to `true` to opt
22
+ * into described audio.
46
23
  */
47
- readonly preferDescriptiveAudio: boolean;
24
+ readonly audio: AudioOptions;
48
25
  /**
49
26
  * Explicit codec allow/deny overrides that bypass browser support
50
27
  * detection. Keys are RFC 6381 codec strings or prefixes (e.g. `"hvc1"`),
@@ -68,15 +45,16 @@ export interface VinylOptions {
68
45
  */
69
46
  readonly allowedContentTypes: readonly RestrictableContentType[] | null;
70
47
  /**
71
- * Layout style applied to rendered WebVTT cues (the settable `VTTCue`
72
- * positioning properties: size, line, position, align, etc.). Applied to
73
- * each cue as it is added, on platforms that support `VTTCue`.
48
+ * Text-track (subtitles / closed captions) configuration: enable/disable
49
+ * and the selection criteria. See {@link TextTrackControllerOptions}.
74
50
  *
75
- * Defaults to `{ size: 90 }`, insetting the cue box from the full video
76
- * width so long lines don't clip at the screen edges in fullscreen (which
77
- * `::cue` CSS cannot fix). Set to `null` to keep the browser defaults.
51
+ * The default is `{ enabled: 'forced' }`: with no
52
+ * explicit language, the platform's `navigator.languages` are preferred,
53
+ * showing only forced (narrative) tracks. Set `enabled` to `'on'` for full
54
+ * subtitle tracks or `'off'` to render nothing;
55
+ * `selection.language`/`selection.id` choose a specific rendition.
78
56
  */
79
- readonly textCueStyle: VttCueStyle | null;
57
+ readonly text: TextTrackControllerOptions;
80
58
  }
81
59
  export declare const defaultVinylOptions: VinylOptions;
82
60
  export declare const vinylOptionsValidator: ObjectSchema<VinylOptions>;
@@ -156,12 +156,6 @@ export declare class VinylPlayer<TrackLoadOptionsType extends TrackLoadOptions =
156
156
  getPlaybackQuality(contentType: ContentType): MediaQualityMetadata | null;
157
157
  get textTracks(): readonly TextTrackInfo[];
158
158
  get activeTextTrack(): (TextTrackInfo | null);
159
- /**
160
- * Selects the text track with the given id, or clears the active text
161
- * track when called with null. No-op when the current track does not
162
- * surface text tracks or the id is unknown.
163
- */
164
- setActiveTextTrack(id: string | null): void;
165
159
  private emitTextTrackChangeEventsFor;
166
160
  get currentTrackAds(): (TrackAds | null);
167
161
  get currentAdBreak(): (AdBreakInfo | null);
@@ -12,6 +12,8 @@ import { TrackControllerImpl } from '../track/TrackController';
12
12
  import { VinylPatchOptions } from './VinylPatchOptions';
13
13
  import { QualitySelectorImplOptions } from '../streaming/abr/QualitySelectorImpl';
14
14
  import { AdControllerImpl, AdControllerImplDeps, AdControllerImplOptions } from '../ad/AdControllerImpl';
15
+ import { MediaTextTrackProvider } from '../text/mediaTextTrackProvider';
16
+ import { TextTrackRenderer } from '../text/TextTrackRenderer';
15
17
  import { DrmOptions } from '../drm/DrmOptions';
16
18
  import { commonEmeFactory } from '../drm/commonEme/CommonEmeFactory';
17
19
  import { DrmControllerImpl, DrmControllerImplDeps } from '../drm/DrmControllerImpl';
@@ -33,6 +35,12 @@ export interface VinylDependencyOptions {
33
35
  * The media element.
34
36
  */
35
37
  readonly media: HTMLMediaElement;
38
+ /**
39
+ * Optional renderer for text-track cues (an HTML overlay). When provided,
40
+ * captions are painted by the renderer and the DOM text track is kept
41
+ * `'hidden'`; without one they render natively. See `TextTrackRenderer`.
42
+ */
43
+ readonly textTrackRenderer?: TextTrackRenderer;
36
44
  /**
37
45
  * Flags for patches that should be applied browser-specifically.
38
46
  * These will be defaulted based on the user-agent.
@@ -80,6 +88,10 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
80
88
  readonly patched: HTMLMediaElement;
81
89
  };
82
90
  }) => HTMLMediaElement;
91
+ textTrackProvider: (deps: {
92
+ readonly media: HTMLMediaElement;
93
+ }) => MediaTextTrackProvider;
94
+ textTrackRenderer: () => TextTrackRenderer | null;
83
95
  playbackController: (deps: PlaybackControllerImplDeps) => PlaybackControllerImpl;
84
96
  playbackSource: (deps: PlaybackSourceImplDeps) => PlaybackSourceImpl;
85
97
  loudnessNormalizationController: (deps: {
@@ -120,15 +132,12 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
120
132
  qualitySelector: (deps: {
121
133
  options: ObservableValue<Pick<VinylOptions, "abr">>;
122
134
  }) => import("..").QualitySelectorImpl;
123
- preferredAudioLanguage: (deps: {
124
- options: ObservableValue<Pick<VinylOptions, "preferredAudioLanguage">>;
125
- }) => ObservableValue<string | readonly string[] | null>;
135
+ audio: (deps: {
136
+ options: ObservableValue<Pick<VinylOptions, "audio">>;
137
+ }) => ObservableValue<import("..").AudioOptions>;
126
138
  allowedContentTypes: (deps: {
127
139
  options: ObservableValue<Pick<VinylOptions, "allowedContentTypes">>;
128
140
  }) => ObservableValue<readonly import("..").RestrictableContentType[] | null>;
129
- preferDescriptiveAudio: (deps: {
130
- options: ObservableValue<Pick<VinylOptions, "preferDescriptiveAudio">>;
131
- }) => ObservableValue<boolean>;
132
141
  abr: (deps: {
133
142
  options: ObservableValue<Pick<VinylOptions, "abr">>;
134
143
  }) => ObservableValue<QualitySelectorImplOptions>;
@@ -138,11 +147,13 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
138
147
  }) => ObservableValue<Promise<import("..").MediaTimeline>>;
139
148
  mediaTimelineTransformed: typeof import("..").createDefaultMediaTimelineTransformer;
140
149
  textTrackController: (deps: {
141
- readonly media: HTMLMediaElement;
150
+ readonly textTrackProvider: MediaTextTrackProvider;
151
+ readonly textTrackRenderer: TextTrackRenderer | null;
152
+ readonly playbackController: import("..").PlaybackController;
142
153
  readonly manifestTransformed: ObservableValue<Promise<import("..").DashManifestData>>;
143
- readonly options: ObservableValue<Pick<VinylOptions, "preferredTextLanguage" | "textCueStyle">>;
154
+ readonly options: ObservableValue<Pick<VinylOptions, "text">>;
144
155
  }) => import("..").SidecarTextTrackController;
145
- options: import("@amazon/vinyl-di").Factory<ObservableValue<Pick<VinylOptions, "abr" | "preferredAudioLanguage" | "preferredTextLanguage" | "preferDescriptiveAudio" | "allowedContentTypes" | "textCueStyle">>>;
156
+ options: import("@amazon/vinyl-di").Factory<ObservableValue<Pick<VinylOptions, "audio" | "text" | "abr" | "allowedContentTypes">>>;
146
157
  playbackController: import("@amazon/vinyl-di").Factory<import("..").PlaybackController>;
147
158
  playbackSource: import("@amazon/vinyl-di").Factory<import("..").PlaybackSource>;
148
159
  drmKeySystemResolver: import("@amazon/vinyl-di").Factory<import("..").DrmKeySystemResolver>;
@@ -150,6 +161,8 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
150
161
  drmController: import("@amazon/vinyl-di").Factory<import("..").DrmController>;
151
162
  capabilities: import("@amazon/vinyl-di").Factory<import("..").Capabilities>;
152
163
  media: import("@amazon/vinyl-di").Factory<HTMLMediaElement>;
164
+ textTrackProvider: import("@amazon/vinyl-di").Factory<MediaTextTrackProvider>;
165
+ textTrackRenderer: import("@amazon/vinyl-di").Factory<TextTrackRenderer | null>;
153
166
  adController: import("@amazon/vinyl-di").Factory<import("..").AdController>;
154
167
  };
155
168
  createHlsFactories: (deps: import("..").HlsFactoryDeps) => (loadOptions: import("..").HlsTrackLoadOptions) => {
@@ -175,15 +188,12 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
175
188
  qualitySelector: (deps: {
176
189
  options: ObservableValue<Pick<VinylOptions, "abr">>;
177
190
  }) => import("..").QualitySelectorImpl;
178
- preferredAudioLanguage: (deps: {
179
- options: ObservableValue<Pick<VinylOptions, "preferredAudioLanguage">>;
180
- }) => ObservableValue<string | readonly string[] | null>;
191
+ audio: (deps: {
192
+ options: ObservableValue<Pick<VinylOptions, "audio">>;
193
+ }) => ObservableValue<import("..").AudioOptions>;
181
194
  allowedContentTypes: (deps: {
182
195
  options: ObservableValue<Pick<VinylOptions, "allowedContentTypes">>;
183
196
  }) => ObservableValue<readonly import("..").RestrictableContentType[] | null>;
184
- preferDescriptiveAudio: (deps: {
185
- options: ObservableValue<Pick<VinylOptions, "preferDescriptiveAudio">>;
186
- }) => ObservableValue<boolean>;
187
197
  abr: (deps: {
188
198
  options: ObservableValue<Pick<VinylOptions, "abr">>;
189
199
  }) => ObservableValue<QualitySelectorImplOptions>;
@@ -192,11 +202,13 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
192
202
  }) => ObservableValue<Promise<import("..").MediaTimeline>>;
193
203
  mediaTimelineTransformed: typeof import("..").createDefaultMediaTimelineTransformer;
194
204
  textTrackController: (deps: {
195
- readonly media: HTMLMediaElement;
205
+ readonly textTrackProvider: MediaTextTrackProvider;
206
+ readonly textTrackRenderer: TextTrackRenderer | null;
207
+ readonly playbackController: import("..").PlaybackController;
196
208
  readonly manifestTransformed: ObservableValue<Promise<import("..").HlsManifestData>>;
197
- readonly options: ObservableValue<Pick<VinylOptions, "preferredTextLanguage" | "textCueStyle">>;
209
+ readonly options: ObservableValue<Pick<VinylOptions, "text">>;
198
210
  }) => import("..").SidecarTextTrackController;
199
- options: import("@amazon/vinyl-di").Factory<ObservableValue<Pick<VinylOptions, "abr" | "preferredAudioLanguage" | "preferredTextLanguage" | "preferDescriptiveAudio" | "allowedContentTypes" | "textCueStyle">>>;
211
+ options: import("@amazon/vinyl-di").Factory<ObservableValue<Pick<VinylOptions, "audio" | "text" | "abr" | "allowedContentTypes">>>;
200
212
  playbackController: import("@amazon/vinyl-di").Factory<import("..").PlaybackController>;
201
213
  playbackSource: import("@amazon/vinyl-di").Factory<import("..").PlaybackSource>;
202
214
  drmKeySystemResolver: import("@amazon/vinyl-di").Factory<import("..").DrmKeySystemResolver>;
@@ -204,6 +216,8 @@ export declare function createVinylFactories(options: VinylDependencyOptions): {
204
216
  drmController: import("@amazon/vinyl-di").Factory<import("..").DrmController>;
205
217
  capabilities: import("@amazon/vinyl-di").Factory<import("..").Capabilities>;
206
218
  media: import("@amazon/vinyl-di").Factory<HTMLMediaElement>;
219
+ textTrackProvider: import("@amazon/vinyl-di").Factory<MediaTextTrackProvider>;
220
+ textTrackRenderer: import("@amazon/vinyl-di").Factory<TextTrackRenderer | null>;
207
221
  adController: import("@amazon/vinyl-di").Factory<import("..").AdController>;
208
222
  };
209
223
  };
@@ -58,6 +58,7 @@ export * from './playback/PlaybackSourceImpl';
58
58
  export * from './playback/ReadonlyPlaybackController';
59
59
  export * from './streaming/abr/QualitySelector';
60
60
  export * from './streaming/abr/QualitySelectorImpl';
61
+ export * from './streaming/AudioOptions';
61
62
  export * from './streaming/buffering/BufferingController';
62
63
  export * from './streaming/buffering/codecDenylist';
63
64
  export * from './streaming/buffering/error/SourceBufferError';
@@ -87,11 +88,14 @@ export * from './streaming/StreamingEventMap';
87
88
  export * from './streaming/util/segment';
88
89
  export * from './text/discoverDashTextTracks';
89
90
  export * from './text/discoverHlsTextTracks';
91
+ export * from './text/HtmlTextTrackRenderer';
92
+ export * from './text/mediaTextTrackProvider';
90
93
  export * from './text/parseWebVtt';
91
94
  export * from './text/pickPreferredTextTrack';
92
95
  export * from './text/SidecarTextTrackController';
93
96
  export * from './text/SidecarTextTrackLoader';
94
97
  export * from './text/TextTrack';
98
+ export * from './text/TextTrackRenderer';
95
99
  export * from './text/VttCueStyle';
96
100
  export * from './track/AutoResetController';
97
101
  export * from './track/createSegmentDataProvider';
@@ -0,0 +1,39 @@
1
+ import type { ObjectSchema } from '@amazon/vinyl-validation';
2
+ /**
3
+ * Criteria used to pick which audio rendition to play.
4
+ */
5
+ export interface AudioSelection {
6
+ /**
7
+ * Preferred language(s) for audio content, as RFC 5646 codes (e.g. `'en'`,
8
+ * `'ja'`, `'fr-CA'`). May be a single tag or an ordered list of tags —
9
+ * earlier entries are preferred, with the best relatedness match kept for
10
+ * each period (audio without a language tag is always kept). `null` (the
11
+ * default) is NOT "no preference": it orders by the platform's
12
+ * `navigator.languages`. To keep every language, this option is not the
13
+ * mechanism — omit language content or pass a tag matching all.
14
+ */
15
+ readonly language?: string | readonly string[] | null;
16
+ /**
17
+ * Opt in to audio-description (a.k.a. described-video / DVS) audio: audio
18
+ * renditions carrying an accessibility "describes video" characteristic that
19
+ * narrate on-screen action. `false` (the default) keeps them out of the
20
+ * automatic default-audio selection — they are chosen only when this is set.
21
+ * When `true`, a description rendition is preferred where one exists for the
22
+ * selected language. Changing this reselects audio immediately.
23
+ */
24
+ readonly descriptive?: boolean;
25
+ }
26
+ /**
27
+ * Declarative audio configuration. Mirrors `VinylOptions.text`: the audio
28
+ * rendition is chosen from {@link selection}; changing it reselects audio
29
+ * immediately.
30
+ */
31
+ export interface AudioOptions {
32
+ /**
33
+ * The audio selection criteria (language / descriptive).
34
+ */
35
+ readonly selection?: AudioSelection;
36
+ }
37
+ export declare const defaultAudioOptions: AudioOptions;
38
+ export declare const audioOptionsValidator: ObjectSchema<AudioOptions>;
39
+ //# sourceMappingURL=AudioOptions.d.ts.map
@@ -3,13 +3,13 @@ import type { Capabilities } from '../client/Capabilities';
3
3
  import type { DrmController } from '../drm/DrmController';
4
4
  import type { MediaTimeline } from './MediaTimeline';
5
5
  import type { CodecOverrides } from '../util/media/codecOverrides';
6
+ import type { AudioOptions } from './AudioOptions';
6
7
  export interface DefaultMediaTimelineTransformerDeps {
7
8
  readonly capabilities: Capabilities;
8
9
  readonly drmController: DrmController;
9
10
  readonly mediaTimeline: ObservableValue<Promise<MediaTimeline>>;
10
11
  readonly options: ObservableValue<{
11
- readonly preferredAudioLanguage: string | readonly string[] | null;
12
- readonly preferDescriptiveAudio?: boolean;
12
+ readonly audio: AudioOptions;
13
13
  readonly codecOverrides?: CodecOverrides;
14
14
  }>;
15
15
  }
@@ -0,0 +1,60 @@
1
+ import type { Disposable } from '@amazon/vinyl-util';
2
+ import type { TextTrackRenderer } from './TextTrackRenderer';
3
+ /**
4
+ * The subset of a `VTTCue`'s positioning properties {@link computeCueLayout}
5
+ * reads. A native `VTTCue` satisfies this; a plain `TextTrackCue` (platforms
6
+ * without `VTTCue`) leaves them undefined and falls back to defaults.
7
+ */
8
+ export interface CueGeometry {
9
+ readonly align?: string | null;
10
+ readonly line?: number | AutoKeyword;
11
+ readonly lineAlign?: LineAlignSetting;
12
+ readonly position?: number | AutoKeyword;
13
+ readonly positionAlign?: PositionAlignSetting;
14
+ readonly size?: number;
15
+ readonly snapToLines?: boolean;
16
+ readonly vertical?: DirectionSetting;
17
+ }
18
+ /** Inline styles (camelCase CSS properties) to apply to a rendered cue box. */
19
+ export type CueLayout = Record<string, string>;
20
+ /**
21
+ * Maps a cue's WebVTT positioning settings to inline CSS. Pure and DOM-free so
22
+ * the (branchy) placement logic is unit-testable in isolation.
23
+ *
24
+ * A cue with neither `line` nor `position` set flows in the renderer's
25
+ * bottom-anchored, centered container (the common subtitle case). Otherwise it
26
+ * is absolutely positioned: `size` → width, `position`/`positionAlign` →
27
+ * horizontal, `line`/`lineAlign`/`snapToLines` → vertical (percentage lines, or
28
+ * whole rows counted from the bottom for negative integers), `align` → text
29
+ * alignment, `vertical` → writing mode.
30
+ */
31
+ export declare function computeCueLayout(cue: CueGeometry): CueLayout;
32
+ /**
33
+ * Renders a cue's text payload as safe HTML. Text is escaped (so it can't
34
+ * inject nodes); newlines become `<br>`; and WebVTT cue tags are converted:
35
+ * `<c.foo>`→`<span class="foo">`, `<i>/<b>/<u>/<ruby>/<rt>` pass through,
36
+ * `<v Name>`→`<span title>`, `<lang xx>`→`<span lang>`, timestamp tags are
37
+ * dropped. Class-based styling requires matching app CSS (STYLE blocks in the
38
+ * VTT are not applied).
39
+ */
40
+ export declare function renderCueText(text: string): string;
41
+ /**
42
+ * A {@link TextTrackRenderer} that paints cues as HTML into {@link element}.
43
+ * Mount `element` over the video; it stacks cues at the bottom, centered, and
44
+ * positions any cue that carries explicit WebVTT settings. The DOM track is
45
+ * expected to be `'hidden'` so only this renderer paints.
46
+ */
47
+ export declare class HtmlTextTrackRenderer implements TextTrackRenderer, Disposable {
48
+ /** The overlay container to mount over the video. */
49
+ readonly element: HTMLElement;
50
+ private track;
51
+ private readonly styleElement;
52
+ private readonly onCueChange;
53
+ constructor();
54
+ setTextTrack(track: TextTrack | null): void;
55
+ setStyles(styles: readonly string[]): void;
56
+ dispose(): void;
57
+ private renderActiveCues;
58
+ private createCueBox;
59
+ }
60
+ //# sourceMappingURL=HtmlTextTrackRenderer.d.ts.map
@@ -1,92 +1,104 @@
1
1
  import type { Maybe, RequestInitOptions } from '@amazon/vinyl-util';
2
2
  import { EventHostImpl } from '@amazon/vinyl-util';
3
- import type { TextTrackController, TextTrackEventMap, TextTrackInfo } from './TextTrack';
3
+ import type { TextTrackController, TextTrackControllerOptions, TextTrackEventMap, TextTrackInfo } from './TextTrack';
4
4
  import type { ObservableValue } from '@amazon/vinyl-observable';
5
- import type { VttCueStyle } from './VttCueStyle';
5
+ import type { MediaTextTrackProvider } from './mediaTextTrackProvider';
6
+ import type { ReadonlyPlaybackController } from '../playback/ReadonlyPlaybackController';
7
+ import type { TextTrackRenderer } from './TextTrackRenderer';
6
8
  export interface SidecarTextTrackControllerDeps {
7
9
  /**
8
- * The HTML media element on which to attach the in-band TextTrack
9
- * representation. Cues for the active text track are added to a TextTrack
10
- * created via `media.addTextTrack`. Setting this to null disables DOM
11
- * integration; cues are still loaded and surfaced via events.
10
+ * Hands out (memoized) DOM text tracks. Text tracks can only be created on a
11
+ * media element and never removed, so the provider reuses one track per
12
+ * rendition rather than accumulating them.
12
13
  */
13
- readonly media: HTMLMediaElement | null;
14
+ readonly textTrackProvider: MediaTextTrackProvider;
14
15
  /**
15
16
  * Optional request init options forwarded with each VTT fetch (e.g. CORS).
16
17
  */
17
18
  readonly requestInit?: Maybe<RequestInitOptions>;
18
19
  /**
19
- * Preferred caption language(s), most-preferred first. A non-null
20
- * preference auto-selects the best-matching track, re-applied as the track
21
- * list changes. Changing the preference to null clears the selection
22
- * (captions off). An initial null (or an absent observable) is "no
23
- * preference": forced tracks still auto-select until the app makes an
24
- * explicit choice — it does not force captions off.
20
+ * The discovered text tracks, re-emitted whenever the manifest changes.
25
21
  */
26
- readonly preferredTextLanguage?: ObservableValue<string | readonly string[] | null>;
22
+ readonly textTracks: ObservableValue<Promise<readonly TextTrackInfo[]>>;
27
23
  /**
28
- * Layout style applied to each rendered VTTCue (see
29
- * {@link VttCueStyle}). Read per cue as it is appended, so a change affects
30
- * subsequently-rendered cues. Absent means no styling (browser defaults).
24
+ * Declarative selection / rendering configuration. Re-applied on change.
31
25
  */
32
- readonly cueStyle?: ObservableValue<VttCueStyle | null>;
26
+ readonly options: ObservableValue<TextTrackControllerOptions>;
27
+ /**
28
+ * Supplies the current playhead used to fetch caption segments in a window
29
+ * around it.
30
+ */
31
+ readonly playbackController: ReadonlyPlaybackController;
32
+ /**
33
+ * Optional renderer that paints cues itself (HTML overlay). When provided,
34
+ * the DOM text track is kept `'hidden'` (timing only) and the renderer is
35
+ * handed the active track; without one, the track renders natively
36
+ * (`'showing'`).
37
+ */
38
+ readonly textTrackRenderer?: Maybe<TextTrackRenderer>;
33
39
  }
40
+ /**
41
+ * Selects the text track that matches the given options, or null for none.
42
+ *
43
+ * The `enabled` mode gates everything: `'off'` renders nothing (default is
44
+ * `'forced'`). Otherwise an explicit {@link TextTrackSelection.id} wins; else
45
+ * the best language match is chosen among tracks filtered by kind and
46
+ * forced-ness. Forced-ness comes from {@link TextTrackSelection.forced} when
47
+ * set, otherwise from the mode (`'forced'` keeps only forced tracks, `'on'`
48
+ * only full tracks).
49
+ *
50
+ * @private
51
+ */
52
+ export declare function resolveSelectedTrack(tracks: readonly TextTrackInfo[], options: TextTrackControllerOptions): TextTrackInfo | null;
34
53
  /**
35
54
  * Manages a sidecar WebVTT-based text track lifecycle:
36
55
  *
37
- * - holds a discovered list of {@link TextTrackInfo}
38
- * - on activation, fetches the chosen track's WebVTT and pushes cues to a
39
- * `TextTrack` created on the `HTMLMediaElement`
40
- * - clears any previously activated cues when switching tracks
56
+ * - tracks the discovered {@link TextTrackInfo} list (from the `textTracks`
57
+ * observable) and the current selection (from the `options` observable)
58
+ * - on selection, fetches the chosen track's WebVTT and pushes cues to a DOM
59
+ * `TextTrack` obtained from the {@link MediaTextTrackProvider}
60
+ * - clears cues and hides the DOM track when the selection changes or clears
41
61
  *
42
- * The controller is intentionally agnostic of HLS/DASH discovery details. Its
43
- * input is whatever list of {@link TextTrackInfo} entries the manifest layer
44
- * decides to surface.
62
+ * The controller is agnostic of HLS/DASH discovery details; its inputs are the
63
+ * observables supplied by the manifest layer.
45
64
  */
46
65
  export declare class SidecarTextTrackController extends EventHostImpl<TextTrackEventMap> implements TextTrackController {
47
66
  private readonly deps;
48
67
  get [Symbol.toStringTag](): string;
49
- private _tracks;
50
68
  private _active;
51
- private _domTrack;
52
- private loadAbort;
53
- private _userSelected;
54
- private readonly preferredLanguageSub;
69
+ private _tracks;
70
+ private _activeTextTrack;
71
+ private _ref;
72
+ private readonly loadAbort;
73
+ private readonly disposer;
55
74
  constructor(deps: SidecarTextTrackControllerDeps);
56
75
  get textTracks(): readonly TextTrackInfo[];
57
76
  get activeTextTrack(): (TextTrackInfo | null);
77
+ get active(): boolean;
78
+ get disposed(): boolean;
58
79
  /**
59
- * Replaces the discovered text track list. Emits `textTracksChange`. If
60
- * the previously active track is no longer present, clears the active
61
- * selection and emits `activeTextTrackChange`.
62
- */
63
- setTextTracks(tracks: readonly TextTrackInfo[]): void;
64
- setActiveTextTrack(id: string | null): void;
65
- /**
66
- * Selects the track best matching the preferred language(s), or clears the
67
- * selection when the preference is null or nothing matches.
80
+ * Replaces the discovered track list, emits `textTracksChange`, then
81
+ * re-applies the current selection against the new list.
68
82
  */
69
- private applyPreferredLanguage;
83
+ private setTracks;
70
84
  /**
71
- * Applies a selection by id (null clears it) without marking it as an
72
- * explicit user choice. Shared by setActiveTextTrack and forced auto-select.
85
+ * Recomputes the selection from the current options and track list,
86
+ * emitting `activeTextTrackChange` on change and (re)rendering when active.
73
87
  */
74
- private selectById;
88
+ private refreshSelection;
89
+ deactivate(): void;
90
+ activate(): void;
91
+ private startLoad;
92
+ private appendCues;
75
93
  /**
76
- * The forced track to auto-select, or null. Prefers the default track's
77
- * language, else the first forced track.
94
+ * Clears cues from the current DOM track and hides it, keeping the track for
95
+ * later reuse via the provider.
78
96
  */
79
- private pickForcedTrack;
80
- suspend(): void;
81
- resume(): void;
97
+ private hideCurrent;
82
98
  /**
83
- * Cancels any in-flight load, clears the DOM TextTrack, and resets state.
99
+ * Cancels any in-flight load, hides the DOM text track, and resets state.
84
100
  * Called by the host when the underlying media is unloaded.
85
101
  */
86
102
  dispose(): void;
87
- private startLoad;
88
- private ensureDomTrack;
89
- private appendCues;
90
- private clearDomTrack;
91
103
  }
92
104
  //# sourceMappingURL=SidecarTextTrackController.d.ts.map
@@ -24,6 +24,11 @@ export interface LoadWebVttCuesOptions {
24
24
  * per HLS segment, or once for a direct `.vtt` document.
25
25
  */
26
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>;
27
32
  /**
28
33
  * Returns the current playback time (seconds on the presentation
29
34
  * timeline). Used to fetch caption segments in a window around the