title: seek bar not working when playing song from sd card
body: <p>in my app i am trying to play a media player along with a seek bar. When i tried to play the song from a folder stored in my app it was working fine and the seek bar get moved.</p>
  
  <p>When i tried to play continuous songs from SD card it gets crashed and in logcat it showed the following error.</p>
  
  <pre><code>ERROR/sdcard play(2500): 02 - bird flu.mp3
  ERROR/MediaPlayer(2500): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported
  ERROR/MediaPlayer(2500): error (1, -4)
  ERROR/MediaPlayer(2500): Attempt to call getDuration without a valid mediaplayer
  ERROR/MediaPlayer(2500): error (-38, 0)
  ERROR/sdcard play(2500): 03 Un Mela Aasadhaan.mp3
  ERROR/MediaPlayer(2500): setDataSource called in state 0
  ERROR/MediaPlayer(2500): prepareAsync called in state 0
  ERROR/MediaPlayer(2500): Attempt to call getDuration without a valid mediaplayer
  ERROR/MediaPlayer(2500): error (-38, 0)
  </code></pre>
  
  <p>Following is my code</p>
  
  <pre><code> sv = (SurfaceView)findViewById(R.id.surfaceView1);
  //        mediaPlayer =MediaPlayer.create(this, R.raw.b);        
  init_mediaPlayer();     
  
  
  // sv.postDelayed(runnable,200);                
    seek = (SeekBar)findViewById(R.id.seekBar1);
  
  
   seek.setMax(mediaPlayer.getDuration());
  
  System.out.println("**** MEDIA PLAYER DURATION "+ mediaPlayer.getDuration());       
  
  
  play.setOnClickListener(new View.OnClickListener() 
  
  {
  public void onClick(View v) 
  
  {
  
  mediaPlayer.start();
  
  myHandler.post(runn);
  
  isPlaying = true;
  
  }
  
  });
  
  
  pause.setOnClickListener(new View.OnClickListener() 
  
  {   
  
  public void onClick(View v) 
  
  {
  
  mediaPlayer.pause();
  
  
  mediaPlayer.prepare();
  
  
  }
  
  });
  
  seek.setProgress(mediaPlayer.getCurrentPosition());
  
  System.out.println("**** MEDIA PLAYER CURRENT DURATION "+ mediaPlayer.getCurrentPosition());
  
  }
  
  
  private void init_mediaPlayer() 
      {
  
   System.gc();
  
  final String[] proj = { MediaStore.Audio.Media._ID,MediaStore.Audio.Media.DATA,MediaStore.Audio.Media.DISPLAY_NAME,MediaStore.Audio.Media.SIZE };
  
            Log.e("media",""+proj);
  
  
  musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,proj, null, null, null);
  
   Log.e("media1",""+musiccursor);
  
  
   count = musiccursor.getCount();
  
  Log.e("media2",""+count);
  
   if(musiccursor!=null)
  
  {
  
  musiccursor.moveToFirst();
  
  MediaPlayer mediaPlayer = new  MediaPlayer();
  
  do{
  
  filename=musiccursor.getString(2);
  
  Log.e("sdcard play",filename);
  
  mediaPlayer.setDataSource(filename);
  
  mediaPlayer.prepare();
  
  if(mediaPlayer.getCurrentPosition()==mediaPlayer.getDuration())         
  {                           
  end=musiccursor.moveToNext();                       
  }               
  }               
  while(end);         
  }
  </code></pre>