             let address: AudioObjectPropertyAddress = addresses[Int(index)]
             switch address.mSelector {
             case kAudioHardwarePropertyDefaultOutputDevice:
-                if (getDefaultAudioOutputDeviceName().rangeOfString(airplayDeviceName) != nil) {
-                    print("enabling")
-                } else {
-                    print("disabling")
-                }
+                setupVolumeKeyTap()
             default:
                 print("We didn't expect this!")
                 

        
        // volume key listener
        volumeTap = SPMediaKeyTap(delegate: self)
        volumeTap.startWatchingMediaKeys()
        
        // audio device listener http://stackoverflow.com/questions/26070058/how-to-get-notification-if-system-preferences-default-sound-changed
        // tell HAL to manage its own thread for notifications 

        let session = NSURLSession.sharedSession()
        let url = NSURL(string: url)!
        let task = session.dataTaskWithURL(url) { (data, response, error) in
            //print(NSString(data: data!, encoding:NSUTF8StringEncoding))
        }
        task.resume()
    }
    
    func setupVolumeKeyTap() {
        if (getDefaultAudioOutputDeviceName().rangeOfString(airplayDeviceName) != nil) {
            volumeTap.startWatchingMediaKeys()
        } else {
            volumeTap.stopWatchingMediaKeys()
        }

    }
}

