Wednesday, October 12, 2011

[android-developers] SeekBar jumps ahead initially while playing short media files

Hi All,

I am implementing a media player with seekbar controls.
I am using AsyncTask to update the seekbar progress.

I am facing one issue with seekbar when media player plays short media
files(< 15 sec duration).
The issue is that seekbar suddenly jumps to around 2 seconds forward
at the start and then it is normal after this jump.
I mean, the seekbar does not start at the far left. Instead, it seems
to jump ahead initially.

Below is the Asynctask code for this

////////////////////////////////

@Override
protected String doInBackground(Context... params) {

while (mCurrentPosition < mTotalDuration) {
try {
mCurrentPosition = mPlayer.getCurPosition();

if (mCurrentPosition < 0) {
this.publishProgress(mTotalDuration);
} else {
this.publishProgress(mCurrentPosition);
}

Thread.sleep(20);
} catch (InterruptedException e) {
return null;
} catch (Exception e) {
return null;
}

if (this.isCancelled()) {
return null;
}
}


@Override
protected void onProgressUpdate(Integer... progress) {
mSeekbar.setProgress(progress[0]);
mDurationView.setText(ConvertToTimeString(progress[0]));
}
///////////////////////////////


Could anybody give some pointers to resolve this issue.


Thanks,
Ganesh

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment