Notices


Reply
Thread Tools
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:
antikx's Avatar
Posts: 43 | Thanked: 12 times | Joined on Jun 2008 @ Winnpeg, MB, CAN
#2
thanks for posting the script
when I run it I get this:
process 4498: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-Bus not built with -rdynamic so unable to print a backtrace
Aborted
__________________
-Antikx
n810 running Diablo

http://www.tyrannozaurus.com
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#3
I'd be interested in seeing what you can do as I'd be interested in replacing the dbus-send command with the proper python dbus commands.

Have you thought about looking into daemonising it like I do with headset-control?

Btw, replace:
os.system('dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause')

with:
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')
 
antikx's Avatar
Posts: 43 | Thanked: 12 times | Joined on Jun 2008 @ Winnpeg, MB, CAN
#4
thanks qwerty12, running it as non-root did the trick.
__________________
-Antikx
n810 running Diablo

http://www.tyrannozaurus.com
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#5
Oh, you saw?

I edited with the run-standalone stuff because using run-standalone lets you run it as root or non-root.
 
Reply

Thread Tools

 
Forum Jump


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