title: synchronizing seekbar with the audio song
body: <p>I am playing a song from the sdcard.</p>
  
  <p>Its plays fine. I tried to implement the seekbar such that when the user moves the seekbar the song gets forwarded or rewnided as per the seek bar position.</p>
  
  <p>Here is the code</p>
  
  <pre><code>public class ViewAudio extends Activity implements  OnSeekBarChangeListener,OnSeekCompleteListener,OnCompletionListener,OnPreparedListener{
   @Override
    public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.audio_player);
  
          System.gc();
          Intent i = getIntent();
          Bundle extras = i.getExtras();
          filename = extras.getString("audiofilename");
  
          try {
              mPlayer.setDataSource(filename);
          } catch (IllegalArgumentException 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();
          }
  
          try {
              mPlayer.prepare();
          } catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
  
          mPlayer.setOnCompletionListener(this);
          mPlayer.setOnPreparedListener(this);
          mPlayer.setOnSeekCompleteListener((OnSeekCompleteListener) this);
  
          mPlayer.start();
  
          TextView tv=(TextView) findViewById(R.id.file);
          tv.setText("Playing "+filename);
  
          seekbar = (SeekBar)findViewById(R.id.seekBar1);
          mPlay = (Button)findViewById(R.id.play);
          mPause = (Button)findViewById(R.id.pause);
  
          seekbar.setProgress(0);
          seekbar.setOnSeekBarChangeListener(this);
          total = mPlayer.getDuration();
  
    }
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress,
          boolean fromUser) {
      Log.d("Progres changed",""+progress);
  
      if(fromUser){
          mPlayer.seekTo(progress);
          seekbar.setProgress(progress);
  
      }
  
  }
  
  }
  </code></pre>
  
  <p>Now where ever i click the seekbar the song is getting played from the beginning  not from the position i clicked. And it is not moving based on the song.</p>
  
  <p>Any one please help.</p>