I have created a class to play the sound when I click the buttons.
Here is the code :
public void playSound()
{
try
{
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("beep-1.wav"));
Clip clip = AudioSystem.getClip( );
clip.open(audioInputStream);
clip.start( );
}
catch(Exception e)
{
System.out.println("Error with playing sound.");
e.printStackTrace( );
}
}
But when I compile, I get this error :
error: cannot find symbol
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("beep-1.wav"));
^
symbol: class File
location: class MemoryGame
1 error
Process completed.
What is the problem with the getAudioInputStream()?
I had used import javax.sound.sampled.*; in my program.
Did you remember to import
java.io.File? That’s the class the compiler says it doesn’t know about.