Controlling Banshee over D-Bus

I needed to be able to control Banshee from another application, and it turns out it has a lovely D-Bus API.

Skip to the next song*:

import dbus
bus = dbus.SessionBus()
banshee = bus.get_object("org.bansheeproject.Banshee",
  "/org/bansheeproject/Banshee/PlaybackController")
banshee.Next(False) # use banshee.Previous(False) to skip back one song

Start Banshee playing (this works even if Banshee isn’t running; D-Bus starts it up!):

import dbus
bus = dbus.SessionBus()
banshee = bus.get_object("org.bansheeproject.Banshee",
  "/org/bansheeproject/Banshee/PlayerEngine") # note PlayerEngine, not PlaybackController
banshee.Play() # use banshee.Pause() to pause playback

I found these commands using D-Feet*, J5’s D-Bus browser thing, which is great. The program I’m using to call this stuff is open source Enso from the Humanized team, which is also pretty darn useful.

4 Responses to “Controlling Banshee over D-Bus”

  1. Thanks for the hint on enso. I didn’t know they released the source under a BSD license. Very cool, I remember seeing it a while ago and thinking that it would be really cool if it was open as people would extend it with all kinds of useful features. I can see that you’re already doing exactly that :)

    Anders Rune Jensen
  2. D-Feet. Nyom. Thanks for that.

    Roger / oojah
  3. Sweet! I’m also discovering the wonders of dbus. Pretty amazing stuff.

    Kalle
  4. [...] = dbus.SessionBus banshee = bus.get_object&quotorg.bansheeproject.Banshee&quot, &quot/org/bansheephttp://www.kryogenix.org/days/2008/07/02/controlling-banshee-over-d-busA&E Calendar The Fremont ArgusMUSIC FREMONTThe Central Park summer concert series, presented by The [...]

    banshee

Leave a Reply