I know the sound doesn't play sometimes on my computer. I have no other computer to test it on. If there is no problem running it on another computer then I'm wasting everyone's time.
Printable View
I know the sound doesn't play sometimes on my computer. I have no other computer to test it on. If there is no problem running it on another computer then I'm wasting everyone's time.
When there were overlapping calls to the play() method, sometimes a play of the sound was missed. When I added code to serialize the play using Semaphore and sleep() all the calls to play() made sounds.
OK, thank you. I have made significant progress. I created a 1sec wav file to make it easier to hear the interruptions. From this I could clearly see that the AudioClip.play() method returns immediately. Which leads me to think that there's no need to run it on another thread (it creates it's own thread), please correct me if I'm wrong. I got rid of my new thread and it ran on the EDT with the same results as before.
I could also see that sometimes the old sound was cleanly interrupted by the new one, but sometimes the new one just stopped the old one and the new one didn't play. So I put a sound.stop() before the sound.play() and, except when I try and make them play ridiculously fast, they never fail to play. This just leads me to ask one more question. Since play() appears to create its own new thread is it OK to call it on the EDT?
Since it returns immediately, it's probably OK.
That's what I thought. Great then, thank you very much for you help!