Question

I want to find the exact time where a media file is currently paused at (or playing) in a running Totem instance using D-Bus. To be precise, what I want is available from the Totem python console (if the plugin exists and is enabled) by the following command:

>>> print totem_object.props.current_time
732616

which I understand is milliseconds.

So far: I've never used D-Bus before, so I'm in the process of going through D-Bus and python-dbus documentation. I've also fired up D-Feet and found that the org.gnome.Totem bus name and the /Factory object I can use the org.freedesktop.DBus.Properties interface methods.

I'm currently at this point:

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

I can't find even a proper how-to, so any help will be greatly appreciated.

Was it helpful?

Solution

I'm currently researching the the API for a different reason, I need to retrieve the path or location being played, and I stumbled upon this question.

First things first, you'll want to activate the D-Bus Service Plugin (Edit -> Plugins) which will expose the org.mpris.Totem service. Then on the /Player object and the org.freedesktop.MediaPlayer interface you can use the PositionGet() method to retrieve the current position.

This returns totem.props.current_time you were talking about.

Here's some code:

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

As for the whole org.gnome.Totem service and the Get/GetAll methods, I don't understand the entire purpose of those either. Looks like it has more to do with DBus itself than Totem specifically.

References

  1. http://git.gnome.org/browse/totem/tree/src/plugins/dbusservice/dbusservice.py
  2. http://developer.gnome.org/totem/stable/TotemObject.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top