-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
62 lines (58 loc) · 1.33 KB
/
Copy pathtest.js
File metadata and controls
62 lines (58 loc) · 1.33 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { generate: showQR } = require("qrcode-console");
const {
getAuthToken,
getServiceToken,
getSTreamToken,
Stream
} = require("./lib/api");
async function getStream(onId) {
const { token: authToken, id: authId } = await getAuthToken();
onId(authId);
const { service_token: serviceToken } = await getServiceToken(authToken);
const { token, id: streamId } = await getStreamToken(serviceToken);
return new Stream(token, streamId);
}
getStream(authId => {
console.log(authId);
showQR(`subreader://authenticate?id=${authId}`);
}).then(stream => {
console.log("Got stream", stream.id);
stream.setSubtitles([
{
language: "da",
cues: [
{
text: "Hej med dig!",
timeIn: Date.now() + 0,
timeOut: Date.now() + 4000
},
{
text: "Hvordan går det?",
timeIn: Date.now() + 5000,
timeOut: Date.now() + 7000
}
]
},
{
language: "en",
cues: [
{
text: "Hello!",
timeIn: Date.now() + 0,
timeOut: Date.now() + 4000
},
{
text: "How are you?",
timeIn: Date.now() + 5000,
timeOut: Date.now() + 7000
}
]
}
]);
setInterval(() => {
stream.setState({
playing: true,
time: Date.now()
});
}, 1000);
});