maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks. (https://talk.maemo.org/showthread.php?t=21182)

qwerty12 2008-06-22 07:09

[ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
1 Attachment(s)
This daemon monitors when the button on the headset is pressed and makes the media player pause the playing song.

Download: Attached.

Install instructions :
  1. Install deb.
  2. Run Media player or Canola.
  3. Play a track.
  4. Press headset button.
  5. Enjoy as song pauses.
  6. If you wish, edit /usr/lib/hsetctrl/hsetctrl.py to change the program it runs.


Credits:
Media players supported by the default configuration:
  • The built-in, included media player with OS2008.
  • Canola*

"Configurations" available:
Default - This config uses dbus-send to send a pause message to the osso-media-server. So this config would only work with those players that use osso-media-server.
MPlayer - This one uses key-presses sent via xte to manipulate mplayer. Pressing the headset button will send a Return key press and pause the playing video.

Your Own. - Make your own command run when you press the button. If your program can be controlled by dbus, run dbus-monitor and make a dbus-send command. Or if by key presses, find out which one and make xte send that key press. Also, for example, on the bitsmithy website, there is a command to run flite to speak the time.

The original script to do this with a Bluetooth headset used xte to control the built in media player. I replaced that xte command with the dbus one as it didn't require focus to be on the media player window.
I don't really have an easy way to switch so edit /usr/bin/hsetctrl.py as root, manually. I've put comments in the file.

*For canola, it only works for playing/pausing the music by default as that uses osso-media-server. Movies won't work for example because that uses mplayer. But it wouldn't be hard to find the key press event and make the headset-control app run that instead.

(BTW. If anyone is into headset modding, grab the kernel source and look at retu-headset.c)

(If you get unable to install (it probably won't say that but for me it does (with EVERY program that adds something to init), do this:
sudo gainroot
mv /etc/rc2.d/S99hsetctrl /etc/rc2.d/S99hsetctrl1
apt-get -f install
mv /etc/rc2.d/S99hsetctrl1 /etc/rc2.d/S99hsetctrl
)

EDIT: Version 0.2 uploaded. Little bugs fixed.

tz1 2008-07-12 21:21

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
I needed the python-dbus support installed.

Also, it doesn't seem to work. I have an aliph jawbone on an n810 with diablo. I get:

Code:

signal sender=:1.0 -> dest=(null destination) path=/com/nokia/osso_hp_ls_controller; interface=com.nokia.osso_hp_ls_controller.headset; member=button_pressed
signal sender=:1.0 -> dest=(null destination) path=/com/nokia/osso_hp_ls_controller; interface=com.nokia.osso_hp_ls_controller.headset; member=button_released

when I press and release, not the hal events.

qwerty12 2008-07-12 21:25

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
Well, this is for the wired headset. (My bad, I should have mentioned that). if you want to use a bluetooth headset, check out www.bitsmithy.net

tz1 2008-07-13 16:11

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
I forgot the original headset had that button. Actually this might be even better.

Laughing Man 2008-07-14 01:48

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
I always wondered what that even did by default (I never figured it out).

sakamoto 2008-07-14 02:19

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
That's great!! Working fine with the bundle headset, Thanks!:)

But seem like can't work with my another headset, which is come with my N81 phone :(

Saka

Saturn 2008-07-26 23:20

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
Quote:

Originally Posted by Laughing Man (Post 202681)
I always wondered what that even did by default (I never figured it out).

one thing it does by default is to answer or end a call in the 'internet call' application.

ericcmi 2008-07-27 20:39

Possible to make it compatable with both blutooth button as well as wired buton?
 
Would it be possible to make this compatible with both bluetooth headset button as well as wired button?

That would be much appreciated among the community.

Or even dream up a way that makes it possible for people to easily change the event of the button press from a seprate file so that the function of the button can be changed easily simply by overwriting a file.

but really, the community has been waiting for a way to pause canola with a bluetooth headset button for a very very long time.

Thanks for the work.

ericcmi 2008-07-28 06:09

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
I tried to hack this together myself.
But its not working.
I used the deb installer and replaced /usr/lib/hsetvtrl/hsetctrl.py with the below script which used dbus to start and stop canola/mplayer.

If i run just 'dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause' in the terminal while canola is running I get a working play/pause system. However this does not work when trying to use it in the script below.


Here's the script I am using:
Code:

#!/usr/bin/env python2.5
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

import dbus
import gobject
import os

def main():

        dbus_loop = gobject.MainLoop()
        bus = dbus.SystemBus()


                def on_button_pressed (sender=None):
                os.system('run-standalone.sh dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause 2> /dev/null 1> /dev/null')
   

headset = bus.get_object('com.nokia.osso_hp_ls_controller', '/com/nokia/osso_hp_ls_controller')
headset_iface = dbus.Interface(headset, dbus_interface='com.nokia.osso_hp_ls_controller.headset')
headset_iface.connect_to_signal('button_pressed', on_button_pressed, sender_keyword='sender')

        dbus_loop.run()

if __name__ == "__main__":
        main()

Do you see any flaws? Why does my bluetooth button not calling the dbus command properly? I'm not to certian what all is done by the deb installer, and im a python newb. so, any comments are welsome.

Nif 2008-10-14 06:54

Re: [ANNOUNCE] headset-control : Make the headset button actually manipulate tracks.
 
Hi

I see there has been no activity for some time on this thread but I will still give my question a try:

What are the commands to put into the code to enable play/pause while having Canola configured with mplayer for the music?

Background is that I want to use mplayer in stead of oms in Canola to boost the volume. I also want the play/pause functionality described here which works very nicely with oms running for music. So I now just want best of both worlds ;-)


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

vBulletin® Version 3.8.8