|
|
2010-06-01
, 06:05
|
|
Posts: 105 |
Thanked: 26 times |
Joined on May 2010
|
#2
|
|
|
2010-06-01
, 06:18
|
|
|
Posts: 91 |
Thanked: 32 times |
Joined on Jan 2008
@ Near: Gilroy, CA
|
#3
|
|
|
2010-06-08
, 10:55
|
|
|
Posts: 288 |
Thanked: 113 times |
Joined on Dec 2009
@ Germany
|
#4
|
This script is exactly what I've been looking for! Thank you so much!
Is there any way to allow this script to work while the screen is off?
|
|
2010-07-20
, 13:49
|
|
|
Posts: 876 |
Thanked: 396 times |
Joined on Dec 2009
|
#5
|
|
|
2010-07-24
, 22:36
|
|
Posts: 223 |
Thanked: 79 times |
Joined on Apr 2010
@ Lebanon- Beirut
|
#6
|
Is it possible? Also, how would I have to change the script to get the following functionality:
1 click = play/pause
2 clicks = next track
3 clicks = previous track
(without long clicks, accidental clicks aren't an issue for me)
Thanks!
|
|
2011-04-29
, 20:28
|
|
Posts: 435 |
Thanked: 769 times |
Joined on Apr 2010
|
#7
|
Is there any way to allow this script to work while the screen is off?
# N900 focus button Media Player control # thp 2010-05-31 # # The last press must be held for about 1 second, # so for a three-press, you would do short-short-long. # # two-press: next # three-press: previous # four-press: toggle pause # import gtk import gobject import dbus import dbus.glib import hildon FOCUS_FILE = '/sys/devices/platform/camera_button/bus/devices/cam_focus/state' TIMEOUT = 1000 MAFW_OBJECT = 'com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer' MAFW_PATH = '/com/nokia/mafw/renderer/gstrenderer' MAFW_INTF = 'com.nokia.mafw.renderer' METHODS = [None, 'next', 'previous', 'pause'] class FocusMonitor(object): def __init__(self): self.fp = open(FOCUS_FILE, 'r') self.fp.read() self.source_id = gobject.io_add_watch(self.fp, \ gobject.IO_PRI, \ self.on_state_changed) self.timeout_id = None self.active = False self.event_count = 0 self.session_bus = dbus.SessionBus() self.widget = gtk.Label() def on_state_changed(self, source, cb_condition): self.fp.seek(0, 0) self.active = (self.fp.read().strip() == 'active') if self.active: self.event_count += 1 if self.timeout_id is not None: gobject.source_remove(self.timeout_id) self.timeout_id = gobject.timeout_add(TIMEOUT, self.on_timeout) return True def banner(self, message): hildon.hildon_banner_show_information(self.widget, '', message) def on_timeout(self): if not self.active: self.event_count = 0 self.timeout_id = None return False if self.event_count > 1 and self.event_count <= len(METHODS): o = self.session_bus.get_object(MAFW_OBJECT, MAFW_PATH) i = dbus.Interface(o, MAFW_INTF) method_name = METHODS[self.event_count-1] method = getattr(i, method_name) try: method() self.banner(method_name) except Exception, e: if method_name == 'pause': try: i.play() self.banner('play') except: pass self.event_count = 0 self.timeout_id = None return False FocusMonitor() gtk.main()