But setting a refresh interval as long as 1 second makes the SeekBar UI looks very sluggish =/ Just…
Crístian Deives

Crístian Deives — In the MainActivity, try replacing the onPositionChanged(int) method with the following:

public void onPositionChanged(int position) {
if (mSeekbarAudio.getProgress() >= position){
Log.d(TAG, "onPositionChanged: not setting progress");
if (!mUserIsSeeking) {
mSeekbarAudio.setProgress(position, true);
Log.d(TAG, String.format("setPlaybackPosition: setProgress(%d)", position));

This will ensure that the SeekBar won’t jump backwards as the audio is being played.

Here’s a link to a media player sample that uses MediaSession and a Service. Take a look at the PlaybackProgress class. It uses a different strategy where the movement of the SeekBar’s progress is actually done in UI code, and not in the player itself. When playback state changes to PLAYING, then the UI code simply starts an Executor and increments the SeekBar until the state changes to PAUSED, or STOPPED.

Like what you read? Give Nazmul Idris (Naz) a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.