From 5951f6b55f20981f411a06d98fb686acc4da394e Mon Sep 17 00:00:00 2001 From: sowgro Date: Thu, 8 Jun 2023 02:50:36 -0400 Subject: move resources out of src so they can be read from a jar --- src/main/SoundController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/SoundController.java') diff --git a/src/main/SoundController.java b/src/main/SoundController.java index 8f255da..0d7527e 100644 --- a/src/main/SoundController.java +++ b/src/main/SoundController.java @@ -1,6 +1,7 @@ package main; import java.io.File; +import java.nio.file.Paths; import java.util.HashMap; import gui.Driver; @@ -13,17 +14,18 @@ public class SoundController public MediaPlayer songMediaPlayer; public MediaPlayer sfxMediaPlayer; private HashMap effects = new HashMap<>(); - private File mainMenuSong = new File("src/assets/fairyfountain.wav"); + private File mainMenuSong = Paths.get("resources/fairyfountain.wav").toFile(); + /** * creates a new sound controller and starts playing the main menu music */ public SoundController() { - 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.put("hit", new MediaPlayer(new Media(Paths.get("resources/hit.wav").toUri().toString()))); + effects.put("miss", new MediaPlayer(new Media(Paths.get("resources/miss.wav").toUri().toString()))); + effects.put("forward", new MediaPlayer(new Media(Paths.get("resources/forward.wav").toUri().toString()))); + effects.put("backward", new MediaPlayer(new Media(Paths.get("resources/backward.wav").toUri().toString()))); effects.forEach((key,value) -> { value.volumeProperty().bind(Driver.settingsController.effectsVol); }); -- cgit v1.2.3