Reputation: 386
I am having trouble putting in the audio file url into my app in my getCodeBase method :
public class Audioapp extends JApplet
{
public class Sound // Holds one audio file
{
private AudioClip song; // Sound player
private URL songPath; // Sound path
Sound(String filename)
{
try
{
songPath = new URL(getCodeBase("G:\\Uni\\Programming\\Rolling assignements\\Week0\\Programming week21"),filename); // This is the place were im getting error
song = Applet.newAudioClip(songPath); // Load the Sound
}
catch(Exception e){e.printStackTrace();}
}
public void playSound()
{
song.play(); // Play
}
}
}
The error I am getting is:
The method getCodeBase() in the type Applet is not applicable for the arguments (String)
I followed the tutorial online and have followed it properly and in full. But what is missing/wrong?
Upvotes: 0
Views: 380
Reputation: 3948
According Oracle's Java API for Applets there is no method there you can pass a string. There are three methods without any parameters.
Upvotes: 0
Reputation: 1317
What tutorial did you follow? Did you read the javadoc for getCodeBase and AudioClip?
I think this is what you should do :
Audioclip song = getAudioClip(getCodeBase(),"filename");
The song is supposed to be in your class files directory. I didn't try it, but I think it should work.
Upvotes: 1