By inconsitent he meant that the sounds would play sometimes but not others.
I had the same problem at first until I shortened the wav file so there was no silence at the end, then it worked fine on my computers. Althought it didn't on my friends. This was the method I was using. Would it have made a difference if I called stop() before setting the framePosition to 0?
1 2 3 4 5 6 7 8 9
| public void playClip(String clipName) { Clip clip = soundsMap.get(clipName); if (clip != null) { clip.setFramePosition(0); clip.start(); } } |
This is the method I use now, just for the clicking sound that is played rapidly.
1 2 3 4 5 6 7 8 9 10
| public void click() { Clip clip = clicks.get(clickIndex); clip.setFramePosition(0); clip.start(); clickIndex++; if (clickIndex >= clicks.size()) { clickIndex = 0; } } |
So I have four clicking sounds in an array. This apparently works fine on his computer. No one who tested my game in the showcase section had any problems either. I don't know why this would work better than the other way.