title: Android streaming from icecast server get track information
body: <p>I have a stream from an icecast server downloading, and I can grab the information in the headers by doing the following:</p>
  
  <pre><code> URLConnection cn = new URL(mediaUrl).openConnection();   
      cn.connect();   
  
      int pos=1;
      String x;
      String y;
  </code></pre>
  
  <p>while (cn.getHeaderField(pos) != null)
          {
     x=cn.getHeaderFieldKey(pos);
     y = cn.getHeaderField(x);
     Log.e(":::::",""+x+" : "+y);
     pos++;
          }</p>
  
  <p>When I do this all of the headers I receive are shown as:</p>
  
  <p>content-type : audio/mpeg
   icy-br : 64
   ice-audio-info : ice-samplerate=22050;ice-bitrate=64;ice-channels=2
   icy-br : 64
   icy-description : RadioStation
   icy-genre : Classical, New Age, Ambient
   icy-name : RadioStation Example
   icy-private : 0
   icy-pub : 1
   icy-url : <a href="http://exampleradio.com" rel="nofollow noreferrer">http://exampleradio.com</a>
   server : Icecast 2.3.2
   cache-control : no-cache</p>
  
  <p>However if I open my stream in mplayer I get:</p>
  
  <pre><code> ICY Info: StreamTitle='artist - album - trackname' 
  </code></pre>
  
  <p>and with each time the song is changed, the new track information is sent appearing the same way in mplayer.</p>
  
  <p>In android when I attempt to read the icy-info all I get returned is null. Also how would I go about retrieving the new information from the headers while I am buffering from the stream? Because even if I try to read the header of something I already know exists whilst buffering such as:</p>
  
  <pre><code>  Log.e(getClass().getName()," "+cn.getHeaderField("icy-br"));
  </code></pre>
  
  <p>All I get returned is null. </p>
  
  <p>I hope this makes sense, I can post more code on request.</p>