android - How to Play Sound Multiple Times in Method In java ? -


I want to play a similar sound when playing a button, when I call this method twice, its first Button in the first button, the second button has not been played

here is the code

  the new thread (new runleball) {@Override Public Zero () {// from the command line Take the path of the audio file (file f = new file (this.getClass (). GetResource ("/ sounds / attention.wav"). GetFile ()); Create an audio player to create an audio player that ends I player p = manager .createplayer (f. Touri) .toURL (); // start music p.start (); try {thread.leep (100);} hold (exception e) {} p. Stop (); Thread.interrupted ();} catch (exception e) {e.printStackTrace ();}}}). Start ();  

I had this problem developing a game too. Note that I am using AudioInputStream and Clip clasés, but this solution worked for me:

  Secure synchronized Gone zero play (clip clip) {Try {if (clip.isOpen ()) {System.out.println ("The clip is opened ..."); Clip.start (); Clip.setMicrosecondPosition (0); Try rewinding clips like {sleep} sleep (10);} hold (exception e) {}} try System.out.println ("shooting"); } Hold (exception e) {e.printStackTrace ();}}  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -