diff --git a/src/database/DatabaseTesting.java b/src/database/DatabaseTesting.java index 5269835..93dc71e 100644 --- a/src/database/DatabaseTesting.java +++ b/src/database/DatabaseTesting.java @@ -32,12 +32,7 @@ public class DatabaseTesting { Table a = new Table("a"); a.remplirTable("CartesLumiere"); - try { - ByteaToCardImage.getImg(a.getList().get(5).getImg()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + diff --git a/src/database/Table.java b/src/database/Table.java index eb92c15..b8cc929 100644 --- a/src/database/Table.java +++ b/src/database/Table.java @@ -27,7 +27,7 @@ public class Table { while (retour.next()) { Record r = new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image")); list.add(r); - //System.out.printf("%-20.30s %-30.30s %-20.30s%n", retour.getString("id"), retour.getString("nom"), retour.getBytes("image")); + System.out.printf("%-20.30s %-30.30s %-20.30s%n", retour.getString("id"), retour.getString("nom"), retour.getBytes("image")); } } catch (SQLException e) { diff --git a/src/ihm/Musique.java b/src/ihm/Musique.java index d9bf68d..7ee513a 100644 --- a/src/ihm/Musique.java +++ b/src/ihm/Musique.java @@ -8,28 +8,41 @@ import javax.sound.sampled.Clip; import javax.swing.JOptionPane; public class Musique { - - public void playMusique(String path) { - + + public static Clip clip; + public static long clipTimePosition = 0; + + public static void playMusique(String path) { + try { - + File musicPath = new File(path); - - if( musicPath.exists()) { - + + if (musicPath.exists()) { + AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicPath); - Clip clip = AudioSystem.getClip(); + 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(); } } + public static void pauseMusique(Clip clip) { + clipTimePosition = clip.getMicrosecondPosition(); + clip.stop(); + } + + public static void resumeMusique(Clip clip) { + clip.setMicrosecondPosition(clipTimePosition); + clip.start(); + } + } diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index d2cccc4..c319173 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -10,6 +10,7 @@ import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; +import javax.swing.JOptionPane; import ihm.Musique; import javafx.fxml.FXML; @@ -21,30 +22,27 @@ import javafx.scene.control.ComboBox; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; -public class ParametreController implements Initializable { - @FXML private Pane rootPane; - @FXML private CheckBox cmusique; - @FXML private CheckBox clair; - @FXML private ComboBox langues; +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; - - + boolean coche = false; + boolean MusiqueLancee = false; + 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"); - - - - - + // https://www.youtube.com/watch?v=LBpKUIyOHdo + 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 - - - + String liste[] = repertoire.list(); @Override public void initialize(URL arg0, ResourceBundle arg1) { @@ -53,58 +51,48 @@ public class ParametreController implements Initializable { langues.getItems().add("Espagnol"); langues.getItems().add("Français"); - - } - + @FXML - public void enregistre(MouseEvent mouseEvent) throws IOException, Exception{ - if(files.exists()) { - try { - - clip=AudioSystem.getClip(); - clip.open(AudioSystem.getAudioInputStream(files)); - - - if(cmusique.isSelected()==true) { + public void enregistre(MouseEvent mouseEvent) throws IOException, Exception { - - - clip.start(); - clip.loop(Clip.LOOP_CONTINUOUSLY); - - - - - } - else { - AudioSystem.getAudioInputStream(files).close(); - clip.close(); + if (files.exists()) { - + if (cmusique.isSelected() == true) { + coche = true; + if (Musique.clipTimePosition == 0 && MusiqueLancee == false) { + Musique.playMusique(filepath); + MusiqueLancee = true; + + } else { + Musique.resumeMusique(Musique.clip); } - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + + } else { + if (coche == true) { + coche = false; + Musique.pauseMusique(Musique.clip); + } + } - - } - - - /* 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"); - } - } - - - } */ + /* + * } 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"); } } + * + * + * } + */ + + } }