title: How to develop a live streaming radio application in android from a given web proxy
body: <p>I am developing a live streaming radio application in android, I have a link which contain a .pls file,  on clicking the link it will be downloaded as a .pls file .I want to play the music stream live from a web proxy to my android application.The server is 24X7 running .I have tried some codings but I am getting some error , Can anybody help me here..</p>
  
  <p>giving my logcat below</p>
  
  <pre><code>01-31 01:33:43.209: E/MediaPlayer(1216): error (1, -2147483648)
  
  01-31 01:33:43.309: E/MediaPlayer(1216): Error (1,-2147483648)
  
  01-31 01:33:45.549: I/Choreographer(1216): Skipped 252 frames!  The application may be doing too much work on its main thread.
  
  01-31 01:33:45.699: I/Choreographer(1216): Skipped 32 frames!  The application may be doing too much work on its main thread.
  </code></pre>
  
  <p>Java Class :</p>
  
  <pre><code>import java.io.IOException;
  
  import android.app.Activity;
  import android.media.MediaPlayer;
  import android.media.MediaPlayer.OnBufferingUpdateListener;
  import android.media.MediaPlayer.OnPreparedListener;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.ProgressBar;
  
  public class MainActivity extends Activity implements OnClickListener {
  
      private ProgressBar playSeekBar;
  
      private Button buttonPlay;
  
      private Button buttonStopPlay;
  
      private MediaPlayer player;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          initializeUIElements();
  
          try {
              initializeMediaPlayer();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  
      private void initializeUIElements() {
  
          playSeekBar = (ProgressBar) findViewById(R.id.progressBar1);
          playSeekBar.setMax(100);
          playSeekBar.setVisibility(View.INVISIBLE);
  
          buttonPlay = (Button) findViewById(R.id.button1);
          buttonPlay.setOnClickListener(this);
  
          buttonStopPlay = (Button) findViewById(R.id.button2);
          buttonStopPlay.setEnabled(false);
          buttonStopPlay.setOnClickListener(this);
  
      }
  
      public void onClick(View v) {
          if (v == buttonPlay) {
              startPlaying();
          } else if (v == buttonStopPlay) {
              stopPlaying();
          }
      }
  
      private void startPlaying() {
          buttonStopPlay.setEnabled(true);
          buttonPlay.setEnabled(false);
  
          playSeekBar.setVisibility(View.VISIBLE);
  
          player.prepareAsync();
  
          player.setOnPreparedListener(new OnPreparedListener() {
  
              public void onPrepared(MediaPlayer mp) {
                  player.start();
              }
          });
  
      }
  
      private void stopPlaying() {
          if (player.isPlaying()) {
              player.stop();
              player.release();
              try {
                  initializeMediaPlayer();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
          buttonPlay.setEnabled(true);
          buttonStopPlay.setEnabled(false);
          playSeekBar.setVisibility(View.INVISIBLE);
      }
  
      private void initializeMediaPlayer() throws IOException {
          player = new MediaPlayer();
          try {
            player.setDataSource("//.pls file link");
          //
          } catch (IllegalArgumentException e) {
              e.printStackTrace();
          } catch (IllegalStateException e) {
              e.printStackTrace();
          }
  
          player.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
  
              public void onBufferingUpdate(MediaPlayer mp, int percent) {
                  playSeekBar.setSecondaryProgress(percent);
                  Log.i("Buffering", "" + percent);
              }
          });
      }
  
      @Override
      protected void onPause() {
          super.onPause();
          if (player.isPlaying()) {
              player.stop();
          }
      }
  }
  </code></pre>