dimanche 28 décembre 2014

how to play random .wav sounds?

I have a group of .wav sounds which are contained in a folder within the package. In the following code It will always play the same .wav sound every time the button is pressed. how to to add the Random function to read from the folder and play a different sound each time the button is pressed.



public void actionPerformed(ActionEvent e){
if (e.getSource() == Button)
play("/nameofthefolder/nameofsound.wav");

}




Aucun commentaire:

Enregistrer un commentaire