-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.js
81 lines (71 loc) · 1.89 KB
/
test2.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
69
70
71
72
73
74
75
76
77
78
79
80
81
const { Samsung, APPS, KEYS } = require("samsung-tv-control");
/*
Typescript Example for Dinamic Keys
import { $enum } from 'ts-enum-util'
*/
const config = {
debug: true, // Default: false
ip: "192.168.4.32",
mac: "5c497d22f462",
nameApp: "NodeJS-Test", // Default: NodeJS
port: 8001, // Default: 8002
token: "0000"
};
const control = new Samsung(config);
// control.turnOn();
control
.isAvailable()
.then(() => {
console.log("is available");
// Get token for API
control.getToken(token => {
console.info("############################################ Response getToken:", token);
process.exit(1);
});
/*
Typescript Example for Dinamic Keys
const KeyTypes = $enum(KEYS).getValues()
const getEnumValue = (key: any) => {
return KeyTypes[key]
}
*/
/*
// Send key to TV
control.sendKey(KEYS.KEY_HOME, function(err, res) {
if (!err) {
console.log("# Response sendKey", res);
}
});
// Send text to focused input on TV
control.sendText("Text to be inserted in some focused input", function(
err,
res
) {
if (!err) {
console.log("# Response sendText", res);
}
});
// Get all installed apps from TV
control.getAppsFromTV((err, res) => {
if (!err) {
console.log("# Response getAppsFromTV", res);
}
});
// Get app icon by iconPath which you can get from getAppsFromTV
control.getAppIcon(
`/opt/share/webappservice/apps_icon/FirstScreen/${APPS.YouTube}/250x250.png`,
(err, res) => {
if (!err) {
console.log("# Response getAppIcon", res);
}
}
);
// Open app by appId which you can get from getAppsFromTV
control.openApp(APPS.YouTube, (err, res) => {
if (!err) {
console.log("# Response openApp", res);
}
});
*/
})
.catch(e => console.error(e));