-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyBluRadio.html
66 lines (55 loc) · 2.16 KB
/
MyBluRadio.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
<!DOCTYPE html>
<!-- Audio stream selector for BluOS players. Igor Ridanovic, www.metafide.com -->
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="mybluradio.css">
<title>My Blu Radio</title>
</head>
<body>
<div>
<button id=stationButton_01 type="button" onclick="connect(id)">...</button>
<button id=stationButton_02 type="button" onclick="connect(id)">...</button>
<button id=stationButton_03 type="button" onclick="connect(id)">...</button>
<button id=stationButton_04 type="button" onclick="connect(id)">...</button>
<button id=stationButton_05 type="button" onclick="connect(id)">...</button>
<button id=stationButton_06 type="button" onclick="connect(id)">...</button>
<button id=stationButton_07 type="button" onclick="connect(id)">...</button>
<button id=stationButton_08 type="button" onclick="connect(id)">...</button>
<button id=stationButton_09 type="button" onclick="connect(id)">...</button>
<button id=stationButton_10 type="button" onclick="connect(id)">...</button>
<button id=stationButton_11 type="button" onclick="connect(id)">...</button>
<button id=stationButton_12 type="button" onclick="connect(id)">...</button>
</div>
<div>
<button class="stopbutton" id=stop type="button" onclick="connect(id)">Stop</button>
</div>
<script type="text/javascript" src="config.json"></script>
<script type="text/javascript">
buttonCount = config.length
var i;
for (i = 1; i < buttonCount; i++) {
var elid = 'stationButton_' + i.toString().padStart(2, '0')
document.getElementById(elid).innerHTML=config[i].label;
}
function connect(buttonId) {
if (buttonId == 'stop') {
var uri=config[0].playerIP + ':' + config[0].playerPort + '/Stop'
var connectionMsg = 'Stopped streaming';
} else {
var idx=parseInt(buttonId.slice(-2));
var endpoint=config[0].playerIP + ':' + config[0].playerPort + '/Play?url=';
var uri=endpoint + config[idx].uri;
var connectionMsg = 'Connected:' + config[idx].label;
}
fetch(uri).then(function(response) {
return response.json();
}).then(function(data) {
console.log(data);
}).catch(function() {
console.log(connectionMsg);
});
}
</script>
</body>
</html>