From 7f5656a1a127a3ad5d360c22273d693124dd8188 Mon Sep 17 00:00:00 2001 From: peam8y43l <3421917108@qq.com> Date: Sat, 13 Apr 2024 20:47:01 +0800 Subject: [PATCH] Delete 'src/SoundPlayer.java' --- src/SoundPlayer.java | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 src/SoundPlayer.java diff --git a/src/SoundPlayer.java b/src/SoundPlayer.java deleted file mode 100644 index 1bb19c7..0000000 --- a/src/SoundPlayer.java +++ /dev/null @@ -1,34 +0,0 @@ -package impl; - -import javax.sound.sampled.*; -import java.io.File; -import java.io.IOException; - -public class SoundPlayer { - private Clip clip; - - public SoundPlayer(String filePath) { - try { - File soundFile = new File(filePath); - AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(soundFile); - clip = AudioSystem.getClip(); - clip.open(audioInputStream); - } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { - e.printStackTrace(); - } - } - - public void play() { - if (clip != null) { - clip.setFramePosition(0); // Rewind to the beginning - clip.start(); - } - } - - public void stop() { - if (clip != null && clip.isRunning()) { - clip.stop(); - } - } - -} \ No newline at end of file