diff options
author | Zach Jordan <zxjordan5@gmail.com> | 2023-06-05 08:38:00 -0400 |
---|---|---|
committer | Zach Jordan <zxjordan5@gmail.com> | 2023-06-05 08:38:00 -0400 |
commit | b6826c6ba281366efc60e89d73d3b6f81d4f2b80 (patch) | |
tree | 4d4dc505eb71cd0306fc07b44928eec3f152572c /src/sound/ShortAudioPlayer.java | |
parent | 649bb51ed3d7a55fd136b511a96e008298db5c7b (diff) | |
parent | fc23e12aa682298a6845d0085f1d39dae1d9c5b6 (diff) | |
download | NPEhero-b6826c6ba281366efc60e89d73d3b6f81d4f2b80.tar.gz NPEhero-b6826c6ba281366efc60e89d73d3b6f81d4f2b80.tar.bz2 NPEhero-b6826c6ba281366efc60e89d73d3b6f81d4f2b80.zip |
Merge branch 'main' of https://gitlab.sowgro.net/guitarheros/guitarhero
Diffstat (limited to 'src/sound/ShortAudioPlayer.java')
-rw-r--r-- | src/sound/ShortAudioPlayer.java | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/src/sound/ShortAudioPlayer.java b/src/sound/ShortAudioPlayer.java deleted file mode 100644 index 77fb52c..0000000 --- a/src/sound/ShortAudioPlayer.java +++ /dev/null @@ -1,73 +0,0 @@ -package sound; - -import java.io.File; -import java.io.IOException; - -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.UnsupportedAudioFileException; - -//Java program to play audio files. imports file scanning and various -//methods from the java audio class in order to do so. -public class ShortAudioPlayer implements LineListener -{ - //indicates whether the playback completes or not - boolean playCompleted; - Clip audioClip; - - public void play(String audioFilePath) - { - File audioFile = new File(audioFilePath); - - try - { - //creates an audioInput object using the file we - //declared earlier - AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile); - - //gets the format of the audioStream object - AudioFormat format = audioStream.getFormat(); - - DataLine.Info info = new DataLine.Info(Clip.class, format); - - audioClip = (Clip) AudioSystem.getLine(info); - - audioClip.addLineListener(this); - - audioClip.open(audioStream); - - audioClip.start(); - } - catch (UnsupportedAudioFileException ex) - { - System.out.println("The specified audio file is not supported."); - ex.printStackTrace(); - } - catch (LineUnavailableException ex) - { - System.out.println("Audio line for playing back is unavailable."); - ex.printStackTrace(); - } - catch (IOException ex) - { - System.out.println("Error playing the audio file."); - ex.printStackTrace(); - } - } - - - /** - * Listens to the START and STOP events of the audio line. - */ - @Override - public void update(LineEvent event) - { - //something should prolly go here - } -} |