Ejemplo n.º 1
0
    private void handlePlaylistMessage(SqueezePlayer player, String[] messageParts) {
      String action = messageParts[2];

      if (action.equals("newsong")) {
        player.setMode(Mode.play);
      } else if (action.equals("pause")) {
        player.setMode(messageParts[3].equals("0") ? Mode.play : Mode.pause);
      } else if (action.equals("stop")) {
        player.setMode(Mode.stop);
      }
    }
Ejemplo n.º 2
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));
     }
   }
 }