C
Christian Kremser
I have a problem with playing sound-files (wav-files) from my
application. The application should play a short (about 1-2 sec
long) sound-file (the existence of the files ich checked) from a
list each time the user pushes a button (the index of the list is
changed for each button press). The problem I have is, that it
sometimes works and plays the sound and sometimes it doesn't play
the sound and there is now error thrown. The part of my code
which plays the sound is as follows:
try {
URL completeURL = new URL("file:" +
FileList[actIndex]);
AudioClip audioClip = Applet.newAudioClip(completeURL);
audioClip.play();
} catch (MalformedURLException e) {
System.err.println(e.getMessage());
}
Has anybody an idea what is wrong with this? How can I make sure
ensure that the file is completely loaded and ready for playing
(if (audioClip==null) didn't bring any improvement)? Or, how can
I determin if the AudioClip has finished playing?
Thanks in advance for any help!
Cheers,
Christian.
application. The application should play a short (about 1-2 sec
long) sound-file (the existence of the files ich checked) from a
list each time the user pushes a button (the index of the list is
changed for each button press). The problem I have is, that it
sometimes works and plays the sound and sometimes it doesn't play
the sound and there is now error thrown. The part of my code
which plays the sound is as follows:
try {
URL completeURL = new URL("file:" +
FileList[actIndex]);
AudioClip audioClip = Applet.newAudioClip(completeURL);
audioClip.play();
} catch (MalformedURLException e) {
System.err.println(e.getMessage());
}
Has anybody an idea what is wrong with this? How can I make sure
ensure that the file is completely loaded and ready for playing
(if (audioClip==null) didn't bring any improvement)? Or, how can
I determin if the AudioClip has finished playing?
Thanks in advance for any help!
Cheers,
Christian.