-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsample.js
49 lines (34 loc) · 1.37 KB
/
sample.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
var soundTouchDiscovery = require('./discovery');
soundTouchDiscovery.search(function(deviceAPI) {
console.log(deviceAPI.name + " --> " + deviceAPI.getDevice().ip);
deviceAPI.isAlive(function(json) {
console.log(deviceAPI.name + ' --> isAlive: ' + json);
});
deviceAPI.isPoweredOn(function(json) {
console.log(deviceAPI.name + ' --> isPoweredOn: ' + json);
});
deviceAPI.getVolume(function(json) {
console.log(deviceAPI.name + ' --> Volume: ', json.volume.actualvolume);
});
deviceAPI.getNowPlaying(function(json) {
console.log(deviceAPI.name + ' --> Now playing: ', json.nowPlaying.ContentItem);
});
//SOCKETS
deviceAPI.socketStart();
deviceAPI.setPoweredListener(function(poweredOn, nowPlaying) {
console.log(poweredOn ? 'Powered On' : 'Powered Off');
});
deviceAPI.setIsPlayingListener(function(poweredOn) {
console.log(poweredOn ? 'Playing' : 'Not playing');
});
deviceAPI.setVolumeUpdatedListener(function(volume, json) {
console.log("VOLUME UPDATED", volume, json);
});
deviceAPI.setNowPlayingUpdatedListener(function(json) {
console.log("NOW PLAYING UPDATED", json);
});
deviceAPI.setNowSelectionUpdatedListener(function(json) {
console.log("NOW SELECTION UPDATED", json);
});
soundTouchDiscovery.stopSearching();
});