I have an app that uses android SeebBar to show and change MediaPlayer progress.
Problem:
When i touch and drag seek bar thumb sometimes it works perfectly and my MediaPlayer progress change successfully but some times when I touch and drag seek bar thumb it shows the pressed state ripple effect but does not change its position and feels life it got stuck.
I tried logging to detect the problem then I found onStopTrackingTouch is getting called automatically after onStartTrackingTouch method in Seekbar without lifting the finger and onProgressChanged not getting called.
Code:
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
Log.d(">>>>>>", "I'm in onStartTrackingTouch");
}
@Override
public void onProgressChanged(SeekBar seekBar, int seekPosition, boolean fromUser) {
Log.d(">>>>>>", "I'm in onProgressChanged");
// Here i'm just changing seek position of MediaPlayer
// but sometimes it invokes successfully sometimes it doesn't :(
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
Log.d(">>>>>>", "I'm in onStopTrackingTouch");
}
});
Output:
Sometimes I get:
>>>>>> I'm in onStartTrackingTouch
>>>>>> I'm in onProgressChanged
>>>>>> I'm in onProgressChanged
>>>>>> I'm in onProgressChanged
>>>>>> ...
>>>>>> I'm in onStopTrackingTouch
and sometimes:
>>>>>> I'm in onStartTrackingTouch
>>>>>> I'm in onStopTrackingTouch
still my finger pressed down and onProgressChanged just doesn't invoke.