Skip to content

Instantly share code, notes, and snippets.

@talhahasanzia
Created July 10, 2017 06:19
Show Gist options
  • Save talhahasanzia/9c7c6b73eda3818abe4c876391419374 to your computer and use it in GitHub Desktop.
Save talhahasanzia/9c7c6b73eda3818abe4c876391419374 to your computer and use it in GitHub Desktop.
private Handler mHandler = new Handler();
//Make sure you update Seekbar on UI thread
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if(mMediaPlayer != null){
int mCurrentPosition = mMediaPlayer.getCurrentPosition() / 1000;
mSeekBar.setProgress(mCurrentPosition);
}
mHandler.postDelayed(this, 1000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment