title: How to open bluetooth connections and be A2DP source and sink
body: <p>I want to use Python to connect up to a bluetooth device and utilize that as a speaker. For example, use Python to play .wav and hear on device and validate it is being played etc. I than want to play audio on my linux box and listen to it on the bluetooth device.</p>
  
  <p>I was doing some looking on stackoverflow and it seems I can use pybluez to connect, but then need to use dbus to set up the actual audio connection. I found <a href="https://stackoverflow.com/questions/33329010/linux-bluez-dbus-communication-a2dp">Linux BlueZ dbus communication a2dp</a>, but it results in:</p>
  
  <pre><code>dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist
  </code></pre>
  
  <p>When it tries to get the default adapter off the interface, so I do not even get to the original posters issue.  Thank you for any help!
  Here is the code:</p>
  
  <pre><code>import dbus as dbus
  bus = dbus.SystemBus()
  
  man = bus.get_object('org.bluez', '/')
  iface = dbus.Interface(man, 'org.bluez.Manager')
  adapterPath = iface.DefaultAdapter()
  adapter = dbus.Interface(bus.get_object('org.bluez', adapterPath),dbus_interface='org.bluez.Adapter')
  devices = adapter.GetProperties()['Devices']
  
  for d in devices:
      dev = dbus.Interface(bus.get_object('org.bluez', d),dbus_interface='org.bluez.Device')
      props = dev.GetProperties()
      if any(AudioSourceServiceClass_UUID in UUID.upper() for UUID in props["UUIDs"]):
          devobj = bus.get_object('org.bluez', d)
          devobj.Trusted = True
          if props["Connected"] == True:
              print  props["Name"] + " is connected!"
              exit()
  
  for d in devices:
      dev = dbus.Interface(bus.get_object('org.bluez', d),dbus_interface='org.bluez.Device')
      props = dev.GetProperties()
      if any(AudioSourceServiceClass_UUID in UUID.upper() for UUID in props["UUIDs"]):
          #This device is an A2DP Audio source
          print  props["Name"] + " has A2DP audio source"
          #dev.connect_to_signal("PropertyChanged", handler_for_device(dev))
          #dev.connect_to_signal("PropertyChanged", cb)
          devobj = bus.get_object('org.bluez', d)
          try:
              devobj.Connect(dbus_interface='org.bluez.AudioSource')
              devobj.Play()
              exit()
          except dbus.DBusException, e:
              print str(e)
  </code></pre>
  
  <p>I have two questions.</p>
  
  <ol>
  <li>How to be a A2DP source?</li>
  <li>How do I fix the exception thrown when getting the adapter path? </li>
  </ol>