-
Notifications
You must be signed in to change notification settings - Fork 0
/
heos.js
33 lines (31 loc) · 1.08 KB
/
heos.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
const heos = require("heos-api");
const fav = {
kiosk: "http://kioskradiobxl.out.airtime.pro:8000/kioskradiobxl_b",
lyl: "https://icecast.lyl.live/live",
};
const url = process.env.FAV
? fav[process.env.FAV]
: process.env.URL || "http://kioskradiobxl.out.airtime.pro:8000/kioskradiobxl_b";
heos
.discoverAndConnect({})
.then((c) => c.on({ commandGroup: "system", command: "check_account" }, console.log))
.then((c) =>
c.onAll((response) => {
// response.heos.command.command !== "player_now_playing_progress" &&
// console.log("MESSAGE", response.heos);
if (response.heos.command.command === "get_players") {
if (response?.payload[0].gid !== undefined) {
c.write("browse", "play_stream", {
pid: response.payload[0].gid,
url: url,
});
}
c.write("browse", "play_stream", {
pid: response.payload[0].pid,
url: url,
});
}
})
)
.then((c) => c.write("system", "register_for_change_events", { enable: "on" }))
.then((c) => c.write("player", "get_players"));