@volcengine/veplayer 1.20.1-rc.3 → 1.20.1-rc.5

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/lite.d.ts CHANGED
@@ -22,6 +22,294 @@ export declare enum UmdKeys {
22
22
  }
23
23
  /** Resolved UMD module values keyed by their public UMD key. */
24
24
  export type UmdModules = Partial<Record<UmdKeys, unknown>>;
25
+ /** {zh}
26
+ * @brief CSS 声明,支持驼峰、短横线属性名和 CSS 自定义属性。长度应包含单位。
27
+ */
28
+ /** {en}
29
+ * @brief CSS declarations accepting camelCase, hyphenated names, and custom properties. Include units for lengths.
30
+ */
31
+ export type SubtitleCss = Readonly<Record<string, string | number>>;
32
+ /** {zh}
33
+ * @brief 字幕背景框和文字的统一样式。
34
+ */
35
+ /** {en}
36
+ * @brief Shared styles for the subtitle background box and text.
37
+ */
38
+ export interface ISubtitleStyleConfig {
39
+ cueBoxStyle?: SubtitleCss;
40
+ textStyle?: SubtitleCss;
41
+ }
42
+ /** {zh}
43
+ * @brief 单条字幕的样式,可覆盖全局配置。
44
+ */
45
+ /** {en}
46
+ * @brief Styles for a single cue, overriding shared configuration.
47
+ */
48
+ export interface ISubtitleCueStyle extends ISubtitleStyleConfig {
49
+ wrapperStyle?: SubtitleCss;
50
+ }
51
+ /** {zh}
52
+ * @brief 可编辑的外层定位容器和背景框,文字位于 `.veplayer-webvtt-cue-text`。
53
+ */
54
+ /** {en}
55
+ * @brief Editable positioning wrapper and background box containing `.veplayer-webvtt-cue-text`.
56
+ */
57
+ export interface ISubtitleStyleBox {
58
+ div: HTMLElement;
59
+ cueDiv: HTMLElement;
60
+ }
61
+ /** {zh}
62
+ * @brief WebVTT 字幕及定位设置。起止时间以秒为单位。
63
+ */
64
+ /** {en}
65
+ * @brief A WebVTT cue and its layout settings. Times are in seconds.
66
+ */
67
+ export interface ISubtitleCue {
68
+ readonly id: string;
69
+ readonly text: string;
70
+ readonly classes: readonly string[];
71
+ readonly startTime: number;
72
+ readonly endTime: number;
73
+ readonly region_id?: string;
74
+ readonly line?: number;
75
+ readonly snapToLines: boolean;
76
+ readonly lineAlign?: "start" | "center" | "end";
77
+ readonly position?: number;
78
+ readonly positionAlign?: "line-left" | "center" | "line-right";
79
+ readonly size?: number;
80
+ readonly align: "start" | "center" | "end" | "left" | "right";
81
+ readonly vertical?: "rl" | "lr";
82
+ }
83
+ /** {zh}
84
+ * @brief WebVTT 区域的尺寸和锚点。
85
+ */
86
+ /** {en}
87
+ * @brief WebVTT region dimensions and anchors.
88
+ */
89
+ export interface ISubtitleRegion {
90
+ readonly width: number;
91
+ readonly lines: number;
92
+ readonly regionAnchorX: number;
93
+ readonly regionAnchorY: number;
94
+ readonly viewportAnchorX: number;
95
+ readonly viewportAnchorY: number;
96
+ readonly scroll: "" | "up";
97
+ }
98
+ /** {zh}
99
+ * @brief 按类名索引的 WebVTT 样式块。`veplayer-webvtt-cue-text` 表示默认 `::cue`。
100
+ */
101
+ /** {en}
102
+ * @brief A WebVTT style block keyed by class name. `veplayer-webvtt-cue-text` represents the default `::cue`.
103
+ */
104
+ export type SubtitleStyleBlock = Readonly<Record<string, SubtitleCss>>;
105
+ /** {zh}
106
+ * @brief 字幕编辑回调的上下文。索引和总数以当前渲染批次为准。
107
+ */
108
+ /** {en}
109
+ * @brief Subtitle editor context. Cue indexes and counts refer to the current render batch.
110
+ */
111
+ export type SubtitleEditorContext = {
112
+ type: "cue";
113
+ cue: ISubtitleCue;
114
+ cueIndex: number;
115
+ totalCues: number;
116
+ containerBox: DOMRectReadOnly;
117
+ paddedOverlay: HTMLElement;
118
+ } | {
119
+ type: "region";
120
+ regionContainer: HTMLElement;
121
+ regionData: Readonly<{
122
+ id: string;
123
+ region: ISubtitleRegion;
124
+ }>;
125
+ overlayEl: HTMLElement;
126
+ } | {
127
+ type: "style";
128
+ styles: readonly SubtitleStyleBlock[];
129
+ overlayEl: HTMLElement;
130
+ };
131
+ /** {zh}
132
+ * @brief WebVTT 编辑回调。仅 cue 回调提供 styleBox。
133
+ * @notes cue 和 region 可直接改 DOM 或返回样式。style 返回对象按类名及属性合并,返回数组替换全部样式。
134
+ */
135
+ /** {en}
136
+ * @brief WebVTT editor. Only the cue callback receives a style box.
137
+ * @notes Cue and region callbacks may edit DOM or return styles. Return an object from style to merge declarations by class, or an array to replace all styles.
138
+ */
139
+ export type SubtitleEditor = (styleBox: ISubtitleStyleBox | undefined, context: SubtitleEditorContext) => ISubtitleCueStyle | SubtitleCss | SubtitleStyleBlock | readonly SubtitleStyleBlock[] | void;
140
+ interface ISubtitleStyle {
141
+ /** {zh}
142
+ * @brief 点播外挂 WebVTT 字幕的背景框样式。传入空对象可启用 WebVTT 渲染。
143
+ * @example Subtitle: { style: { cueBoxStyle: { borderRadius: '8px' } } }
144
+ */
145
+ /** {en}
146
+ * @brief Styles the external VOD WebVTT cue background box. An empty object enables WebVTT rendering.
147
+ * @example Subtitle: { style: { cueBoxStyle: { borderRadius: '8px' } } }
148
+ */
149
+ cueBoxStyle?: SubtitleCss;
150
+ /** {zh}
151
+ * @brief 点播外挂 WebVTT 字幕的文字样式。传入空对象可启用 WebVTT 渲染。
152
+ * @example Subtitle: { style: { textStyle: { display: 'block', lineHeight: 'normal' } } }
153
+ */
154
+ /** {en}
155
+ * @brief Styles external VOD WebVTT cue text. An empty object enables WebVTT rendering.
156
+ * @example Subtitle: { style: { textStyle: { display: 'block', lineHeight: 'normal' } } }
157
+ */
158
+ textStyle?: SubtitleCss;
159
+ /** {zh}
160
+ * @brief 是否跟随控制栏调整位置。
161
+ * @default false
162
+ * @type {boolean | null}
163
+ * @memberof ISubtitleStyle
164
+ */
165
+ /** {en}
166
+ * @brief Whether position follows the control bar.
167
+ * @default false
168
+ * @type {boolean | null}
169
+ * @memberof ISubtitleStyle
170
+ */
171
+ follow?: boolean;
172
+ /** {zh}
173
+ * @brief 字体显示模式,默认如下;
174
+ * - `"stroke"`:空心字体。
175
+ * - `"bg"`:实心字体。
176
+ * @default 'stroke'
177
+ * @type {'stroke' | 'bg'}
178
+ * @memberof ISubtitleStyle
179
+ */
180
+ /** {en}
181
+ * @brief Font display mode:
182
+ * - `"stroke"`: outlined text
183
+ * - `"bg"`: solid background
184
+ * @default 'stroke'
185
+ * @type {'stroke' | 'bg'}
186
+ * @memberof ISubtitleStyle
187
+ */
188
+ mode?: "stroke" | "bg";
189
+ /** {zh}
190
+ * @brief 是否跟随底部控制栏的高度。
191
+ * @default 50
192
+ * @type {number}
193
+ * @memberof ISubtitleStyle
194
+ */
195
+ /** {en}
196
+ * @brief Offset height following the bottom control bar.
197
+ * @default 50
198
+ * @type {number}
199
+ * @memberof ISubtitleStyle
200
+ */
201
+ followBottom?: number;
202
+ /** {zh}
203
+ * @brief 是否跟随视频自动调整字号。
204
+ * @default true
205
+ * @type {boolean}
206
+ * @memberof ISubtitleStyle
207
+ */
208
+ /** {en}
209
+ * @brief Whether font size auto-adjusts with video.
210
+ * @default true
211
+ * @type {boolean}
212
+ * @memberof ISubtitleStyle
213
+ */
214
+ fitVideo?: boolean;
215
+ /** {zh}
216
+ * @brief 字幕距离画面底部百分比。
217
+ * @default 4
218
+ * @type {number}
219
+ * @memberof ISubtitleStyle
220
+ */
221
+ /** {en}
222
+ * @brief Subtitle offset from bottom as percentage.
223
+ * @default 4
224
+ * @type {number}
225
+ * @memberof ISubtitleStyle
226
+ */
227
+ offsetBottom?: number;
228
+ /** {zh}
229
+ * @brief 横屏视频适配基准字号。
230
+ * @default 49
231
+ * @type {number}
232
+ * @memberof ISubtitleStyle
233
+ */
234
+ /** {en}
235
+ * @brief Base font size for landscape video.
236
+ * @default 49
237
+ * @type {number}
238
+ * @memberof ISubtitleStyle
239
+ */
240
+ baseSizeX?: number;
241
+ /** {zh}
242
+ * @brief 竖屏视频适配基准字号。
243
+ * @default 28
244
+ * @type {number}
245
+ * @memberof ISubtitleStyle
246
+ */
247
+ /** {en}
248
+ * @brief Base font size for portrait video.
249
+ * @default 28
250
+ * @type {number}
251
+ * @memberof ISubtitleStyle
252
+ */
253
+ baseSizeY?: number;
254
+ /** {zh}
255
+ * @brief PC 端最小字号.
256
+ * @default 16
257
+ * @type {number}
258
+ * @memberof ISubtitleStyle
259
+ */
260
+ /** {en}
261
+ * @brief Minimum font size on PC.
262
+ * @default 16
263
+ * @type {number}
264
+ * @memberof ISubtitleStyle
265
+ */
266
+ minSize?: number;
267
+ /** {zh}
268
+ * @brief 移动端最小字号。
269
+ * @default 13
270
+ * @type {number}
271
+ * @memberof ISubtitleStyle
272
+ */
273
+ /** {en}
274
+ * @brief Minimum font size on mobile.
275
+ * @default 13
276
+ * @type {number}
277
+ * @memberof ISubtitleStyle
278
+ */
279
+ minMobileSize?: number;
280
+ /** {zh}
281
+ * @brief 最大显示行数。取值如下:
282
+ * - `"double"`:两行
283
+ * - `"single"`:一行
284
+ * - `"three"`:三行
285
+ * @default double
286
+ * @type {'double' | 'single' | 'three'}
287
+ * @memberof ISubtitleStyle
288
+ */
289
+ /** {en}
290
+ * @brief Maximum display lines:
291
+ * - `"double"`: two lines
292
+ * - `"single"`: one line
293
+ * - `"three"`: three lines
294
+ * @default double
295
+ * @type {'double' | 'single' | 'three'}
296
+ * @memberof ISubtitleStyle
297
+ */
298
+ line?: "double" | "single" | "three";
299
+ /** {zh}
300
+ * @brief 字体颜色。可设为 16 位颜色值或 RGB 值。
301
+ * @default #fff
302
+ * @type {string}
303
+ * @memberof ISubtitleStyle
304
+ */
305
+ /** {en}
306
+ * @brief Font color; hex or RGB value.
307
+ * @default #fff
308
+ * @type {string}
309
+ * @memberof ISubtitleStyle
310
+ */
311
+ fontColor?: string;
312
+ }
25
313
  interface ISubTitleItem {
26
314
  /** {zh}
27
315
  * @brief 字幕来源。业务配置字幕为 `config`,Master M3U8 或原生 HLS 字幕为 `hls`。
@@ -1327,6 +1615,10 @@ export interface LiteStream<MediaUrl extends LiteMediaUrl = LiteMediaUrl> {
1327
1615
  export interface LiteSubtitleConfig {
1328
1616
  list?: LiteSubtitleItem[];
1329
1617
  label?: ISubtitleLabelOptions;
1618
+ style?: ISubtitleStyle;
1619
+ /** @deprecated Use style.cueBoxStyle and style.textStyle. */
1620
+ subtitleStyleConfig?: ISubtitleStyleConfig;
1621
+ subtitleEditor?: SubtitleEditor;
1330
1622
  defaultSubtitleId?: string | number;
1331
1623
  defaultSubtitleLanguage?: string | number;
1332
1624
  mode?: "external" | "native";