Switch to side-by-side view

--- a/src/mpdcli.cxx
+++ b/src/mpdcli.cxx
@@ -32,12 +32,12 @@
 #define M_CONN ((struct mpd_connection *)m_conn)
 
 MPDCli::MPDCli(const string& host, int port, const string& pass,
-               const string& onstart, const string& onstop,
-               const string& onvolumechange)
+               const string& onstart, const string& onplay,
+               const string& onstop, const string& onvolumechange)
     : m_conn(0), m_ok(false), m_premutevolume(0), m_cachedvolume(50),
       m_host(host), m_port(port), m_password(pass), m_onstart(onstart),
-      m_onstop(onstop), m_onvolumechange(onvolumechange), m_lastinsertid(-1),
-      m_lastinsertpos(-1), m_lastinsertqvers(-1)
+      m_onplay(onplay), m_onstop(onstop), m_onvolumechange(onvolumechange),
+      m_lastinsertid(-1), m_lastinsertpos(-1), m_lastinsertqvers(-1)
 {
     regcomp(&m_tpuexpr, "^[[:alpha:]]+://.+", REG_EXTENDED|REG_NOSUB);
     if (!openconn()) {
@@ -167,14 +167,23 @@
     switch (mpd_status_get_state(mpds)) {
     case MPD_STATE_STOP:
         // Only execute onstop command if mpd was playing or paused
-        if (m_stat.state != MpdStatus::MPDS_STOP && !m_onstop.empty()) {
+        if (!m_onstop.empty() && (m_stat.state == MpdStatus::MPDS_PLAY ||
+                                  m_stat.state == MpdStatus::MPDS_PAUSE)) {
             if (system(m_onstop.c_str())) {
                 LOGERR("MPDCli::updStatus: " << m_onstop << " failed "<< endl);
             }
         }
         m_stat.state = MpdStatus::MPDS_STOP;
         break;
-    case MPD_STATE_PLAY: m_stat.state = MpdStatus::MPDS_PLAY;break;
+    case MPD_STATE_PLAY:
+        // Only execute onplay command if mpd was stopped
+        if (!m_onplay.empty() && m_stat.state == MpdStatus::MPDS_STOP) {
+            if (system(m_onplay.c_str())) {
+                LOGERR("MPDCli::updStatus: " << m_onplay << " failed "<< endl);
+            }
+        }
+        m_stat.state = MpdStatus::MPDS_PLAY;
+        break;
     case MPD_STATE_PAUSE: m_stat.state = MpdStatus::MPDS_PAUSE;break;
     case MPD_STATE_UNKNOWN: 
     default: