mercredi 21 janvier 2015

TinySound and multiple click in GUI (button)

I am struggling with a problem using TinySound (http://ift.tt/1zxbKOi). I've made a method to play a sound (i've implemented the Music class, since it allows to be played without a thread sleep limiter). My problem is that the "Play" button in my GUI can be spammed, resulting in the sound or music being played in a stack. I've checked out the setMultiClickThreshold in the Java API, but this do not solve my problem (You never know how long the sound or music-file is going to be).


Has anyone used TinySound, or know a workaround this challenge?


Here is the code for the method (I will provide more if necessary):



public void playSound(String filePath) {

soundFile = new File(filePath);
TinySound.init();
Music sound = TinySound.loadMusic(soundFile);

sound.play(false);

while(sound.done()) {
TinySound.shutdown();
}
}

Aucun commentaire:

Enregistrer un commentaire