I have other problem now. Lets say I have 10 buttons (0-9), when user press button program should play short (0.3-0.5 secs) sound. I added them as wav resources. Now I see that each MediaPlayer creates its own thread and takes resources. I'm not sure that this is good idea to make 10 players. But if I create player when user presses button it works fine only if user presses no more than 1 button in 2 secs. If user presses button each second or even several buttons a second, some sounds are silent. What's best solution for this problem on android? On Pocket PC we can play wav files fast - we create thread, that uses WaveIO and we have no "silent" sounds. How can we make sounds ready to play fast?
On Apr 23, 7:18 pm, Marco Nelissen <[email protected]> wrote: > Does it work with longer sounds? > Have you tried using MediaPlayer.setLooping(true) instead of restarting it > yourself from the OnCompletionListener callback? > > On Thu, Apr 23, 2009 at 12:00 AM, BlackLight <[email protected]>wrote: > > > > > Hello. > > > I have this task: > > Need to play short (0.3-0.4 sec) sounds all the time. When sound is > > played, it should start again, etc. User can press button to reset > > sound - it should stop and lunch. > > > I did many tests. I tried to create 1 MediaPlayer, then do this: > > MediaPlayer.OnCompletionListener complListener = new > > MediaPlayer.OnCompletionListener() > > { > > public void onCompletion(MediaPlayer mp) { > > lunchSound(); // "rewind" > > } > > }; > > > private boolean lunchSound() > > { > > try > > { > > mplayer.seekTo(0); // move to start > > mplayer.start(); > > return true; > > }catch(Exception e){} > > return false; > > } > > When user press button, I call lunchSound(); > > > It works great on emulator and on device if I have eclipse+debugger > > on. > > When I disconnect debugger, I have very strange errors - sound can > > stop at all (till program restart), sound can start "repeating" (play > > 0.1-0.2 sec, then restart). Can someone please provide me some info > > about problem? > > Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

