def command_to_player(command, player): logging.debug('Sending command {command} to {player}'.format( command=command, player=player)) if player['type'] == 'youtube': if command == 'pause': return click(player, 0.01, 0.01) elif command == 'fullscreen': return click(player, 0.99, 0.01) else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'youtube-fs': if command == 'pause': return click(player, 0.5, 0.5) elif command == 'fullscreen': return keypress('Escape') else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'iplayer-fs': if command == 'pause': return click(player, 0.01, 0.01) elif command == 'fullscreen': return keypress('Escape') else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'iplayer': if command == 'pause': return click(player, 0.01, 0.01) elif command == 'fullscreen': return click(player, 0.42, 0.08) else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'mplayer': if command == 'pause': fifo.send('pause') return {'ok': True, 'message': 'done'} elif command == 'fullscreen': shell('xdotool', 'search', '--class', 'mplayer', 'windowactivate') fifo.send("vo_fullscreen") return {'ok': True, 'message': 'done'} else: return {'ok': False, 'message': 'command not supported'} else: logging.error('Type ' + player['type']) return {'ok': False, 'message': 'bad player detection'}
def voldown(): """On volume up request we: - Tell the window manager to decrease the volume and - Tell mplayer to increase the volume """ xorg.shell('xdotool', 'key', 'XF86AudioLowerVolume') fifo.send("volume -20") return 'ok'
def command_to_player(command, player): logging.debug('Sending command {command} to {player}'.format(command=command, player=player)) if player['type'] == 'youtube': if command == 'pause': return click(player, 0.01, 0.01) elif command == 'fullscreen': return click(player, 0.99, 0.01) else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'youtube-fs': if command == 'pause': return click(player, 0.5, 0.5) elif command == 'fullscreen': return keypress('Escape') else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'iplayer-fs': if command == 'pause': return click(player, 0.01, 0.01) elif command == 'fullscreen': return keypress('Escape') else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'iplayer': if command == 'pause': return click(player, 0.01, 0.01) elif command == 'fullscreen': return click(player, 0.42, 0.08) else: return {'ok': False, 'message': 'command not supported'} elif player['type'] == 'mplayer': if command == 'pause': fifo.send('pause') return {'ok': True, 'message': 'done'} elif command == 'fullscreen': shell('xdotool', 'search', '--class', 'mplayer', 'windowactivate') fifo.send("vo_fullscreen") return {'ok': True, 'message': 'done'} else: return {'ok': False, 'message': 'command not supported'} else: logging.error('Type ' + player['type']) return {'ok': False, 'message': 'bad player detection'}
def mute(): """On mute toggle request we: - Tell mplayer to toggle the volume - Tell the window manager to toggle the volume and """ if fifo.send("mute") == 'ok': return 'ok' else: xorg.shell('xdotool', 'key', 'XF86AudioMute') return 'ok'
def forward(seconds): """Send a skip forwards to mplayer only.""" logging.info('forward ' + str(seconds) + 's') return fifo.send("seek " + str(seconds))
def audlang(): """Tell mplayer to switch between audio languages.""" return fifo.send("switch_audio")
def sublang(): """Tell mplayer to switch between subtitle languages.""" return fifo.send("sub_select")
def sub(): """Tell mplayer to toggle subtitle visibility.""" logging.debug('sending subvisibility') return fifo.send("sub_visibility")
def osdoff(): """Tell mplayer to switch off on screen display.""" return fifo.send("osd 1")
def osdon(): """Tell mplayer to switch on on screen display.""" return fifo.send("osd 3")
def backward(seconds): """Send a skip backwards to mplayer only.""" logging.info('backward ' + str(seconds) + 's') return fifo.send("seek -" + str(seconds))