this is my sound class
package com.kiko.quest.sound;
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
public class Sound {
private Clip clip;
private boolean play = false;
private String url;
public static Sound bg1 = new Sound("/res/sounds/Fire magic.wav");
private Sound(String url) {
this.url = url;
}
public void Play(float volume, boolean repeat) {
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(url));
Clip clip = AudioSystem.getClip();
this.clip = clip;
clip.open(audioInputStream);
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(volume);
} catch (Exception ex) {
System.err.println("Wrong sound path!");
}
if (repeat)
clip.loop(Clip.LOOP_CONTINUOUSLY);
else
clip.start();
}
public void Stop() {
clip.loop(0);
clip.stop();
}
}
In my game class I write Sound.bg1.Play(0, true);
I always get Wrong path! I have set the res folder.It says that clip = null everytime, I tried ex.printStackTrace(); but still same the res folder its added in the library other thinks like pictures works fine but the sound no please help