Reputation: 799
This python program shall play a playlist from Mediapplayer. When one song ends or after typing on the keyboard the playlist will play the next song.
The input is:
#!/usr/bin/python
#-*-coding:ascii-*-
import dbus
import gobject
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
banshee = bus.get_object('org.mpris.MediaPlayer2.banshee',
'/org/mpris/MediaPlayer2')
iface = dbus.Interface(banshee,'org.mpris.MediaPlayer2.Player')
loop = gobject.MainLoop()
def on_reply():
print"Start"
def on_error():
print"Error"
def next_song():
print"Next Song"
iface.Next(reply_handler=on_reply,
error_handler=on_error)
gobject.timeout_add(4,next_song)
def on_error(error):
print"Error"
loop.quit()
next_song()
try:
loop.run()
finally:
print"End"
iface.Stop()
The output: Nothing
Thank you in advance
Upvotes: 0
Views: 1019
Reputation: 799
The path was wrong. The correct path is:
banshee = bus.get_object("org.bansheeproject.Banshee", "/org/bansheeproject/Banshee/PlayerEngine")
On the following page you get more informations about the path and how it works.
Upvotes: 1
Reputation: 3395
You can use d-feet to see if the method is available on the interface you are trying to use.
You can also use dbus-monitor
to see what messages are passed on the bus. The syntax should be like this:
dbus-monitor --monitor --address <your_bus_address>
You will get all the messages on the bus with the command above. To filter, you can do something like:
dbus-monitor --monitor --address <your_bus_address> interface=<IF_name> path=<path_name> dest=...
You cannot use partial interface/path names in filtering. You can always grep for some advanced filtering.
You usually get this error if either the method is not available on that interface, or you try to call it with a wrong set of parameter types. Check the function signature also, in your calling code.
Upvotes: 1
Reputation: 444
mdbus2 should give a list of available methods. Taken from this page:
$ mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2
...
[METHOD] org.mpris.MediaPlayer2.Player.Pause() -> ()
[METHOD] org.mpris.MediaPlayer2.Player.PlayPause() -> ()
[METHOD] org.mpris.MediaPlayer2.Player.Stop() -> ()
[METHOD] org.mpris.MediaPlayer2.Player.Play() -> ()
...
Adjust the example to reflect the fact that you're interfacing with Banshee. I tried installing Banshee and mdbus2 to try this out myself, but the installer script failed.
You can also try using Python's built-in tools for introspection.
$ python
>>> from org.mpris.MediaPlayer2 import Player
>>> dir(Player)
Even better, drop a similar statement in your program. Your body of code is currently trivial enough that you can just print out the result of dir().
finally:
print"End"
dir(iface)
iface.Stop()
Upvotes: 1