Playing music in applications
I keep getting the Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
The error is at runtime.
Here is the music code:
publicvoid startthemusic()
{
whatmusic ="wae.wav";
playmusic();
}
publicvoid playmusic()
{
try
{
URL hapfile =new URL("file:sounds/hap.wav");
AudioClip hap = JApplet.newAudioClip(hapfile);
URL waefile =new URL("file:sounds/wae.wav");
AudioClip wae = JApplet.newAudioClip(waefile);
if(whatmusic =="hap.wav")
{
wae.stop();
hap.loop();
}
elseif(whatmusic =="wae.wav")
{
hap.stop();
wae.loop();
}
}
catch(MalformedURLException error)
{
System.out.println("Music Error");
}
}
What is the problem?

