Created
July 10, 2017 06:19
-
-
Save talhahasanzia/9c7c6b73eda3818abe4c876391419374 to your computer and use it in GitHub Desktop.
Media player update, SOF answer: https://stackoverflow.com/questions/17168215/seekbar-and-media-player-in-android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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