I have the same problem, did you manage to find a workaround?
The built in player works ok but I wonder if they are using native
code.
I am guessing that this must effect the built in MediaController class
as it uses the same method call.

Next best solution is to keep track of the position myself perhaps
using time delayed handlers.
This will be fiddly as I also have a seek bar to contend with but if I
can get it working then I guess it should mask the error

I'll give it a try and post the code if I can


On Aug 4, 5:53 am, Femi Omojola <[email protected]> wrote:
> Looking for some guidance on MediaPlayer issues on Android 2.2. I've
> confirmed that the below code works on Android 1.5 (an ADP1). I'm
> playing back an MP3 file using a MediaPlayer instance and using a
> ProgressBar to track the progress. The method that updates the
> progress bar is invoked from a Handler every second. On the ADP1 this
> results in a correct update rate (the countdown timer moves about a
> second every second) and steady progress on the ProgressBar. However,
> the exact same code deployed on the Nexus 1 results in about a half
> second update in the count down timer every second.
>
> The code that updates the ProgressBar and captures the timer
> information is
>
> void updateAudioProgress(App a, boolean init)
>         {
>         if(a.getMediaPlayer() == null || audioControlToolbar == null ||
>                         (!init && audioControlToolbar.getVisibility() == 
> View.GONE))
>                 return;
>                 ImageButton ib = (ImageButton)findViewById(R.id.playpause);
>                 if(a.getMediaPlayer().isDownloading()){
>                         ib.setVisibility(View.INVISIBLE);
>                         TextView tv = (TextView)findViewById(R.id.duration);
>                         tv.setText("");
>                         ProgressBar pb = 
> (ProgressBar)findViewById(R.id.progress);
>                         pb.setMax(5000);
>                         pb.setProgress((int)(5000 *
> a.checkDownloadProgress(a.getMediaPlayer().getPendingUrl())));
>                         Message m = Message.obtain();
>                         m.what = App.UPDATE_DOWNLOAD_PROGRESS;
>                         getHandler().sendMessageDelayed(m, 1000);
>                 }else{
>                         boolean newAudioState =
> a.getMediaPlayer().getPlayer().isPlaying();
>                         if(newAudioState != a.getLastAudioState() || init){
>                                 init = true;
>                                 if(newAudioState){
>
> ib.setImageDrawable(getResources().getDrawable(R.drawable.pause));
>                                 }else{
>                                         
> ib.setImageDrawable(getResources().getDrawable(R.drawable.play));
>                                 }
>                         }
>                         if(ib.getVisibility() == View.INVISIBLE || init){
>
> ((TextView)audioControlToolbar.findViewById(R.id.audiocaption)).setText(a.getMediaPlayer().getCaption());
>                                 ib.setVisibility(View.VISIBLE);
>                         }
>                         if(init || newAudioState){
>                                 int dur = 
> a.getMediaPlayer().getPlayer().getCurrentPosition();
>                                 ProgressBar pb = 
> (ProgressBar)findViewById(R.id.progress);
>                                 int max =  
> a.getMediaPlayer().getPlayer().getDuration();
>                                 pb.setMax(max);
>                                 pb.setProgress(dur);
>                                 TextView tv = 
> (TextView)findViewById(R.id.duration);
>                                 tv.setText(a.formatDuration(dur - max));
>                                 
> android.util.Log.v("JLA",String.format("[%s/%s]", dur, max));
>                         }else{
>                                 
> android.util.Log.v("LISTACTIVITY",String.format("[%s][%s]", init,
> newAudioState));
>                         }
>                         a.setLastAudioState(newAudioState);
>                         Message m = Message.obtain();
>                         m.what = App.UPDATE_PLAYBACK_PROGRESS;
>                         getHandler().sendMessageDelayed(m, 1000);
>                 }
>         }
>
> I modified the code to log the method invocation, and it appears that
> the method is accurately called every second, but the calls to
> getCurrentPosition do NOT appear to work correctly. I noticed that
> there is an open issue,http://code.google.com/p/android/issues/detail?id=2559,
> talking about incorrect getCurrentPosition results: could this be what
> I'm seeing?
>
> Thank,
> Femi.
>
> 08-04 00:46:52.944: VERBOSE/JLA(1552): [2090/148032]
> 08-04 00:46:53.964: VERBOSE/JLA(1552): [2482/148032]
> 08-04 00:46:54.994: VERBOSE/JLA(1552): [2847/148032]
> 08-04 00:46:56.014: VERBOSE/JLA(1552): [3213/148032]
> 08-04 00:46:56.414: DEBUG/dalvikvm(1305): GC_EXPLICIT freed 183
> objects / 13032 bytes in 56ms
> 08-04 00:46:57.044: VERBOSE/JLA(1552): [3605/148032]
> 08-04 00:46:58.074: VERBOSE/JLA(1552): [3971/148032]
> 08-04 00:46:59.094: VERBOSE/JLA(1552): [4336/148032]
> 08-04 00:47:00.124: VERBOSE/JLA(1552): [4702/148032]
> 08-04 00:47:01.144: VERBOSE/JLA(1552): [5068/148032]
> 08-04 00:47:02.164: VERBOSE/JLA(1552): [5459/148032]
> 08-04 00:47:03.194: VERBOSE/JLA(1552): [5825/148032]
> 08-04 00:47:04.214: VERBOSE/JLA(1552): [6191/148032]
> 08-04 00:47:05.104: DEBUG/dalvikvm(663): GC_EXPLICIT freed 102
> objects / 6512 bytes in 58ms
> 08-04 00:47:05.244: VERBOSE/JLA(1552): [6557/148032]
> 08-04 00:47:06.264: VERBOSE/JLA(1552): [6922/148032]
> 08-04 00:47:07.294: VERBOSE/JLA(1552): [7314/148032]
> 08-04 00:47:08.314: VERBOSE/JLA(1552): [7680/148032]
>
> I'd appreciate any suggestions or pointers that might shed some light
> on this issue.
> Thanks,
> Femi.

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

Reply via email to