I have tried this and I can confirm that when you click a button with an
onClick() method defined as I suggested, that it will fail when clicked many
times in short succession.
Looking at the debug messages, it looks like that the mediaplayer is simply
running out of filehandles and then crashes because it cannot open any more
files. That situation should be handled inside the mediaplayer code.
This is a bit worrying as it shows that Android has not really been stress
tested by Google: it makes Android look a bit as if it was coded by novices.
I think it would be best to file a bug report. Internally it should be
relatively easy to fix with a bit of resource management: does it really
make sense to try to play dozens of sound files at the same time?
Ludwig
2008/10/10 [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>
> > What would be wrong with this:
> > @Override
> > public void onClick(View view) {
> > MediaPlayer mp = MediaPlayer.create(this, R.raw.a2);
> > mp.start();
> >}
>
> In this case I can to click only 27 times.
> Then I hve exception - NullPointerException
>
> In m5 worked variant:
>
> if( mSoundFx != null )
> mSoundFx.pause();
> mSoundFx = mSoundFxs[aBonusType];
> mSoundFx.seekTo(0);
> mSoundFx.start();
>
> where mSoundFx - MediaPlayer mSoundFx;
> and mSoundFxs - MediaPlayer mSoundFxs = new MediaPlayer[]{
> MediaPlayer.create( mContext,R.raw.no2),
> MediaPlayer.create( mContext,R.raw.trc_ok2),
> MediaPlayer.create( mContext,R.raw.type2) ,
> MediaPlayer.create( mContext,R.raw.side2),
> MediaPlayer.create( mContext,R.raw.appl2),
> };
>
> But in 9beta and 1.0_r1 it does not work.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---