forked from msloth/lgtv.js
-
Notifications
You must be signed in to change notification settings - Fork 45
/
test.js
34 lines (25 loc) · 852 Bytes
/
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
var lgtv = require('./index.js')({
url: 'ws://lgwebostv:3000'
});
lgtv.on('error', function (err) {
console.log(err);
});
lgtv.on('connecting', function () {
console.log('connecting');
});
lgtv.on('connect', function () {
console.log('connected');
lgtv.subscribe('ssap://audio/getVolume', function (err, res) {
if (res.changed && res.changed.indexOf('volume') !== -1) console.log('volume changed', res.volume);
if (res.changed && res.changed.indexOf('muted') !== -1) console.log('mute changed', res.muted);
});
lgtv.subscribe('ssap://com.webos.applicationManager/getForegroundAppInfo', function (err, res) {
console.log('app', res.appId);
});
});
lgtv.on('prompt', function () {
console.log('please authorize on TV');
});
lgtv.on('close', function () {
console.log('close');
});