You can use Async class as welll wherein u have three methods, onPreexecution, doInbackgound and OnPostexecution.
You can try out these .. Lokesh On Sun, Aug 22, 2010 at 12:02 PM, Luca Carlon <[email protected]> wrote: > Thanks for the link! > I see in that code they do: > > mediaPlayer.stop(); > mediaPlayer.prepare(); > mediaPlayer.seekTo(0); > > This way it seems to stop correctly. Still unfortunately, I'm > experiencing a strange behavior: after the stop, I let the user open > another resource, with: > > mediaPlayer.reset(); > mediaPlayer.setOnBufferingUpdateListener(this); > mediaPlayer.setOnCompletionListener(this); > mediaPlayer.setOnPreparedListener(this); > mediaPlayer.setOnVideoSizeChangedListener(this); > mediaPlayer.setDataSource(this, Uri.parse(uri)); > mediaPlayer.prepare(); > mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); > > and it seems that after some stop, open and start, the player start to > behave strangely and, for instance, it goes to onCompletion when it > shouldn't, it stops buffering correctly and hangs at setDataSource for > minutes before going on. Now I tried to use runOnUiThread to make sure > only one thread manages the media player. Any idea why? Anyone who > also noticed this behavior? > Thanks! > > On 22 Ago, 13:17, Mark Murphy <[email protected]> wrote: > > On Sun, Aug 22, 2010 at 7:09 AM, Luca Carlon <[email protected]> > wrote: > > > Hi! I don't know if I'm doing something wrong, but I see calling the > > > stop function of MediaPlayer simply does nothing. The playback goes > > > on. I looked in the documentation and I found: > > > > > "Stops playback after playback has been stopped or paused." > > > > > So, I tried to pause() it before stopping, but the MediaPlayer then > > > pauses and resumes the playback. The only thing I can see is that the > > > buffering stops. But the playback continues. Is this the expected > > > behavior? > > > > No. Here is a project that behaves correctly: > > > > http://github.com/commonsguy/cw-advandroid/tree/master/Media/Audio/ > > > > > Could the problem be related to the fact that I call the > > > methods of the MediaPlayer object from different threads than the > > > creator by synchronizing with Semaphores? > > > > Possibly -- I don't know whether MediaPlayer uses thread-local values > > or anything. I have only ever used MediaPlayer from a single thread. > > > > -- > > Mark Murphy (a Commons Guy)http://commonsware.com| > http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy<http://github.com/commonsguyhttp://commonsware.com/blog%7Chttp://twitter.com/commonsguy> > > > > _The Busy Coder's Guide to Android Development_ Version 3.1 Available! > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Thanks & Regards Lokesh Gupta -- 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

