title: How to display progress dialog with media player ?
body: <p>There is a problem in the following media player that plays the audio stream when you press play if the stream is not available there is no any response from the program, How can I solve this issue, try to make progress dialog, but the solution does not work, maybe I did something wrong, but when you click on the progress bar appears first and then immediately disappears without waiting to start playback of music.</p>
  
  <p>setDataSource filed in advance a broken link, nothing has changed.</p>
  
  <p>Code media player with progress dialog:</p>
  
  <pre><code>private class ProgressTask extends AsyncTask &lt;Void,Void,Void&gt;{
          @Override
          protected void onPreExecute(){
              progressbar.setVisibility(View.VISIBLE);
          }
  
          @Override
          protected Void doInBackground(Void... arg0) {   
              preload();
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              MPplay();
              progressbar.setVisibility(View.GONE);               
  
          }
      }
  
  public void preload() {
      releaseMP();
      mediaPlayer = new MediaPlayer();
      mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      try {
          if(pdaStream.isChecked()){
              Main_stream = "http://145.255.233.204:58000/radio_pda";             
          }else{
              Main_stream = "http://145.255.233.204:58000/radio";
          }
      mediaPlayer.setDataSource(Main_stream);
      } catch (IOException e) {
            e.printStackTrace();
        }
      Log.d(LOG_TAG, "prepareAsync");
          mediaPlayer.prepareAsync();;
     }
  
  public void MPplay(){
      mediaPlayer.setOnPreparedListener(new OnPreparedListener() {  
          @Override  
          public void onPrepared(MediaPlayer mp) {
              mp.start();
          }  
          });
  }
  </code></pre>