ai Sound when clicked

This commit is contained in:
samuelsmith 2025-05-07 16:10:07 +02:00
parent d6c376ab27
commit 31571fcd99
3 changed files with 15 additions and 0 deletions

Binary file not shown.

View File

@ -28,4 +28,16 @@ public class SoundEffect {
e.printStackTrace();
}
}
public void aiSound() {
try {
File file = new File("Voicy_R2-D2-7.wav");
AudioInputStream audioStream = AudioSystem.getAudioInputStream(file);
Clip clip = AudioSystem.getClip();
clip.open(audioStream);
clip.start();
} catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
e.printStackTrace();
}
}
}

View File

@ -1,4 +1,5 @@
package windowInterface;
import backend.SoundEffect;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
@ -43,6 +44,7 @@ public class MyInterface extends JFrame {
private JLabel actionLabel;
private JCheckBox chckbxBlackAI;
private JCheckBox chckbxWhiteAI;
private SoundEffect soundEffect = new SoundEffect();
/**
* Create the frame.
@ -193,6 +195,7 @@ public class MyInterface extends JFrame {
} else {
game.toggleAI(isWhite);
}
soundEffect.aiSound();
}
public void clicLoadFileButton() {