I have now tried with dbus. I found some nice tutorials [1] [2] so I got some code looking like: session_bus = dbus.SessionBus() proxy_obj = session_bus.get_object('org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player') player = dbus.Interface(proxy_obj, 'org.gnome.Rhythmbox.Player') # get playing song print player.getPlayingUri() # skip to next player.next() Much easier than I thought. However, one of the tutorials [2] described how I should the dbus-next utility to get information about all the different method are available via dbus. Using the following message I know what kind of objects I can get from rhythmbox: dbus-send --print-reply --dest=org.gnome.Rhythmbox /org/gnome/Rhythmbox
org.freedesktop.DBus.Introspectable.Introspect Which gives: [...] <node> <node name="DAAP"/> <node name="Player"/> <node name="PlaylistManager"/> <node name="Shell"/> </node> [...] I can do the same with them: dbus-send --print-reply --dest=org.gnome.Rhythmbox /org/gnome/Rhythmbox/Player org.freedesktop.DBus.Introspectable.Introspect [...] <method name="getPlayingUri"> <arg name="uri" type="s" direction="out"/> </method> <method name="getPlaying"> <arg name="playing" type="b"
direction="out"/> </method> <method name="next"> </method> <method name="previous"> </method> [...] Now I'm wondering, is there any documentation on these methods I get from the command, for instance getPlayingUri? Or is the xml file the only documentation? And with that said, can I "only" use the method defined in the introspect files? So if I need more functionality, I have to use threads (or some other kind of communication so I get access to the shell)? Thanks for your help! Oh, and by the way, with threads, I used the gdk lock functions to avoid crashing rhythmbox: # get lock gtk.gdk.threads_enter() # do stuff with
gtk self.shell.props.shell_player.play() # release lock gtk.gdk.threads_leave() Kind regards, Samuel [1] http://unmaintainable.wordpress.com/2006/12/10/controlling-rhythmbox-using-dbus/ [2] http://fredreh.wordpress.com/2008/02/13/put-rhythmbox-om-the-d-bus/ --- Den mån 2010-03-22 skrev Michael Gratton <mike vee net>:
|