title: How to set duration of android mediaPlayer on start activity
body: <p>I need help to set duration of <code>MediaPlayer</code> on start activity.</p>
  
  <p>I have tried using <code>seekTo()</code> but its not working correctly.</p>
  
  <p>Here is what I'm doing:</p>
  
  <pre><code>protected void Player(String bURL, int seekTo){
      btn = (Button) findViewById(R.id.playpauseBtn);
      setVolumeControlStream(AudioManager.STREAM_MUSIC);
      mediaPlayer = new MediaPlayer();
      mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      try {
          mediaPlayer.setDataSource(bURL);
          mediaPlayer.prepareAsync();
          mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
              @Override
              public void onPrepared(MediaPlayer mp) {
                  if (!mediaPlayer.isPlaying()) {
                      if (seekTo != 0) {
                          mediaPlayer.seekTo(seekTo);
                      }
                      mediaPlayer.start();
                  }
              }
          });
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>