def action(self, action=None): """Received action. Parse it and send to correct module.""" if action in ['play', 'pause', 'next', 'prev', 'stop']: controller.send_command(action) return json.dumps(controller.get_current()) elif action in ['volUp', 'volDown']: pa_controller.change_volume(10 if action == 'volUp' else -10)
def notify(self, msg): """Receive command from client and execute it.""" try: command = msg['command'] if command in ['PLAY', 'PAUSE', 'NEXT', 'PREV']: controller.send_command(command) elif command == 'GET_TRACK': properties = controller.get_current() if properties: self.send(properties) except KeyError: pass
def current(self): """Client asked for current information.""" return json.dumps(controller.get_current())