ajout d'une musique de fond
This commit is contained in:
parent
3803becdcf
commit
cd9de06a76
@ -12,7 +12,7 @@ public class Main extends Application{
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
System.out.println("Lancement de l'application");
|
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.setTitle("Shadow Hunters");
|
||||||
primaryStage.setScene(new Scene(root));
|
primaryStage.setScene(new Scene(root));
|
||||||
primaryStage.centerOnScreen();
|
primaryStage.centerOnScreen();
|
||||||
@ -20,6 +20,11 @@ public class Main extends Application{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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);
|
launch(args);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
src/ihm/Musique.java
Normal file
35
src/ihm/Musique.java
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
BIN
src/ihm/ressources/musique/The_Red_Fox_Tavern.wav
Normal file
BIN
src/ihm/ressources/musique/The_Red_Fox_Tavern.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user