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.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)