title: Play Rtsp audio stream in Android media player
body: <p>I want to play an <a href="http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol" rel="nofollow">RTSP</a> audio stream in Android media player. I was trying to directly bind to an RTSP link in media player. Sometimes it's playing fine, but now it didn't play and showed a media player error:</p>
  
  <blockquote>
    <p>MediaPlayer(808): error (1, -2147483648).</p>
  </blockquote>
  
  <p>Where is the problem?</p>
  
  <p>Here is my some part of the code:</p>
  
  <pre><code>public class PlayRadio extends AsyncTask&lt;Void, Void, Void&gt; {
  
      @Override
      protected Void doInBackground(Void... arg0) {
          // TODO Auto-generated method stub
          setDataSource(rtspUrl);
          Log.e("inside doinbackground....", path);
          return null;
      }
      @Override
      protected void onPostExecute(Void result) {
          // TODO Auto-generated method stub
          super.onPostExecute(result);
  
          player.setOnPreparedListener(new OnPreparedListener() {
  
              public void onPrepared(MediaPlayer mp) {
                  player.start();
                  Toast.makeText(getApplicationContext(), "starting..", Toast.LENGTH_LONG).show();
              }
          });
          player.setAudioStreamType(AudioManager.STREAM_MUSIC);
      }
  }
  
  private void setDataSource(String path2) {
      // TODO Auto-generated method stub
          player=new MediaPlayer();
          try {
              Uri a =Uri.parse("rtsp://stream.rtm.swiftserve.com/live/rtm/rtm-ch010");
  
              player.setDataSource(getApplicationContext(),a);
              player.prepareAsync();
          }
          catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          //Log.e("tempPath", tempPath);
      }
  </code></pre>