forked from helgeholm/vtt-adjust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.js
30 lines (30 loc) · 1.01 KB
/
web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
window.vttAdjust = require('./index');
window.vttAdjust.toString = function() {
return [
"Usage: vttAdjust(<VTT file as string>)",
"",
"// Example, move all cues forward by 2 seconds:",
"var adjuster = vttAdjust('WEBVTT\\n\\n00:00:10.000 --> 00:00:15.000\\nHello\\n\\n00:00:20.000 --> 00:00:25.000\\nHallo\\n\\n00:00:30.000 --> 00:00:35.000\\nHullo');",
"",
"console.log(JSON.stringify(adjuster.cues));",
"/* Output: -------------------",
'[{"id":0,"start":10000,"text":"Hello"},{"id":1,"start":20000,"text":"Hallo"},{"id":2,"start":30000,"text":"Hullo"}]',
" */",
"",
"adjuster.move(adjuster.cues[0], adjuster.cues[0].start + 2000);",
"",
"console.log(adjuster.toString());",
"/* Output: -------------------",
"WEBVTT",
"",
"00:00:12.000 --> 00:00:17.000",
"Hello",
"",
"00:00:22.000 --> 00:00:27.000",
"Hallo",
"",
"00:00:32.000 --> 00:00:37.000",
"Hullo",
" */"
].join('\n');
}