2024-10-24 20:18:06 +02:00
|
|
|
package main;
|
|
|
|
|
2024-10-25 20:22:35 +02:00
|
|
|
import model.MenuModel;
|
|
|
|
import controller.*;
|
|
|
|
import view.*;
|
|
|
|
|
|
|
|
import javax.sound.sampled.AudioInputStream;
|
|
|
|
import javax.sound.sampled.AudioSystem;
|
|
|
|
import javax.sound.sampled.Clip;
|
|
|
|
import javax.swing.*;
|
|
|
|
import java.net.URL;
|
2024-10-24 20:18:06 +02:00
|
|
|
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
2024-10-25 20:22:35 +02:00
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
|
MenuModel model = new MenuModel();
|
|
|
|
MenuView view = new MenuView();
|
|
|
|
|
2024-10-26 17:40:26 +02:00
|
|
|
JFrame frame = App.getInstance();
|
2024-10-25 20:22:35 +02:00
|
|
|
frame.add(view);
|
|
|
|
|
|
|
|
// Créer le contrôleur
|
|
|
|
new MenuController(model, view);
|
|
|
|
|
|
|
|
frame.setVisible(true);
|
|
|
|
|
|
|
|
// Chargement de la musique
|
|
|
|
PlayMusic("/Music/audio.wav");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void PlayMusic(String location){
|
|
|
|
try {
|
|
|
|
// Utilisation de getResource pour charger l'audio
|
|
|
|
URL url = Main.class.getResource(location);
|
|
|
|
|
|
|
|
if (url != null) {
|
|
|
|
AudioInputStream audioInput = AudioSystem.getAudioInputStream(url);
|
|
|
|
Clip clip = AudioSystem.getClip();
|
|
|
|
clip.open(audioInput);
|
|
|
|
clip.start();
|
|
|
|
} else {
|
|
|
|
System.out.println("fichier introuvable");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println(e);
|
|
|
|
}
|
2024-10-24 20:18:06 +02:00
|
|
|
}
|
|
|
|
}
|