diff --git a/OOP_2B1_Project/Voicy_R2-D2-7.wav b/OOP_2B1_Project/Voicy_R2-D2-7.wav new file mode 100644 index 0000000..55c1dbb Binary files /dev/null and b/OOP_2B1_Project/Voicy_R2-D2-7.wav differ diff --git a/OOP_2B1_Project/src/backend/SoundEffect.java b/OOP_2B1_Project/src/backend/SoundEffect.java index de89a53..e747977 100644 --- a/OOP_2B1_Project/src/backend/SoundEffect.java +++ b/OOP_2B1_Project/src/backend/SoundEffect.java @@ -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(); + } + } } diff --git a/OOP_2B1_Project/src/windowInterface/MyInterface.java b/OOP_2B1_Project/src/windowInterface/MyInterface.java index c7e638b..e661bdb 100644 --- a/OOP_2B1_Project/src/windowInterface/MyInterface.java +++ b/OOP_2B1_Project/src/windowInterface/MyInterface.java @@ -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() {