diff --git a/src/ihm/Main.java b/src/ihm/Main.java index 9a2d744..02ad6f9 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -12,7 +12,7 @@ public class Main extends Application{ @Override public void start(Stage primaryStage) throws Exception{ System.out.println("Lancement de l'application"); - Pane root = FXMLLoader.load(getClass().getResource("ressources/Jouer_tour(1)lancer_des.fxml")); + Pane root = FXMLLoader.load(getClass().getResource("ressources/Menu.fxml")); // "ressources/Jouer_tour(1)lancer_des.fxml" primaryStage.setTitle("Shadow Hunters"); primaryStage.setScene(new Scene(root)); primaryStage.centerOnScreen(); @@ -20,6 +20,11 @@ public class Main extends Application{ } public static void main(String[] args) { + + String filepath = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav"; //lien vers la musique : https://www.youtube.com/watch?v=LBpKUIyOHdo + Musique musiqueObjet = new Musique(); + musiqueObjet.playMusique(filepath); launch(args); + } } diff --git a/src/ihm/Musique.java b/src/ihm/Musique.java new file mode 100644 index 0000000..d9bf68d --- /dev/null +++ b/src/ihm/Musique.java @@ -0,0 +1,35 @@ +package ihm; + +import java.io.File; + +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.swing.JOptionPane; + +public class Musique { + + public void playMusique(String path) { + + try { + + File musicPath = new File(path); + + if( musicPath.exists()) { + + AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicPath); + Clip clip = AudioSystem.getClip(); + clip.open(audioInput); + clip.start(); + clip.loop(Clip.LOOP_CONTINUOUSLY); + + } else { + System.out.println("le fichier audio n'est pas trouvé"); + } + + } catch (Exception ex) { + ex.printStackTrace(); + } + } + +} diff --git a/src/ihm/ressources/musique/The_Red_Fox_Tavern.wav b/src/ihm/ressources/musique/The_Red_Fox_Tavern.wav new file mode 100644 index 0000000..790d601 Binary files /dev/null and b/src/ihm/ressources/musique/The_Red_Fox_Tavern.wav differ