2010-12-09 219 views

回答

1

,你可以用它來扮演名爲.mp3或.wav文件

Player p; 
InputStream is = getClass().getResourceAsStream(SoundName[sound]); 
     try { 
      p = Manager.createPlayer(is, "audio/X-wav"); 
      p.start(); 
      is.close(); 
      is = null; 
     } catch (IOException ex) { 
      ex.printStackTrace(); 
     } catch (MediaException ex) { 
      ex.printStackTrace(); 
     } 

p.setLoopCount(100);//using this you can play the sound in loop