bouton musique fonctionnel
This commit is contained in:
parent
77e1e2d7a8
commit
0a8c883595
@ -32,12 +32,7 @@ public class DatabaseTesting {
|
|||||||
|
|
||||||
Table a = new Table("a");
|
Table a = new Table("a");
|
||||||
a.remplirTable("CartesLumiere");
|
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()) {
|
while (retour.next()) {
|
||||||
Record r = new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"));
|
Record r = new Record(retour.getString("id"), retour.getString("nom"), retour.getBytes("image"));
|
||||||
list.add(r);
|
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) {
|
} catch (SQLException e) {
|
||||||
|
@ -9,16 +9,19 @@ import javax.swing.JOptionPane;
|
|||||||
|
|
||||||
public class Musique {
|
public class Musique {
|
||||||
|
|
||||||
public void playMusique(String path) {
|
public static Clip clip;
|
||||||
|
public static long clipTimePosition = 0;
|
||||||
|
|
||||||
|
public static void playMusique(String path) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
File musicPath = new File(path);
|
File musicPath = new File(path);
|
||||||
|
|
||||||
if( musicPath.exists()) {
|
if (musicPath.exists()) {
|
||||||
|
|
||||||
AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicPath);
|
AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicPath);
|
||||||
Clip clip = AudioSystem.getClip();
|
clip = AudioSystem.getClip();
|
||||||
clip.open(audioInput);
|
clip.open(audioInput);
|
||||||
clip.start();
|
clip.start();
|
||||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
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.Clip;
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import ihm.Musique;
|
import ihm.Musique;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@ -21,30 +22,27 @@ import javafx.scene.control.ComboBox;
|
|||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
|
|
||||||
public class ParametreController implements Initializable {
|
public class ParametreController implements Initializable {
|
||||||
@FXML private Pane rootPane;
|
@FXML
|
||||||
@FXML private CheckBox cmusique;
|
private Pane rootPane;
|
||||||
@FXML private CheckBox clair;
|
@FXML
|
||||||
@FXML private ComboBox<String> langues;
|
private CheckBox cmusique;
|
||||||
|
@FXML
|
||||||
|
private CheckBox clair;
|
||||||
|
@FXML
|
||||||
|
private ComboBox<String> langues;
|
||||||
AudioInputStream musique;
|
AudioInputStream musique;
|
||||||
Clip clip;
|
Clip clip;
|
||||||
|
boolean coche = false;
|
||||||
|
boolean MusiqueLancee = false;
|
||||||
|
|
||||||
String filepath = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav"; // lien vers la musique :
|
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");
|
File repertoire = new File("src//ihm//ressources");
|
||||||
|
|
||||||
String liste[] = repertoire.list();
|
String liste[] = repertoire.list();
|
||||||
// https://www.youtube.com/watch?v=LBpKUIyOHdo
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||||
@ -53,58 +51,48 @@ public class ParametreController implements Initializable {
|
|||||||
langues.getItems().add("Espagnol");
|
langues.getItems().add("Espagnol");
|
||||||
langues.getItems().add("Français");
|
langues.getItems().add("Français");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void enregistre(MouseEvent mouseEvent) throws IOException, Exception{
|
public void enregistre(MouseEvent mouseEvent) throws IOException, Exception {
|
||||||
if(files.exists()) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
clip=AudioSystem.getClip();
|
if (files.exists()) {
|
||||||
clip.open(AudioSystem.getAudioInputStream(files));
|
|
||||||
|
|
||||||
|
|
||||||
if(cmusique.isSelected()==true) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clip.start();
|
|
||||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
AudioSystem.getAudioInputStream(files).close();
|
|
||||||
clip.close();
|
|
||||||
|
|
||||||
|
if (cmusique.isSelected() == true) {
|
||||||
|
coche = true;
|
||||||
|
if (Musique.clipTimePosition == 0 && MusiqueLancee == false) {
|
||||||
|
Musique.playMusique(filepath);
|
||||||
|
MusiqueLancee = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Musique.resumeMusique(Musique.clip);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (coche == true) {
|
||||||
|
coche = false;
|
||||||
|
Musique.pauseMusique(Musique.clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* } 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