Using getCodeBase() for getAudioClip returns various errors.
I have tried putting my audio file in various locations in my project file* and tried using getDocumentBase instead, but it keeps returning the error.
*I've put it in bin, the the base of the project file, and the src file.
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class GameAudio extends JApplet {
AudioClip song;
public void init() {
song = getAudioClip(getCodeBase(), "file: gameSong.wav");
song.play();
}
public void start() {
song.loop(); //Loop
}
public void stop() {
song.stop(); //Stop the play when applet is closed
}
}
Expected to be able to run audio as part of my applet, but this is the error I keep getting:
Exception in thread "main" java.lang.NullPointerException
at java.applet.Applet.getCodeBase(Unknown Source)
at GameAudio.init(GameAudio.java:9)
at MathGameApp.main(MathGameApp.java:9)