From 77e1e2d7a8bbaa51c7d4222a64dbb99e90ca982a Mon Sep 17 00:00:00 2001 From: Yessine Ben El Bey Date: Tue, 28 Apr 2020 09:32:33 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Ajout=20de=20la=20musique=20param=C3=A8tre?= =?UTF-8?q?=20non=20complet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ihm/controller/ParametreController.java | 86 +++++++++++++++++---- src/ihm/ressources/parametre.fxml | 2 +- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index 550c9a6..d2cccc4 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -1,9 +1,16 @@ package ihm.controller; +import java.io.File; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + import ihm.Musique; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -14,11 +21,28 @@ import javafx.scene.control.ComboBox; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; -public class ParametreController implements Initializable{ +public class ParametreController implements Initializable { @FXML private Pane rootPane; @FXML private CheckBox cmusique; @FXML private CheckBox clair; @FXML private ComboBox langues; + AudioInputStream musique; + Clip clip; + + + String filepath = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav"; // lien vers la musique : + File files=new File("src//ihm//ressources//musique//The_Red_Fox_Tavern.wav"); + + + + + + File repertoire = new File("src//ihm//ressources"); + + String liste[] = repertoire.list(); + // https://www.youtube.com/watch?v=LBpKUIyOHdo + + @@ -27,26 +51,60 @@ public class ParametreController implements Initializable{ langues.getItems().add("Anglais"); langues.getItems().add("Allemand"); langues.getItems().add("Espagnol"); - langues.getItems().add("Français"); - - + langues.getItems().add("Français"); + } - /*@FXML - public void enregistre(MouseEvent mouseEvent) throws IOException{ - if(cmusique.isSelected()==true) { - - 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); + + @FXML + public void enregistre(MouseEvent mouseEvent) throws IOException, Exception{ + if(files.exists()) { + try { + + clip=AudioSystem.getClip(); + clip.open(AudioSystem.getAudioInputStream(files)); - Pane root = FXMLLoader.load(getClass().getResource("ressources/parametre.fxml")); - //root.setStyle("ressources/style/menuLight.css); + + if(cmusique.isSelected()==true) { + + + + clip.start(); + clip.loop(Clip.LOOP_CONTINUOUSLY); + + + + + } + else { + AudioSystem.getAudioInputStream(files).close(); + clip.close(); + + + } + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } + + /* if(clair.isSelected()) { + Pane root = FXMLLoader.load(getClass().getResource("ressources/parametre.fxml")); + root.setStyle("ressources/style/menuLight.css"); + if (liste != null) { + for (int i = 0; i < liste.length; i++) { + System.out.println(liste[i]); + Pane root1 = FXMLLoader.load(getClass().getResource(liste[i])); + root1.setStyle("ressources/style/menuLight.css"); + } + } + + } */ } +} diff --git a/src/ihm/ressources/parametre.fxml b/src/ihm/ressources/parametre.fxml index e70b1b9..e382d83 100644 --- a/src/ihm/ressources/parametre.fxml +++ b/src/ihm/ressources/parametre.fxml @@ -37,6 +37,6 @@ -