diff options
author | zxjordan <zxjordan5@gmail.com> | 2023-06-05 22:48:07 -0400 |
---|---|---|
committer | zxjordan <zxjordan5@gmail.com> | 2023-06-05 22:48:07 -0400 |
commit | 144b9e9a16272da2a7cdde01b16dfb83f5353b07 (patch) | |
tree | c9876abbe02ee74d68d75e827d9a26da7495e941 /src/main/SoundController.java | |
parent | 85037099c9ff60d55501c0ff9a70ccfaccbb95f2 (diff) | |
parent | 5f6b84a1d3a4cf1936e7d495d03400ce5c7478f6 (diff) | |
download | NPEhero-144b9e9a16272da2a7cdde01b16dfb83f5353b07.tar.gz NPEhero-144b9e9a16272da2a7cdde01b16dfb83f5353b07.tar.bz2 NPEhero-144b9e9a16272da2a7cdde01b16dfb83f5353b07.zip |
Merge branch 'main' of https://gitlab.sowgro.net/npeinc/npehero
Diffstat (limited to 'src/main/SoundController.java')
-rw-r--r-- | src/main/SoundController.java | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/main/SoundController.java b/src/main/SoundController.java index b3c6d23..c8e6c8a 100644 --- a/src/main/SoundController.java +++ b/src/main/SoundController.java @@ -11,15 +11,18 @@ public class SoundController { public MediaPlayer songMediaPlayer; public MediaPlayer sfxMediaPlayer; - private HashMap<String,File> presets = new HashMap<>(); + private HashMap<String,MediaPlayer> effects = new HashMap<>(); private File mainMenuSong = new File("src/assets/fairyfountain.wav"); public SoundController() { - presets.put("forward", new File("src/assets/MenuForward.wav")); - presets.put("backward", new File("src/assets/MenuBackward.wav")); - presets.put("hit", new File("src/assets/Hitsound.wav")); - presets.put("miss", new File("src/assets/Miss.wav")); + effects.put("hit", new MediaPlayer(new Media(new File("src/assets/hit.wav").toURI().toString()))); + effects.put("miss", new MediaPlayer(new Media(new File("src/assets/miss.wav").toURI().toString()))); + effects.put("forward", new MediaPlayer(new Media(new File("src/assets/forward.wav").toURI().toString()))); + effects.put("backward", new MediaPlayer(new Media(new File("src/assets/backward.wav").toURI().toString()))); + effects.forEach((key,value) -> { + value.volumeProperty().bind(Driver.settingsController.effectsVol); + }); playMenuSong(); } @@ -50,20 +53,9 @@ public class SoundController } } - public void playSfx(File sfxFile) - { - if (sfxMediaPlayer != null) - { - sfxMediaPlayer.stop(); - } - Media sound = new Media(sfxFile.toURI().toString()); - sfxMediaPlayer = new MediaPlayer(sound); - sfxMediaPlayer.volumeProperty().bind(Driver.settingsController.effectsVol); //not working yet - sfxMediaPlayer.play(); - } - public void playSfx(String preset) { - playSfx(presets.get(preset)); + effects.get(preset).stop(); + effects.get(preset).play(); } }
\ No newline at end of file |