Skip to content
Permalink
Browse files

fixed headset support

  • Loading branch information
helmuth authored and xerxes2 committed Feb 21, 2011
1 parent 8e2075d commit d910438e27ea76e23844126d28582257389e2a93
Showing with 61 additions and 9 deletions.
  1. +9 −6 src/panucci/dbusinterface.py
  2. +51 −2 src/panucci/main.py
  3. +1 −1 src/panucci/playlist.py
@@ -35,12 +35,15 @@ def __init__(self, bus_name, path='/panucciInterface'):
self.player = None
self.gui = None
self.headset_device = None

# headset_button = dbus.SystemBus().get_object(
# 'org.freedesktop.Hal', '/org/freedesktop/Hal/devices/'
# 'platform_retu_headset_logicaldev_input' )
# self.headset_device = dbus.Interface(
# headset_button, 'org.freedesktop.Hal.Device')

try:
headset_button = dbus.SystemBus().get_object(
'org.freedesktop.Hal', '/org/freedesktop/Hal/devices/'
'platform_retu_headset_logicaldev_input' )
self.headset_device = dbus.Interface(
headset_button, 'org.freedesktop.Hal.Device')
except:
pass

def register_player(self, player):
self.__log.debug('Registered player.')
@@ -35,6 +35,7 @@
import pango

import cgi
import dbus

import panucci

@@ -277,9 +278,57 @@ def __init__(self, filename=None):
self.__window_fullscreen = False

if platform.MAEMO and interface.headset_device is not None:
print platform.MAEMO
print interface.headset_device
print 'Enable play/pause with headset button'
# Enable play/pause with headset button
interface.headset_device.connect_to_signal(
'Condition', self.handle_headset_button )
interface.headset_device.connect_to_signal('Condition', self.handle_headset_button)

# Monitor connection state of BT headset
system_bus = dbus.SystemBus()
def handler_func(device_path):
if device_path == '/org/freedesktop/Hal/devices/computer_logicaldev_input_1' and settings.play_on_headset and not player.playing:
player.play()
system_bus.add_signal_receiver(handler_func, 'DeviceAdded', 'org.freedesktop.Hal.Manager', None,
'/org/freedesktop/Hal/Manager')
# End Monitor connection state of BT headset

# Monitor BT headset buttons
system_bus = dbus.SystemBus()
def handle_bt_button(signal, button):
# See https://bugs.maemo.org/show_bug.cgi?id=8283 for details
if signal == 'ButtonPressed':
print 'Bluetooth Button pressed'

if button == 'play-cd':
player.play_pause_toggle()
elif button == 'pause-cd':
player.pause()
elif button == 'next-song':
#self.seekbutton_callback(None, short_seek)
print 'Bluetooth Button FWD pressed'
#lambda: self.do_seek(settings.seek_short)
#self.do_seek(settings.seek_short)


# Helmuth Kadusch: not very elegant, but it works...
# was this better?
# self.do_seek(settings.seek_short)
# Not working for me...

self.__player_tab.do_seek(settings.seek_short)

elif button == 'previous-song':
# self.seekbutton_callback(None, -1*short_seek)
print 'Bluetooth Button REW pressed'
# lambda: self.do_seek(-1*settings.seek_short)
# self.do_seek(-1*settings.seek_short)
self.__player_tab.do_seek(-1*settings.seek_short)


system_bus.add_signal_receiver(handle_bt_button, 'Condition', 'org.freedesktop.Hal.Device', None,
'/org/freedesktop/Hal/devices/computer_logicaldev_input_1')
# End Monitor BT headset buttons

self.main_window.connect('key-press-event', self.on_key_press)
player.playlist.register( 'file_queued', self.on_file_queued )
@@ -286,7 +286,7 @@ def get_playlist_item_ids(self):
""" Returns an iterator which yields a tuple which contains the
item's unique ID and a dict of interesting data (currently
just the title). """

for item in self.__queue:
yield str(item), { 'title' : item.title }

0 comments on commit d910438

Please sign in to comment.