2

我想做与这里解释的完全相同的事情:

如何使用 python 持续监控节奏盒的音轨变化

但用 Clementine 而不是 Rhythmbox。

问题是,我找不到与playUriChanged等效的方法来提供给connect_to_signal方法。

我能找到的唯一与 qdbus 相关的东西是

signal void org.freedesktop.MediaPlayer.TrackChange(QVariantMap)

但它需要一个参数。

我对 DBus 不熟悉,因此不胜感激。

谢谢

4

1 回答 1

0

它不带参数,它返回参数(哈希映射)

从此脚本中提取的代码:

def TrackChange(Track):
    # use Track["URI"], Track["title"], Track["artist"] etc

def Connect(name):
    global root, player, tracklist

    # first we connect to the objects
    root_o = bus.get_object(name, "/")
    player_o = bus.get_object(name, "/Player")
    tracklist_o = bus.get_object(name, "/TrackList")

    # there is only 1 interface per object
    root = dbus.Interface(root_o, "org.freedesktop.MediaPlayer")
    tracklist  = dbus.Interface(tracklist_o, "org.freedesktop.MediaPlayer")
    player = dbus.Interface(player_o, "org.freedesktop.MediaPlayer")

    # connect to the TrackChange signal
    player_o.connect_to_signal("TrackChange", TrackChange, dbus_interface="org.freedesktop.MediaPlayer") 
于 2013-02-11T01:21:47.213 回答