Skip to content

Commit

Permalink
Add player state to example file: Now displays playing/paused/stopped…
Browse files Browse the repository at this point in the history
… in addition to track info
  • Loading branch information
tmittet committed Nov 9, 2017
1 parent 0ebd3e4 commit 7063ece
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/Sonos_Control_and_State/Sonos_Control_and_State.ino
Expand Up @@ -118,6 +118,22 @@ void loop()
// Sonos state polling
if (g_sonosLastStateUpdate > millis() || millis() > g_sonosLastStateUpdate + SONOS_STATUS_POLL_DELAY_MS)
{
byte playerState = g_sonos.getState(g_sonosLivingrIP);
switch (playerState)
{
case SONOS_STATE_PLAYING:
Serial.print("Playing, ");
break;
case SONOS_STATE_PAUSED:
Serial.print("Paused, ");
break;
case SONOS_STATE_STOPPED:
Serial.print("Stopped, ");
break;
default:
Serial.print("Unknown, ");
break;
}
char uri[25] = "";
TrackInfo track = g_sonos.getTrackInfo(g_sonosLivingrIP, uri, sizeof(uri));
byte source = g_sonos.getSourceFromURI(track.uri);
Expand Down

0 comments on commit 7063ece

Please sign in to comment.