-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.js
67 lines (37 loc) · 1.24 KB
/
play.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
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
63
64
const {CasparCG} = require("casparcg-connection");
let connection = new CasparCG();
(async () => {
// ciklas
// await broadcasting()
await connection.play(1, 1, "pirmas");
})();
const broadcasting = async () => {
const playinfo = await connection.info(1, 1);
const fileInfo = await playinfo.response.data.stage.layer.layer_1.foreground.file;
console.log(fileInfo);
if (!fileInfo || !('time' in fileInfo)) {
broadcasting();
}
let timefirst = fileInfo.time[0];
let timesecond = fileInfo.time[1];
if (timesecond === 0) {
broadcasting();
}
// setTimeout
// setInterval
// clearTimeout
// clearInterval
const intervalId = setInterval(async () => {
const lastnumber = timesecond - timefirst;
if (lastnumber < 0.3) {
clearTimeout(intervalId);
console.log('-- ISGROJO');
connection.play(1, 1, "antras");
return;
}
const playinfo2 = await connection.info(1, 1);
timefirst = playinfo2.response.data.stage.layer.layer_1.foreground.file.time[0];
console.log(playinfo2.response.data.stage.layer.layer_1.foreground.file.time[0], timesecond);
}, 100);
};
broadcasting();