ProgressBar Problem

All your problems with Audio, Video and Images.

ProgressBar Problem

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

Hi,

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?

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

Top

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

You could update it yourself like they do in the MediaPlaybackActivity.java 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
next
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;
michael1221988
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri Jan 08, 2010 4:39 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 16 guests