View Single Post
pycage's Avatar
Posts: 3,404 | Thanked: 4,474 times | Joined on Oct 2005 @ Germany
#3
In case you still want to use D-Bus (shouldn't hurt), here's how:

Retrieving the current volume:

Code:
bus = dbus.SessionBus()
obj = bus.get_object("com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer",
    "/com/nokia/mafw/renderer/gstrenderer")
mafw = dbus.Interface(obj, "com.nokia.mafw.extension")
volume = int(mafw.get_extension_property("volume")[1])
Changing the volume:

Code:
os.system("dbus-send --session --print-reply " \
    "--dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer " \
    "/com/nokia/mafw/renderer/gstrenderer " \
    "com.nokia.mafw.extension.set_extension_property " \
    "string:'volume' variant:uint32:%d &" \
    % volume)
I'm using os.system here because couldn't get it work otherwise. Note that --print-reply is necessary to make the volume change happen, but there won't come a reply, and it will timeout with an error. That's why I'm sending it to background using "&". Omitting --print-reply avoids the timeout with error message but won't change the volume at all.

Using the mafw libs would certainly be a much cleaner solution, but this does its job.
__________________
Tidings - RSS and Podcast aggregator for Jolla - https://github.com/pycage/tidings
Cargo Dock - file/cloud manager for Jolla - https://github.com/pycage/cargodock