コード例 #1
0
 private void handleStatusMessage(SqueezePlayer player, String[] messageParts) {
   for (String messagePart : messageParts) {
     // Parameter Power
     if (messagePart.startsWith("power%3A")) {
       String value = messagePart.substring("power%3A".length());
       player.setPowered(value.matches("1"));
     }
     // Parameter Volume
     else if (messagePart.startsWith("mixer%20volume%3A")) {
       String value = messagePart.substring("mixer%20volume%3A".length());
       player.setVolume(Integer.parseInt(value));
     }
     // Parameter Mode
     else if (messagePart.startsWith("mode%3A")) {
       String value = messagePart.substring("mode%3A".length());
       player.setMode(Mode.valueOf(value));
     }
     // Parameter Title
     else if (messagePart.startsWith("title%3A")) {
       String value = messagePart.substring("title%3A".length());
       player.setTitle(decode(value));
     }
     // Parameter Remote Title (radio)
     else if (messagePart.startsWith("remote_title%3A")) {
       String value = messagePart.substring("remote_title%3A".length());
       player.setRemoteTitle(decode(value));
     }
     // Parameter Artist
     else if (messagePart.startsWith("artist%3A")) {
       String value = messagePart.substring("artist%3A".length());
       player.setArtist(decode(value));
     }
     // Parameter Album
     else if (messagePart.startsWith("album%3A")) {
       String value = messagePart.substring("album%3A".length());
       player.setAlbum(decode(value));
     }
     // Parameter Genre
     else if (messagePart.startsWith("genre%3A")) {
       String value = messagePart.substring("genre%3A".length());
       player.setGenre(decode(value));
     }
     // Parameter Year
     else if (messagePart.startsWith("year%3A")) {
       String value = messagePart.substring("year%3A".length());
       player.setYear(Integer.parseInt(value));
     }
     // Parameter Artwork
     else if (messagePart.startsWith("artwork_track_id%3A")) {
       String value = messagePart.substring("artwork_track_id%3A".length());
       // NOTE: what is returned if not an artwork id? i.e. if a space?
       if (!value.startsWith(" ")) {
         value = "http://" + host + ":" + webPort + "/music/" + value + "/cover.jpg";
       }
       player.setCoverArt(decode(value));
     }
   }
 }
コード例 #2
0
    private void handlePrefsetMessage(SqueezePlayer player, String[] messageParts) {
      if (messageParts.length < 5) return;

      // server prefsets
      if (messageParts[2].equals("server")) {
        String function = messageParts[3];
        String value = messageParts[4];

        if (function.equals("power")) {
          player.setPowered(value.equals("1"));
        } else if (function.equals("volume")) {
          player.setVolume(Integer.parseInt(value));
        }
      }
    }