Notices


Reply
Thread Tools
christye's Avatar
Posts: 60 | Thanked: 9 times | Joined on Apr 2010 @ Swindon, UK
#1
Hey guys,

I had posted this in the N900 forum, however, I feel that this may be a better place for it, as I guess it isn't specifically an N900 issue.

Having a bit of a problem with DBUS.

What I'm trying to do is when my bluetooth headset is connected, I want the phone to start playing music. Once the phone is disconnected from the headset, I want it to stop. Sounded pretty simple, I had already played a little bit with dbus (underclocking when locked).

Anyway. I have the command to play music in a file (/usr/local/bin/connect) which contains this command:
Code:
dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.play
The line in the "dbus-scripts-settings" file looks like this:
Code:
/usr/local/bin/connect * * org.bluez.Adapter RemoteDeviceConnected 0C:6E:00:00:17:8F
I did try the GUI application as it would save me typing some. However, it didn't work with that, and it didn't work with me doing it manually either.

I typed in "dbus-scripts --debug" and at the end of the command it gave me the "Failed to open connection to session message bus null)". So I am all out of ideas. Are there any other ways I can test to find out where the fault lies?

Been trying this for hours now! Any help would be much appreciated.

Regards,
Chris
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#2
Use run-standalone.sh in your command file if you want to
execute dbus-send commands on the session bus.
run-standalone.sh sets up the appropriate session bus environment
variables.
run-standalone.sh dbus-send .....

Nicolai
 

The Following User Says Thank You to nicolai For This Useful Post:
christye's Avatar
Posts: 60 | Thanked: 9 times | Joined on Apr 2010 @ Swindon, UK
#3
Thanks for the reply. I had no idea about the 'runstandalone.sh' command =]

Some progress has been made!

It will now play music based upon an event such as a keyboard slide, so I am almost there.

Now I just have to make it play on bluetooth headset connect, which currently isn't working.
 
christye's Avatar
Posts: 60 | Thanked: 9 times | Joined on Apr 2010 @ Swindon, UK
#4
Done it!

I knew the scripts worked, I had tested it with various other dbus signals (such as keyboard open / closed, screen locked / unlocked). I also knew that the helmet would connect and I could start music playing myself.

Something I should have explained first - it's a bluetooth motorbike helmet, so it makes my life much easier if I don't have to touch the phone (voice command would be very nice though!).

Anyway, the only reason I could think of as to why it wasn't working would have been if the dbus wasn't being told to look at the correct thing. Using this command:
Code:
dbus-scripts --debug --system
I could monitor the signals. I connected the helmet and it threw up about 6 (I didn't actually count) different things going on. So I typed one of these into the dbus file. And it worked wonderfully. I repeated the same process to see what I needed to tell it to look for on disconnect as well.

So, there we go. It wasn't so bad after all.

Only thing I have to look at now is why, upon restarting the phone can't I use any command to start music playing - I have to press the play button on the widget instead. Anyway, I am happy with the results!
 

The Following User Says Thank You to christye For This Useful Post:
MohammadAG's Avatar
Posts: 2,473 | Thanked: 12,265 times | Joined on Oct 2009 @ Jerusalem, PS/IL
#5
Originally Posted by christye View Post
Only thing I have to look at now is why, upon restarting the phone can't I use any command to start music playing - I have to press the play button on the widget instead. Anyway, I am happy with the results!
Cause there isn't any playlist assigned to the renderer, so it doesn't know what to play.

Code:
method call sender=:1.595 -> dest=com.nokia.mafw.playlist serial=128 path=/com/nokia/mafw/playlist; interface=com.nokia.mafw.playlist; member=create_playlist
   string "FmpAudioPlaylist"
method return sender=:1.87 -> dest=:1.595 reply_serial=128
   uint32 4
You'll need to create a playlist with the name FmpAudioPlaylist, since you already have one, a dbus reply would have the number of the playlist object (4 in my case above).

After that, you'll need to assign the playlist number above to the renderer.

Code:
method call sender=:1.595 -> dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer serial=226 path=/com/nokia/mafw/renderer/gstrenderer; interface=com.nokia.mafw.renderer; member=assign_playlist
   uint32 4
Now, chances are the playlist number will always be the same on your device (it will be different on other devices), you can get the number easily (if you don't want to listen to DBus) with:

Code:
Nokia-N900:~# grep FmpAudioPlaylist /home/user/.mafw-playlists/*
/home/user/.mafw-playlists/4:FmpAudioPlaylist
So, here's the lazy way of doing it.
Get the number as I showed you above, then
Code:
dbus-send --type=method_call --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.assign_playlist uint32:4

dbus-send --type=method_call --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.goto_index uint32:0

dbus-send --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.renderer.play
Replace 4 with the playlist you want (you can also use your saved playlists, it doesn't have to be FmpAudioPlaylist (just make sure it's not a video playlist)).

Replace the last 0 in the goto_index command with the song you want to start first, numbering starts at 0, so if you're looking at the number in the UI, subtract a 1.

Play the playlist, as per the last command.
 

The Following 4 Users Say Thank You to MohammadAG For This Useful Post:
Posts: 669 | Thanked: 433 times | Joined on May 2010
#6
Is there a command to close application gracefully (similar to what happens when you press the X of its window)?

the "kill" command is not good since the application does not remember its last state when closed with it.

When closed with the X it does.

Thanks.
 
Posts: 669 | Thanked: 433 times | Joined on May 2010
#7
I was trying to find a solution for these 2 issues in several threads and internet sources (including the great "phone control" wiki page) but was unsuccessful.

my two issues:

1. is it possible to answer a call from Skype using a DBUS command (not a regular phone call which can be answerd with this:

dbus-send --system --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.Answer)

2. how can the volume of the call itself be changed using dbus? setting the volume with:

dbus-send --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:50

won't affect the conversation voice level which i want to set to maximum.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 11:58.