itube-specs 0.0.756 → 0.0.757
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/package.json +1 -1
- package/runtime/utils/vtt-helper.ts +16 -8
package/package.json
CHANGED
|
@@ -18,15 +18,23 @@ export class VttHelper {
|
|
|
18
18
|
|
|
19
19
|
/** Загружает и парсит VTT-файл по url из конструктора. Устанавливает hasInited = true после успешной загрузки. */
|
|
20
20
|
async init(): Promise<void> {
|
|
21
|
-
|
|
21
|
+
if (!this.vttUrl) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const vttContent: Response = await fetch(this.vttUrl);
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (vttContent.body) {
|
|
29
|
+
const reader: ReadableStreamDefaultReader<string> = vttContent.body
|
|
30
|
+
.pipeThrough(new TextDecoderStream())
|
|
31
|
+
.getReader();
|
|
32
|
+
const vtt: ReadableStreamReadResult<string> = await reader.read();
|
|
33
|
+
this.vttData = this.parseVTT(vtt);
|
|
34
|
+
this.hasInited = true;
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
this.hasInited = false;
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
|