-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradio.js
68 lines (59 loc) · 1.81 KB
/
radio.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
65
66
67
68
var radio = {
url: 'http://revo/fsapi/',
sessionId: null,
friendlyName: null,
volumeSteps: null,
volume: null,
playInfoName: null,
playInfoText: null,
request: function(operation, value, success) {
var url = this.url + operation + '?pin=1234';
if(radio.sessionId) { url = url + '&sid=' + radio.sessionId; }
if(value) { url = url + '&value=' + value; }
console.log(url);
$.get({
url: url,
success: function(data) {
console.log(data);
var xml = $('fsapiResponse', data);
if(typeof success !== 'undefined') { success(radio, xml); }
}
});
},
getSessionId: function(success) {
radio.request('CREATE_SESSION', null, function(radio, xml) {
radio.sessionId = xml.find('sessionId').text();
success(radio);
});
},
getFriendlyName: function(success) {
radio.request('GET/netRemote.sys.info.friendlyName', null, function(radio, xml) {
radio.friendlyName = xml.find('value').text();
success(radio);
});
},
getVolumeSteps: function(success) {
radio.request('GET/netRemote.sys.caps.volumeSteps', null, function(radio, xml) {
radio.volumeSteps = xml.find('value').text();
success(radio);
});
},
getVolume: function(success) {
radio.request('GET/netRemote.sys.audio.volume', null, function(radio, xml) {
radio.volume = xml.find('value').text();
success(radio);
});
},
getPlayInfoName: function(success) {
radio.request('GET/netRemote.play.info.name', null, function(radio, xml) {
radio.playInfoName = xml.find('value').text();
success(radio);
});
},
getPlayInfoText: function(success) {
radio.request('GET/netRemote.play.info.text', null, function(radio, xml) {
radio.playInfoText = xml.find('value').text();
success(radio);
});
}
};