ProgressBar Problem

All your problems with Audio, Video and Images.

ProgressBar Problem

Postby kdiddy » Thu Dec 17, 2009 6:22 am


I have an app that plays an mp3 file using the mediaplayer, mediacontroller, and mediacontrolplayer as the interface. The default player appears and works but the progressbar doesn't move incrementally as the tracks playing. I can fast forward or rewind or seek to any position by touching the progressbar but it doesn't move on it's own. I've searched high and low for a listener or something that will make the progressbar move each second the track is playing but have found nothing.

Any ideas?

Junior Developer
Junior Developer
Posts: 19
Joined: Wed Apr 01, 2009 2:30 am


Postby michael1221988 » Sun Jan 10, 2010 6:31 pm

You could update it yourself like they do in the file. They have a refreshNow() function that they call like so
Code: Select all
long next = refreshNow();
they then call it after
Code: Select all
seconds. The function looks similar to this
Code: Select all
      mDuration = mp.getDuration();
      long pos = mPosOverride < 0 ? mp.getCurrentPosition() : mPosOverride;
      long remaining = 1000 - (pos % 1000);
      if ((pos >= 0) && (mDuration > 0)) {
      mProgress.setProgress((int) (1000 * pos / mDuration));
      // return the number of milliseconds until the next full second, so
      // the counter can be updated at just the right time
      return remaining;
Junior Developer
Junior Developer
Posts: 12
Joined: Fri Jan 08, 2010 4:39 am


Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 2 guests