I'm trying to communicate with SMPlayer using its D-Bus interface "org.mpris.MediaPlayer2". Calling methods works fine. For example:
smp = QDBusInterface(r'org.mpris.MediaPlayer2.smplayer', "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player")
smp.call("Pause")
smp.call("Seek",QDBusArgument(int(value_in_ms)*1000, QMetaType.LongLong))
I tried both of these variants below I found online, but the result is None
for the first variant (this how I think it should be done), and I get the error No such method 'Rate' in interface 'org.mpris.MediaPlayer2.Player' at object path '/org/mpris/MediaPlayer2'(signature '')
for the second one:
res = smp.property("Rate")
res = smp.call("Rate")
I verified that the these properties actually exist. I can read them using dbus-send or qdbus on the command-line. Any idea what I am doing wrong?
There are several problems with your code. You're using the wrong interface to get/set the properties, and the argument types are specified incorrectly. Also, you are trying to use
property()
, which is an inherited QObject method with no relevance to dbus.The interactive demo script below shows how to get and set the SMPLayer Rate property (the format of which is documented here). Note that it is essential that QDBusVariant is used to specify the value when setting the property:
Output: