@interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate>
 {
        PEPThread *pepper;
+       MPDConnection *mpdConn;
 }
 @end
 
 - (void)applicationDidFinishLaunching
 {
        XMPPConnection *conn;
+
+       OFString *mpd_host;
+       uint16_t mpd_port;
+       OFString *mpd_port_string;
+
+       OFDictionary *environment = [OFApplication environment];
        OFArray *arguments = [OFApplication arguments];
 
        conn = [[XMPPConnection alloc] init];
        conn.password = [arguments objectAtIndex: 2];
        conn.resource = @"ObjXMPP";
 
+       mpd_host = [environment objectForKey: @"MPD_HOST"];
+       if (mpd_host == nil)
+               mpd_host = @"localhost";
+
+       mpd_port_string = [environment objectForKey: @"MPD_PORT"];
+       if (mpd_port_string && [mpd_port_string decimalValue] <= UINT16_MAX)
+               mpd_port = (uint16_t) [mpd_port_string decimalValue];
+       else
+               mpd_port = 6600;
+
+       mpdConn = [[MPDConnection alloc] initWithHost: mpd_host
+                                                port: mpd_port];
+       [mpdConn connect];
+
        @try {
                [conn connect];
                [conn handleConnection];
                    stringValue] isEqual: @"pubsub"] &&
                    [[[identity attributeForName: @"type"] stringValue]
                    isEqual: @"pep"]) {
-                       pepper = [[PEPThread alloc]
-                           initWithObject: conn];
+                       pepper = [[PEPThread alloc] initWithObject: conn];
                        [pepper start];
 
                        return YES;
        }
 }
 
+-  (void)connection: (XMPPConnection*)conn
+  didReceiveMessage: (XMPPMessage*)mesg
+{
+       if ([mesg.body isEqual: @"pause"]) {
+               [mpdConn send: @"pause"];
+               [mpdConn response];
+       }
+}
+
 - (void)connectionWasClosed: (XMPPConnection*)conn
 {
        [of_stdout writeLine: @"Connection was closed!"];