-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecimal_test.js
62 lines (38 loc) · 1.53 KB
/
decimal_test.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
const {CasparCG} = require("casparcg-connection");
const Decimal = require('decimal.js-light');
// Decimal.set({
// precision: 20,
// rounding: Decimal.ROUND_HALF_UP,
// toExpNeg: -7,
// toExpPos: 21
// });
let connection = new CasparCG();
const playallfiles = async () => {
const playfileinfo = await connection.thumbnailList();
for (const o of playfileinfo.response.data) {
await connection.play(1, 1, o.name);
await new Promise((resolve) => setTimeout(() => {
resolve();
}, (300)));
const playinfo = await connection.info(1, 1);
const fileInfo = playinfo.response.data.stage.layer.layer_1.foreground.file;
let timesecond = fileInfo.time[1];
let timefirst = fileInfo.time[0];
const newtimesecond = new Decimal(timesecond);
// newtimesecond.equals(newtimefirst)
console.log(newtimesecond.toFixed(3));
const intervalId = setInterval(async () => {
const playinfo2 = await connection.info(1, 1);
timefirst = playinfo2.response.data.stage.layer.layer_1.foreground.file.time[0];
const newtimefirst = new Decimal(timefirst);
console.log(newtimefirst.toFixed(3), newtimesecond.toFixed(3));
}, 300);
await new Promise(resolve => setTimeout(resolve, timesecond * 1000 + 300));
console.log('-- ISGROJO' + " " + o.name);
clearTimeout(intervalId);
}
connection.stop(1, 1);
console.log("Pabaiga");
//rocess.exit(0);
};
playallfiles();