代码之家  ›  专栏  ›  技术社区  ›  tzot

从图腾应用程序获取当前时间点

  •  2
  • tzot  · 技术社区  · 16 年前

    >>> print totem_object.props.current_time
    732616
    

    据我所知是毫秒。

    到目前为止: 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'))
    

    1 回复  |  直到 16 年前
        1
  •  4
  •   Bruce van der Kooij    15 年前

    我目前正在研究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

    工具书类

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