Reputation: 33
Whenever I try the audio clip, I get this error:
java.net.MalformedURLException: no protocol: /Users/videogames/Documents/workspace/TryApplets/res/adv.wav---------
What's the problem? Here's the code for the program. (I use a mac, if that matters at all)
package game;
import java.applet.*;
import java.net.*;
public class sound {
/**
* @param args
*/
public static void main(String[] args) {
try {
URL url = new URL("/Users/videogames/Documents/workspace/TryApplets/res/adv.wav");
AudioClip clip = Applet.newAudioClip(url);
clip.play();
} catch (MalformedURLException murle) {
System.out.println(murle);
}
}
}
Upvotes: 0
Views: 1001
Reputation: 44813
Valid protocols for the URL class are
http, https, ftp, file, and jar
so try
URL url = new URL("file://Users/videogames/Documents/workspace/TryApplets/res/adv.wav");
If in doubt read the API
http://docs.oracle.com/javase/7/docs/api/java/net/URL.html#URL(java.lang.String)
Upvotes: 2
Reputation: 168815
An URL must start with something like http://..
or file://..
. The URL shown does not, it is not a valid URL.
Upvotes: 2