View Single Post
Posts: 21 | Thanked: 4 times | Joined on Apr 2008
#1
Here it is.
This python script will pause and play both mplayer and canola(and probably others) regardless of whether or not the media player is the active window(i.e. can be minimized.)

The main bit of the script is from http://www.bitsmithy.net/.
The other bit is from qwerty12 from this thread.

1. Copy this code to a file.
Code:
#!/usr/bin/env python2.5

from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

import dbus
import gobject
import os

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

def on_button_pressed (sender=None):
    os.system('dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause')
    

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()
2. Copy that file to the device.
3. cd to directory you copied to.
'cd /media/mmc1'
4. in console type:
Code:
python filename.py
filename.py = whatever you named the file you copiedthe script into.

This should work. python was installed with canola for me i believe. Should not be to difficult to get it if you dont have it.

Im working on a solution to have the on_button_pressed function use python to send the pause method rather than use the commandline way with os.system. If you can get it working that way, please do. Then please be sure to post it back here for everyone to enjoy.

Eric
 

The Following 3 Users Say Thank You to ericcmi For This Useful Post: