The Specification page for this particular interface says:
PlaybackStatus — s (Playback_Status)
.
.
.
May be "Playing", "Paused" or "Stopped".
But when i read it like this:
print "Song %s" % iPlayer.PlaybackStatus
or
if iPlayer.PlaybackStatus == "Playing":
print "Song playing"
It shows a very strange output like <dbus.proxies._ProxyMethod instance at 0x255f248>
How can I access the String value of this variable?
You have to call the Get
method to get the property. The method returns a string. I did the following to get playback status of VLC player:
import dbus
bus = dbus.SessionBus()
vlc_media_player_obj = bus.get_object("org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2")
props_iface = dbus.Interface(vlc_media_player_obj, 'org.freedesktop.DBus.Properties')
pb_stat = props_iface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
In my case (and hopefully in yours), the object also had a org.freedesktop.DBus.Properties
interface, which has the Get
method, which you can call as above.