9 def _command(self,*command):
10 subprocess.call([ 'alsaplayer' ] + list(command))
12 def _get_status(self):
14 for line in subprocess.Popen(['alsaplayer', '--status'], stdout=subprocess.PIPE).stdout:
15 if not ':' in line: continue
16 k, v = line.split(':',1)
17 status[k.strip()] = v.strip()
21 self._command('--start')
24 if self._get_status()['speed'] == '0%':
30 self._command('--stop')
33 self._command('--prev')
36 self._command('--next')
39 self._command('--jump', str(n))
42 self._command('--clear')
45 self._command('--enqueue', str(f))
48 self._command('--speed', str(v))
51 class Action(Actions.Action):
53 def __init__(self, name, action, player, *args):
54 Actions.Action.__init__(self, name)
59 def __call__(self, binding):
60 getattr(self._player, self._action)(*self._args);
62 class Dispatcher(object):
64 def __init__(self, action):
67 def __call__(self, name, *args):
68 return Action(name, self._action, *args)
70 Play = Dispatcher('play')
71 Pause = Dispatcher('pause')
72 Stop = Dispatcher('stop')
73 Toggle = Dispatcher('toggle')
74 Prev = Dispatcher('prev')
75 Next = Dispatcher('next')
76 Jump = Dispatcher('jump')
77 Clear = Dispatcher('clear')
78 Add = Dispatcher('add')