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%':
29 def skip(self, distance):
30 self._command('--relative', str(distance))
33 self._command('--stop')
36 self._command('--prev')
39 self._command('--next')
42 self._command('--jump', str(n))
45 self._command('--clear')
48 self._command('--enqueue', str(f))
51 self._command('--speed', str(v))
54 class Action(Actions.Action):
56 def __init__(self, name, action, player, *args):
57 Actions.Action.__init__(self, name)
62 def __call__(self, binding):
63 getattr(self._player, self._action)(*self._args);
65 class Dispatcher(object):
67 def __init__(self, action):
70 def __call__(self, name, *args):
71 return Action(name, self._action, *args)
73 Play = Dispatcher('play')
74 Pause = Dispatcher('pause')
75 Skip = Dispatcher('skip')
76 Stop = Dispatcher('stop')
77 Toggle = Dispatcher('toggle')
78 Prev = Dispatcher('prev')
79 Next = Dispatcher('next')
80 Jump = Dispatcher('jump')
81 Clear = Dispatcher('clear')
82 Add = Dispatcher('add')