private void executePlayerCommand(String playerCommandLine, Object commandParams) {
String[] commandParts = playerCommandLine.split(":");
String playerId = commandParts[0];
String playerCommand = commandParts[1];
MPD daemon = findMPDInstance(playerId);
if (daemon == null) {
// we give that player another chance -> try to reconnect
reconnect(playerId);
}
if (daemon != null) {
PlayerCommandTypeMapping pCommand = null;
try {
pCommand = PlayerCommandTypeMapping.fromString(playerCommand);
MPDPlayer player = daemon.getMPDPlayer();
switch (pCommand) {
case PAUSE: player.pause(); break;
case PLAY: player.play(); break;
case STOP: player.stop(); break;
case VOLUME_INCREASE: player.setVolume(player.getVolume() + VOLUME_CHANGE_SIZE); break;
case VOLUME_DECREASE: player.setVolume(player.getVolume() - VOLUME_CHANGE_SIZE); break;
case NEXT: player.playNext(); break;
case PREV: player.playPrev(); break;
case ENABLE:
case DISABLE:
Integer outputId = Integer.valueOf((String) commandParams);
MPDAdmin admin = daemon.getMPDAdmin();
MPDOutput output = new MPDOutput(outputId - 1); // internally mpd uses 0-based indexing
if (pCommand == PlayerCommandTypeMapping.ENABLE) {
admin.enableOutput(output);
} else {
admin.disableOutput(output);