https://i.stack.imgur.com/r7npI.jpg it will leed to my problems
I just want to play some audio files, when some action in the program happens. The problem is that my team and I have different structures of folders after cloning the repo. For me I need to give it a path with SourceCode and they need it without this term. And I'd rather like to outsource the resource folder outside of src.
For me the code needs to be:
aux.playSound("SourceCode/AnwendungGruppeAfx/src/application/resources/systems-online.wav");
But for them that needs to be like in the example in the main.java. Otherwise it leeds to the error:
Caused by: MediaException: MEDIA_UNAVAILABLE : C:\Users\david\git\Repo_Gruppe_A\AnwendungGruppeAfx\src\application\resources\systems-online.wav
And for my teammates they have the same error with the message SourceCode/SourceCode then.
AudioPlayer.java:
public class AudioPlayer {
public void playSound(String file) {
String musicFile = file;
AudioClip audio = new AudioClip(new File(musicFile).toURI().toString());
audio.play();
}
}
For example in the Main.java at the opening of the program:
public class Main extends Application {
AudioPlayer aux = new AudioPlayer();
@Override
public void start(Stage primaryStage) throws Exception {
aux.playSound("AnwendungGruppeAfx/src/application/resources/systems-online.wav");
Parent root = FXMLLoader.load(getClass().getResource("/application/controller/LoginController/Login.fxml"));
Scene scene = new Scene(root);
primaryStage.getIcons().add(new Image("/application/resources/icons8-blockchain-technology-64.png"));
primaryStage.setTitle("SemestervErwaltungsPlan");
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.show();
}