title: Android - MediaPlayer, how to catch broken url when streaming
body: <p>I have a little application that streams from differents urls from the net, I would like to handle invalid/broken url, I have tried the various catch offered but even when streaming a broken file, I can see my log in the log, all I see is </p>
  
  <pre><code> Error (1,-1004) 
  </code></pre>
  
  <p>here is my code for the moment</p>
  
  <pre><code> mediaPlayer.reset();
          try {
              mediaPlayer.setDataSource(urlString);
              Log.w("myApp", "0");
              mediaPlayer.prepareAsync(); // might take long! (for buffering, etc)
              playPauseButton.setVisibility(View.INVISIBLE);
               progressBar1.setVisibility(View.VISIBLE);
              mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                  @Override
                  public void onPrepared(MediaPlayer mediaPlayer) {
                      // TODO Auto-generated method stub
  
                      duration = mediaPlayer.getDuration();
                      textDuration.setText(getDurationString(duration/1000));
                      progress.setMax(duration);
                      playPauseButton.setChecked(true); 
                      mediaPlayer.start();
                      playPauseButton.setVisibility(View.VISIBLE);
                       progressBar1.setVisibility(View.INVISIBLE);
                  }
              });
  
          } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              Log.w("myApp", "1");
              e.printStackTrace();
          } catch (SecurityException e) {
              // TODO Auto-generated catch block
              Log.w("myApp", "2");
              e.printStackTrace();
          } catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              Log.w("myApp", "3");
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              Log.w("myApp", "4");
              e.printStackTrace();
          }
  </code></pre>
  
  <p>Thank you for the help .)</p>