Android Music Seekbar is not working (Idle)
try this
mediaFileLength = mediaPlayer.getDuration();
realtimeLength = mediaFileLength;
mediaPlayer.start();
finalTime = mediaPlayer.getDuration();
startTime = mediaPlayer.getCurrentPosition();
updateSeekBar();
SeekBar is not updating music is playing but the seekBar stay idle
You are defining Runnable updater
but not calling it.
if (mediaPlayer.isPlaying()) {
Runnable updater = new Runnable() {
@Override
public void run() {
updateSeekBar();
}
};
seekBar.post(updater)
}
Seek Bar Does not move with audio track running. Unable to debug
In my part I create a Runnable.
Then I think you need to set the seekBar.setProgress first before calling handler.postDelayed. This works in my part.
private Runnable runnable = new Runnable() {
@Override
public void run() {
displayCurrentTime();
seekBar.setProgress((int) player.getCurrentTimeMillis());
mHandler.postDelayed(this, 100);
}
SeekBar not working with online streaming in Android
Please relate the following code with your seekBar then this will work.
mSeekBar.setMax(mMediaPlayer.getDuration());
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
mSeekBar.setProgress(mMediaPlayer.getCurrentPosition());
}
}, 0, 10);
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mMediaPlayer.seekTo(progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
Related Topics
Android: Overlay on Android Camera Preview
Cannot Catch Toolbar Home Button Click Event
Getintent() Extras Always Null
Load an Image from Assets Folder
How to Know the Size of a File Before Downloading It
How to Run Media Scanner in Android
How to Send File Using Bluetooth on Android Programatically
Starting Frame-By-Frame Animation
How to Record Microphone to More Compressed Format During Webrtc Call on Android
How to Check an Android Device Is Hdpi Screen or Mdpi Screen
Android Room: Insert Relation Entities Using Room
How to Generate Buildconfigfield with String Type
Navigationview Menu Items with Counter on the Right
Redirecting Audio/Creating Alternate Sound Paths in Android
Custom Attributes in Styles.Xml
How to Resolve "Missing Pendingintent Mutability Flag" Lint Warning in Android API 30+
Disable Default Animation from Portrait to Landscape
How to Implement the Material-Design Elevation for Pre-Lollipop