forked from cgarwood/ProPresenter-vMix
-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
101 lines (79 loc) · 2.89 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="stylesheet.css">
<script type="text/javascript" src="lib/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript">
prev_text = '';
function processProPresenterMessage(message) {
/* enable this to view Array of data in the console. */
/*
if (message['acn'] != "vid") {
console.log(message);
}
*/
// only parse fv arrays
if (message['acn'] == "fv") {
if (message['ary'][0]['txt'] != undefined && message['ary'][0]['acn'] === 'cs') {
var text = '';
// check slide note for noText keyword. If noText is defined dont step into this IF
if (typeof message['ary'][1] !== 'undefined' && message['ary'][1]['txt'] !== config["noText"]) {
// replace carriage return \r and linefeed \n with <br> global
text = message['ary'][0]['txt'].replace(/\r\n|\n|\r/g, '<br />');
// if fading is true and repeated text is true
if (prev_text !== text || config['fade_repeated_text']) {
// if fading is true
if (config['fade']) {
$("#cs").fadeOut(config["fade_speed"], function() {
$("#cs").html(text);
$("#cs").fadeIn(config["fade_speed"]);
});
}
// no fade
else {
$("#cs").html(text);
}
}
}
// noText keyword was defined on slide note so set #cs to blank
else{
$("#cs").html("");
}
prev_text = text;
}
}
}
function connectToProPresenter() {
var proPresenterStageDisplayURL = 'ws://' + config['propresenter_ip'] + ':' + config['propresenter_port'] + '/stagedisplay';
var ws = new WebSocket(proPresenterStageDisplayURL);
ws.onopen = function() {
console.log('ProPresenter connection opened');
ws.send(JSON.stringify({
"pwd": config['propresenter_password'],
"ptl": 610,
"acn": "ath"
}));
};
ws.onmessage = function(e) {
processProPresenterMessage(JSON.parse(e.data));
};
ws.onclose = function(e) {
console.log('ProPresenter socket was closed. Attempting to reconnect in 1 second...', e.reason);
setTimeout(function() {
connectToProPresenter();
}, 1000);
};
ws.onerror = function(err) {
console.error('ProPresenter socket has error: ', err.message, 'Closing socket');
ws.close();
};
}
connectToProPresenter();
</script>
</head>
<body>
<div id="cs"></div>
</body>
</html>