Back to:
www.javaworld.com/javaworld/javatips/jw-javatip24.html.
thanks!!! i have been looking for this because everyone just post about audio in applet this is great.
Only the continous audio doesn't work it says that the method start is not for that kind of stream.
Thanks a lot :)
continuous stream
thanks sooooo much!! i really needed this code.
The code above for continuous playing has an error that it calls for play() instead of start().
Also there were some files which did not work with continuous but worked with single play. It's not simply the code cuz another file did play. Anyone have an idea?
Excuse me, but works this in RCPs too ?
Excuse me, but works this in RCPs too ?
Java
DOES NOT WORK!
you forgot Applet.newAudioClip(URL)?
newAudioClip(URL) is a static method in Applet Class, so it can easily be used in Applications as well.
e.g.
AudioClip ac = Applet.newAudioClip(url);
ac.play(); //play once
ac.stop(); //stop playing
ac.loop(); //play continuously
Here url can refer to some file within the jar file. So, this method is very useful.
only plays sound once
when you start up the program again the sound goes away.
Sorry, but...
Applet.newAudioClip(URL) does work, I tried it in an application:
try {
AudioClip ac = Applet.newAudioClip(new File(".\\sound.au").toURI().toURL());
ac.play();
}
catch(MalformedURLException e) {}
java.net.URI, java.net.URL and java.io.File are all required.
You can also use AudioClip.loop() aswell.
Thomas
where i put the sound file
in java, where i put the sound file?? if i want to call, how??
not working
not working
audiodata not working
how come the as.getdata() throws an exception
hai
hai
Another more standart way
Although you can't use AudioClip you can use the javax.sound.sampled.Clip interface:
Clip clickClip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(waveFile);
clickClip.open(ais);
clickClip.loop(times - 1);
clickClip.start();
Post new comment