> how can I import or load a *.wav or any sound clip i JAVA application
Load it from anywhere
URL url = new URL("http://....../ping.wav");
or load it from your classpath:
URL url = getClass().getResource("/..../ping.wav");
AudioClip clip = Applet.newAudioClip(url);
Yes, I know it is a method of class Applet. But because it is a
static method, it should be possible to call it from outside an
applet, too. See also
http://java.sun.com/j2se/1.4.2/docs/api/java/applet/Applet.html#newAudioClip(jav
a.net.URL)
> just for the beggining of the program??
Call
clip.play();
> or it can play all the time?
Call
clip.loop();

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
babo - 06 Dec 2005 15:33 GMT
public static void main ( String[] args )
{
URL url = new URL("http://marvin.kset.org/~babo/sound/tada.wav");
//URL url =
getClass().getResource("file:c:/windows/Media/ping.wav");
AudioClip clip = Applet.newAudioClip(url);
clip.loop();
}
it says>
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
URL cannot be resolved to a type
URL cannot be resolved to a type
at Play.main(Play.java:25)
whyyyyy___
> > how can I import or load a *.wav or any sound clip i JAVA application
> Load it from anywhere
[quoted text clipped - 5 lines]
> static method, it should be possible to call it from outside an
> applet, too. See also
Thomas Fritsch - 06 Dec 2005 15:39 GMT
> Exception in thread "main" java.lang.Error: Unresolved compilation
> problems:
> URL cannot be resolved to a type
It seems you forgot
import java.net.URL;

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Thomas Fritsch - 06 Dec 2005 15:54 GMT
> public static void main ( String[] args )
> {
> URL url = new URL("http://marvin.kset.org/~babo/sound/tada.wav");
>
> //URL url =
> getClass().getResource("file:c:/windows/Media/ping.wav");
By the way:
The above line doesn't make sense. Either you mean
URL url = new URL("file:///c:/windows/Media/ping.wav");
or
URL url = new URL("file:/c:/windows/Media/ping.wav");
or
URL url = getClass().getResource("/com/yourcompany/media/ping.wav");
(assuming your .wav file is located besides the .class files of package
"com.yourcompany.media")

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
>how can I import or load a *.wav or any sound clip i JAVA application
>
>just for the beggining of the program??
> or it can play all the time?
see http://mindprod.com/jgloss/sound.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.