Active Topics

 


Reply
Thread Tools
Posts: 31 | Thanked: 44 times | Joined on Nov 2009 @ Czech Republic
#1
I develop an application in python for N900. I want to communicate with the build in media player from Nokia. Getting playback state/metadata/volume and switching tracks is all ok (all based on the dbus logs).
Last thing I need is to control the media player (or system global) volume.

Code:
signal sender=:1.49 -> dest=(null destination) serial=1459 path=/com/nokia/mafw/renderer/gstrenderer; interface=com.nokia.mafw.extension; member=property_changed
   string "volume"
   variant       uint32 54
I can receive this signal but sending it doesn't change the volume.

Is there any way how to control the volume?
 
Posts: 432 | Thanked: 645 times | Joined on Mar 2009
#2
Originally Posted by moneytoo View Post

Code:
signal sender=:1.49 -> dest=(null destination) serial=1459 path=/com/nokia/mafw/renderer/gstrenderer; interface=com.nokia.mafw.extension; member=property_changed
   string "volume"
   variant       uint32 54
I can receive this signal but sending it doesn't change the volume.
The dbus-call you are using is just a system notification that the property has changed and does not change the property itself.

Originally Posted by moneytoo View Post
Is there any way how to control the volume?
Please don't use the dbus api directly. You can mess up the settings by not using it correctly. There is a really nice high-level API for the multimedia framework. Further you have the python-bindings for it and if that is not enough even a guide how to use the C-APIs, which don't have python bindings yet. So please use that approach in your application.

Daniel
 
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
 
Posts: 31 | Thanked: 44 times | Joined on Nov 2009 @ Czech Republic
#4
Thanks for the API references and d-bus signal (works fine). I will have to switch to C APIs at some point anyway.
 
Posts: 21 | Thanked: 6 times | Joined on Apr 2010
#5
Originally Posted by pycage View Post
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.
Hi! I played a little bit with the change the volume code to get rid of the time out problem. I found out that if I change --print-reply to --type=method_call the problem is solved (but what maybe is a bigger problem is that I dont really know if that may give problems in other areas ). An example, set max volume:
Code:
dbus-send --session --type=method_call --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:100
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:15.