[android-developers] Re: to play audio when a button is clicked

2008-10-11 Thread Hugo Veiga
One should always keep the "house" clean. Nevertheless they should have predicted this. Hugo Veiga [EMAIL PROTECTED] On Oct 11, 2008, at 6:01 PM, Ludwig <[EMAIL PROTECTED]> wrote: > Just revisiting this: the documentation actually states that you > have to call release() on the mediaplayer w

[android-developers] Re: to play audio when a button is clicked

2008-10-11 Thread Ludwig
Just revisiting this: the documentation actually states that you have to call release() on the mediaplayer when you are done with it.I suggest that you use the following pattern to ensure that at any one time the media player (at least as far as your application is concerned) will only play one thi

[android-developers] Re: to play audio when a button is clicked

2008-10-11 Thread Ludwig
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 be

[android-developers] Re: to play audio when a button is clicked

2008-10-10 Thread [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 ) mSoun

[android-developers] Re: to play audio when a button is clicked

2008-10-09 Thread Ludwig
What would be wrong with this: @Override public void onClick(View view) { MediaPlayer mp = MediaPlayer.create(this, R.raw.a2); mp.start(); } That requires a sound file a2.mp3 in the res/raw folder (or some other supported media). HTH Ludwig 2008/10/9 [EMAIL PROTECTED] <[EMAIL PROTECTED]> > >