On Wed, Feb 18, 2009 at 3:41 AM, vir <[email protected]> wrote: > > Hello people, > This is my first post on android-framework. I am having a problem > while playing sound with mediaplayer. > the scenario is like this : > > I have an application where the user have to click on images on the > screen and it plays a sound on click event. The problem is that when i > click very quickly 20 - 30 times at one go, i am getting this error : > > WARN/WindowManager(): Key dispatching timed out sending to com.XYZ > INFO/ActivityManager(): ANR (application not responding) in process: > com.XYZ > INFO/ActivityManager(): Annotation: keyDispatchingTimedOut > > i am using this code to play sound on click event :: > > private void media(){ > if (mMediaPlayer != null) { > mMediaPlayer.stop(); > mMediaPlayer.release(); > } > > mMediaPlayer = MediaPlayer.create(this, > R.raw.squash); > > mMediaPlayer.start(); > > }
Rather than destroying and recreating the MediaPlayer every time like that, consider creating it once, and then seeking back to the beginning if you want to play it again. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "android-framework" 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-framework?hl=en -~----------~----~----~----~------~----~------~--~---
