title: Android SeekBar to control MediaPlayer progress
body: <p>I have a <code>SeekBar</code>, it displays correctly <code>MediaPlayer</code> progress. However, I have troubles with seeking - if I seek scroll box somewhere it just returns on the position where audio file is playing. </p>
  
  <pre><code>public class EntityPageActivity extends Activity implements Runnable, OnClickListener, OnSeekBarChangeListener{
      private SeekBar seekBar;
      private Button startMedia;
      private Button pauseMedia;
      private MediaPlayer mp;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.entity_page);             
  
          AudioControl();         
  
      }
  
      public void AudioControl(){
          seekBar = (SeekBar) findViewById(R.id.seekBar);
          startMedia = (Button) findViewById(R.id.play);
          pauseMedia = (Button) findViewById(R.id.pause);
          startMedia.setOnClickListener(this);
          pauseMedia.setOnClickListener(this); 
      }
  
      public void run() {
          int currentPosition= 0;
          int total = mp.getDuration();
          while (mp!=null &amp;&amp; currentPosition&lt;total) {
              try {
                  Thread.sleep(1000);
                  currentPosition= mp.getCurrentPosition();
              } catch (InterruptedException e) {
                  return;
              } catch (Exception e) {
                  return;
              }            
              seekBar.setProgress(currentPosition);
          }
      }
  
      public void onClick(View v) {
          if (v.equals(startMedia)) {
              if (mp != null &amp;&amp; mp.isPlaying()) return;
              if(seekBar.getProgress() &gt; 0) {
                  mp.start();
                  return;
              }
              mp = MediaPlayer.create(EntityPageActivity.this, R.raw.gl1);
              mp.start();                     
              seekBar.setProgress(0);
              seekBar.setMax(mp.getDuration());
              new Thread(this).start();
          }
  
          if (v.equals(pauseMedia) &amp;&amp; mp!=null) {
              mp.pause();
          }       
  
      }
  
      public void onStartTrackingTouch(SeekBar seekBar) {
      }
  
      public void onStopTrackingTouch(SeekBar seekBar) {
      }
  
      public void onProgressChanged(SeekBar seekBar, int progress,
              boolean fromUser) {
          if(fromUser) mp.seekTo(progress);
  
      }
  }
  </code></pre>
  
  <p>Thus, <code>onProgressChanged</code> isn't enough to allow <code>SeekBar</code> to control <code>MediaPlayer</code>?</p>
  
  <p>What should I add/correct to allow seeking?</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I found out that <code>onProgressChanged</code> is never invoked by some reason. However I can't figure out why</p>