// private void readHeaders(InputStream stream) { // try { // char firstChar = (char)stream.read(); // char nextChar; // String headerLine = String.valueOf(firstChar); // while(true) { // nextChar = (char)stream.read(); // // if (firstChar == '\r' && nextChar == '\n') { // System.out.println(headerLine); // headerLine = ""; // System.out.println(); // } // // headerLine = headerLine.concat(String.valueOf(nextChar)); // // // firstChar = nextChar; // } // } catch (IOException ex) { // Logger.getLogger(ShoutcastPlayer.class.getName()).log(Level.SEVERE, null, ex); // } // } private Map<String, String> getHeaders(ShoutcastBufferedInputStream stream) { Map<String, String> map = new HashMap(); String line = ""; try { for (int hex = stream.read(); ; ) { if (hex == 10) { // 10 is 0a in hex and is \n String[] lineSplit = line.split(":", 2); if (lineSplit.length > 1) { map.put(lineSplit[0], lineSplit[1]); } else { map.put("Unknown", line); } if (line.length() == 0) { // 13 = 0D in hex and is \r break; } line = ""; } else { if (hex != 13) { // 13 = 0D in hex and is \r line = line.concat(String.valueOf((char) hex)); } } hex = stream.read(); } } catch (IOException ex) { Logger.getLogger(ShoutcastPlayer.class.getName()).log(Level.SEVERE, null, ex); } return map; }
private void playMetadataStream() { dataStream.metaint = Integer.parseInt(metaint); playInputStream(dataStream); }