bouton musique fonctionnel
This commit is contained in:
parent
77e1e2d7a8
commit
0a8c883595
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -9,7 +9,10 @@ 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 {
|
||||
|
||||
@ -18,7 +21,7 @@ public class Musique {
|
||||
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);
|
||||
@ -32,4 +35,14 @@ public class Musique {
|
||||
}
|
||||
}
|
||||
|
||||
public static void pauseMusique(Clip clip) {
|
||||
clipTimePosition = clip.getMicrosecondPosition();
|
||||
clip.stop();
|
||||
}
|
||||
|
||||
public static void resumeMusique(Clip clip) {
|
||||
clip.setMicrosecondPosition(clipTimePosition);
|
||||
clip.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
@ -22,29 +23,26 @@ 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<String> langues;
|
||||
@FXML
|
||||
private Pane rootPane;
|
||||
@FXML
|
||||
private CheckBox cmusique;
|
||||
@FXML
|
||||
private CheckBox clair;
|
||||
@FXML
|
||||
private ComboBox<String> 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 :
|
||||
// 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@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) {
|
||||
coche = true;
|
||||
if (Musique.clipTimePosition == 0 && MusiqueLancee == false) {
|
||||
Musique.playMusique(filepath);
|
||||
MusiqueLancee = true;
|
||||
|
||||
|
||||
|
||||
clip.start();
|
||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
AudioSystem.getAudioInputStream(files).close();
|
||||
clip.close();
|
||||
|
||||
|
||||
} 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);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* } 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} */
|
||||
/*
|
||||
* 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"); } }
|
||||
*
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user