示例#1
0
 public void setVolume(String playerId, int volume) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   if (0 > volume) {
     volume = 0;
   } else if (volume > 100) {
     volume = 100;
   }
   sendCommand(player.getMacAddress() + " mixer volume " + String.valueOf(volume));
 }
示例#2
0
 public void showStringHuge(String playerId, String line, int duration) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(
       player.getMacAddress()
           + " show line1:"
           + line
           + " font:huge duration:"
           + String.valueOf(duration));
 }
示例#3
0
 public void showStrings(String playerId, String line1, String line2, int duration) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(
       player.getMacAddress()
           + " show line1:"
           + line1
           + " line2:"
           + line2
           + " duration:"
           + String.valueOf(duration));
 }
示例#4
0
    private void handlePlayersList(String message) {
      String[] playersList = decode(message).split("playerindex:\\d+\\s");
      for (String playerParams : playersList) {
        String[] parameterList = playerParams.split("\\s");

        // parse out the MAC address first
        String macAddress = null;
        for (String parameter : parameterList) {
          if (parameter.contains("playerid")) {
            macAddress = parameter.substring(parameter.indexOf(":") + 1);
            break;
          }
        }

        // if none found then ignore this set of params
        if (macAddress == null) continue;

        // see if this player exists in our config
        SqueezePlayer player = playersByMacAddress.get(macAddress);
        if (player == null) continue;

        // populate the player state
        for (String parameter : parameterList) {
          if (parameter.contains("ip")) {
            player.setIpAddr(parameter.substring(parameter.indexOf(":") + 1));
          } else if (parameter.contains("uuid")) {
            player.setUuid(parameter.substring(parameter.indexOf(":") + 1));
          } else if (parameter.contains("name")) {
            player.setName(parameter.substring(parameter.indexOf(":") + 1));
          } else if (parameter.contains("model")) {
            player.setModel(parameter.substring(parameter.indexOf(":") + 1));
          }
        }

        // tell the server we want to subscribe to player updates
        sendCommand(player.getMacAddress() + " status - 1 subscribe:10 tags:yagJlN");
      }
    }
示例#5
0
 public void next(String playerId) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(player.getMacAddress() + " playlist index +1");
 }
示例#6
0
 public void clearPlaylist(String playerId) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(player.getMacAddress() + " playlist clear");
 }
示例#7
0
 public void stop(String playerId) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(player.getMacAddress() + " stop");
 }
示例#8
0
 public void unPause(String playerId) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(player.getMacAddress() + " pause 0");
 }
示例#9
0
 public void playUrl(String playerId, String url) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(player.getMacAddress() + " playlist play " + url);
 }
示例#10
0
 public void syncPlayer(String playerId1, String playerId2) {
   SqueezePlayer player1 = getPlayer(playerId1);
   SqueezePlayer player2 = getPlayer(playerId2);
   if (player1 == null || player2 == null) return;
   sendCommand(player1.getMacAddress() + " sync " + player2.getMacAddress());
 }
示例#11
0
 public void powerOff(String playerId) {
   SqueezePlayer player = getPlayer(playerId);
   if (player == null) return;
   sendCommand(player.getMacAddress() + " power 0");
 }