Skip to content

Commit 7366b4e

Browse files
committed
HEOS: Fixed handling of Event Changes
1 parent 2d674b4 commit 7366b4e

File tree

1 file changed

+74
-28
lines changed

1 file changed

+74
-28
lines changed

hardware/HEOS.cpp

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void CHEOS::ParseLine()
9191
if (DEBUG_LOGGING) _log.Log(LOG_NORM, "DENON by HEOS: No players found (No Payload).");
9292
}
9393
}
94-
else if (root["heos"]["command"] == "player/get_play_state" || root["heos"]["command"] == "player/set_play_state" || root["heos"]["command"] == "event/player_state_changed")
94+
else if (root["heos"]["command"] == "player/get_play_state" || root["heos"]["command"] == "player/set_play_state")
9595
{
9696
if (root["heos"].isMember("message"))
9797
{
@@ -179,45 +179,91 @@ void CHEOS::ParseLine()
179179
}
180180
}
181181
}
182-
else if (root["heos"]["command"] == "event/players_changed")
183-
{
184-
SendCommand("getPlayers");
185-
}
186-
else if (root["heos"]["command"] == "event/groups_changed")
187-
{
188-
SendCommand("getPlayers");
189-
}
190-
else if (root["heos"]["command"] == "event/player_now_playing_changed")
182+
}
183+
}
184+
else
185+
{
186+
if (root["heos"].isMember("command"))
187+
{
188+
if (DEBUG_LOGGING) _log.Log(LOG_NORM, "DENON by HEOS: Failed: '%s'.", root["heos"]["command"].asCString());
189+
}
190+
}
191+
}
192+
else
193+
{
194+
if (root["heos"].isMember("command"))
195+
{
196+
if (root["heos"]["command"] == "event/player_state_changed")
197+
{
198+
if (root["heos"].isMember("message"))
191199
{
192200
std::vector<std::string> SplitMessage;
193-
StringSplit(root["heos"]["message"].asString(), "=", SplitMessage);
201+
StringSplit(root["heos"]["message"].asString(), "&", SplitMessage);
194202
if (SplitMessage.size() > 0)
195203
{
196-
std::string pid = SplitMessage[1];
197-
int PlayerID = atoi(pid.c_str());
198-
SendCommand("getPlayState", PlayerID);
204+
std::vector<std::string> SplitMessagePlayer;
205+
StringSplit(SplitMessage[0], "=", SplitMessagePlayer);
206+
std::vector<std::string> SplitMessageState;
207+
StringSplit(SplitMessage[1], "=", SplitMessageState);
208+
std::string pid = SplitMessagePlayer[1];
209+
std::string state = SplitMessageState[1];
210+
211+
_eMediaStatus nStatus = MSTAT_UNKNOWN;
212+
213+
if (state == "play")
214+
nStatus = MSTAT_PLAYING;
215+
else if (state == "pause")
216+
nStatus = MSTAT_PAUSED;
217+
else if (state == "stop")
218+
nStatus = MSTAT_STOPPED;
219+
else
220+
nStatus = MSTAT_ON;
221+
222+
std::string sStatus = "";
223+
224+
UpdateNodeStatus(pid, nStatus, sStatus);
225+
226+
/* If playing request now playing information */
227+
if (state == "play") {
228+
int PlayerID = atoi(pid.c_str());
229+
SendCommand("getNowPlaying", PlayerID);
230+
}
231+
232+
m_lastUpdate = 0;
199233
}
200234
}
201-
else if (root["heos"]["command"] == "event/player_mute_changed")
235+
}
236+
else if (root["heos"]["command"] == "event/players_changed")
237+
{
238+
SendCommand("getPlayers");
239+
}
240+
else if (root["heos"]["command"] == "event/groups_changed")
241+
{
242+
SendCommand("getPlayers");
243+
}
244+
else if (root["heos"]["command"] == "event/player_now_playing_changed")
245+
{
246+
std::vector<std::string> SplitMessage;
247+
StringSplit(root["heos"]["message"].asString(), "=", SplitMessage);
248+
if (SplitMessage.size() > 0)
202249
{
203-
250+
std::string pid = SplitMessage[1];
251+
int PlayerID = atoi(pid.c_str());
252+
SendCommand("getPlayState", PlayerID);
204253
}
205-
else if (root["heos"]["command"] == "event/repeat_mode_changed")
206-
{
254+
}
255+
else if (root["heos"]["command"] == "event/player_mute_changed")
256+
{
207257

208-
}
209-
else if (root["heos"]["command"] == "event/shuffle_mode_changed")
210-
{
258+
}
259+
else if (root["heos"]["command"] == "event/repeat_mode_changed")
260+
{
211261

212-
}
213262
}
214-
}
215-
else
216-
{
217-
if (root["heos"].isMember("command"))
263+
else if (root["heos"]["command"] == "event/shuffle_mode_changed")
218264
{
219-
if (DEBUG_LOGGING) _log.Log(LOG_NORM, "DENON by HEOS: Failed: '%s'.", root["heos"]["command"].asCString());
220-
}
265+
266+
}
221267
}
222268
}
223269
}

0 commit comments

Comments
 (0)