Hi,

What is the length of the files that you are trying to play?  I'm
trying to do the same with 0.2s long WAV files, but I just can't
MediaPlayer to behave well.  At first I tried 1 MediaPlayer, but it
was too laggy.  In my application, I'm trying to play the sound about
75 times a minute, that is, once every 0.8 seconds.  At this rate,
there should be plenty of time (0.6 s) between invocations, but even
with a pool of 10 MediaPlayers, things don't work very well.  Like
Robert Green said in this thread earlier, MediaPlayer is just unusable
for short, repeated sounds.  How has your experience been so far?


On Nov 2, 11:20 am, tobias429 <[EMAIL PROTECTED]> wrote:
> Thanks for the tip! This actually does the trick. What I'm doing now
> is a bit more complex. I've created a helper class that multiplies the
> number of MediaPlayers used. So instead of using oneMediaPlayerfor
> the bingSound, I use a new class, which internally creates an array of
> MediaPlayers. bingSound is an instance of this helper class. If i call
> bingSound.play(), the helper class initializes the firstMediaPlayer
> in the array and starts it.
>
> When bingSound.play() is called again, the helper class takes the
> secondMediaPlayerin the array and so on. With this I can fire off
> the same sound very quickly several times, without having to make sure
> that the sound has finished before it can be played once more.
>
> For all MediaPlayers created I set the onCompletionListener as you
> suggested with the effect you described: the system does not fill up
> withMediaPlayerremnants any more.
>
> With this everything works fine now. All in all pretty complex though.
>
> On 29 Okt., 09:27, blindfold <[EMAIL PROTECTED]> wrote:
>
> > With option 2, did you try using a setOnCompletionListener() with a
> > bingSound.stop() and bingSound.release()? This cleaning up ought to
> > prevent your system from filling up withMediaPlayerremnants - unless
> > of course you make so many calls to bingSound.start() per unit of time
> > that the system has no chance (on average) to finish playing one
> > bingSound before the next bingSound request already comes in. This
> > approach works for me.
>
> > Regards
--~--~---------~--~----~------------~-------~--~----~
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