【问题标题】:Get current timepoint from Totem application从 Totem 应用程序获取当前时间点
【发布时间】:2011-01-06 22:33:53
【问题描述】:

我想使用 D-Bus 在正在运行的 Totem 实例中找到媒体文件当前暂停(或播放)的确切时间。准确地说,我想要的可以通过以下命令从 Totem python 控制台(如果插件存在并启用)获得:

>>> print totem_object.props.current_time
732616

我理解是毫秒。

到目前为止: 我以前从未使用过 D-Bus,所以我正在阅读 D-Bus 和 python-dbus 文档。我也启动了 D-Feet,发现org.gnome.Totem 总线名称和/Factory 对象我可以使用org.freedesktop.DBus.Properties 接口方法。

我目前处于这一点:

>>> import dbus
>>> seb= dbus.SessionBus()
>>> t= seb.get_object('org.gnome.Totem', '/Factory')
>>> tif= dbus.Interface(t, 'org.freedesktop.DBus.Properties')
>>> tif.GetAll('')
dbus.Dictionary({}, signature=dbus.Signature('sv'))

我什至找不到合适的方法,因此我们将不胜感激。

【问题讨论】:

    标签: python linux gnome dbus totem


    【解决方案1】:

    我目前出于不同的原因正在研究 API,我需要检索正在播放的路径或位置,我偶然发现了这个问题。

    首先,您需要激活 D-Bus 服务插件(编辑 -> 插件),它将公开 org.mpris.Totem 服务。然后在/Player对象和org.freedesktop.MediaPlayer接口上可以使用PositionGet()方法获取当前位置。

    这将返回您所说的 totem.props.current_time

    这里有一些代码:

    import dbus
    
    T_SERVICE_NAME = "org.mpris.Totem"
    T_OBJECT_PATH = "/Player"
    T_INTERFACE = "org.freedesktop.MediaPlayer"
    
    session_bus= dbus.SessionBus()
    
    totem = session_bus.get_object(T_SERVICE_NAME, T_OBJECT_PATH)
    totem_mediaplayer = dbus.Interface(totem, dbus_interface=T_INTERFACE)
    
    print totem_mediaplayer.PositionGet()
    

    至于整个org.gnome.Totem 服务和Get/GetAll 方法,我也不明白它们的全部目的。看起来它与 DBus 本身的关系比与 Totem 的关系更大。

    参考文献

    1. http://git.gnome.org/browse/totem/tree/src/plugins/dbusservice/dbusservice.py
    2. http://developer.gnome.org/totem/stable/TotemObject.html

    【讨论】:

    • 谢谢,就是这样。
    • 感谢@Bruce-van-der-Kooij。有没有办法将视频添加到播放列表?
    猜你喜欢
    • 2011-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 2022-07-08
    相关资源
    最近更新 更多