【问题标题】:using org.mpris.mediaplayer2.player PlaybackStatus property in python在 python 中使用 org.mpris.mediaplayer2.player PlaybackStatus 属性
【发布时间】:2014-04-27 14:52:11
【问题描述】:

此特定界面的Specification page 表示:

PlaybackStatus — s (Playback_Status)
.
.
.
May be "Playing", "Paused" or "Stopped".

但是当我这样读时:

print "Song %s" % iPlayer.PlaybackStatus

if iPlayer.PlaybackStatus == "Playing":
    print "Song playing"

它显示了一个非常奇怪的输出,例如<dbus.proxies._ProxyMethod instance at 0x255f248>

如何访问该变量的字符串值?

【问题讨论】:

    标签: python string media-player dbus


    【解决方案1】:

    您必须调用Get 方法来获取该属性。该方法返回一个字符串。我做了以下获取 VLC 播放器的播放状态:

    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')
    

    在我的情况下(希望在你的情况下),该对象还有一个org.freedesktop.DBus.Properties 接口,它具有Get 方法,您可以像上面那样调用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 2016-07-08
      • 1970-01-01
      • 1970-01-01
      • 2022-11-27
      • 1970-01-01
      相关资源
      最近更新 更多