0
I use this code to play sounds in my application, but it only plays the audio if it is in the project folder, and not within a package. And if I export my project by creating a . jar it does not include the media files. I have tried to change the path by adding the package, in this case sounds, but it does not play "/sounds/audio.wav". Thanks.
try {
AudioClip c = Applet.newAudioClip(new File("audio.wav").toURL());
c.play();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I think the problem is the package hierarchy. If possible, post an image of how it is. Using File, java will always look for the file in the OS file system.
– user28595