title: Update progress bar with media player
body: <p>I tried to use the <code>MediaPlayer</code> and display the current position in the <code>ProgressBar</code>. The media player itself works, but the <code>ProgressBar</code> displays nothing. Below is the code:</p>
  
  <pre><code>final Uri fileUri = Uri.fromFile(audioFile);
  mp = new MediaPlayer();
  mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
  new Thread(new Runnable() {
  
      @Override
      public void run() {
          try {
              mp.setDataSource(getApplicationContext(), fileUri);
              mp.prepare();
              mp.start();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  }).start();
  
  
  progress = findViewById(R.id.audioProgressBar);
  audioDuration = mp.getDuration();
  progress.setMax(100);
  
  new Thread(new Runnable() {
  
          @Override
          public void run() {
              while (progressStatus &lt;= audioDuration) {
                  progressStatus += 1;
                  handler.post(new Runnable() {
                      public void run() {
                          float progressFloat = ((float) mp.getCurrentPosition() / mp.getDuration()) * 100;
                          progress.setProgress((int) progressFloat);
                      }
                  });
                  try {
                      // Sleep for 200 milliseconds.
                      Thread.sleep(200);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }
      }).start();
  </code></pre>
  
  <p>I hope you can help me!</p>