ajustement et ajout d'effets sonores
This commit is contained in:
parent
8627870e86
commit
54e2ae4039
@ -1,6 +1,7 @@
|
||||
package ihm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
@ -9,18 +10,24 @@ import javax.sound.sampled.Clip;
|
||||
public class EffetSonore {
|
||||
|
||||
static boolean soundOK;
|
||||
|
||||
public InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
|
||||
public InputStream fileSound2 = getClass().getResourceAsStream("/ihm/ressources/musique/BeepError.wav");
|
||||
|
||||
public static void playSoundEffect(String path) {
|
||||
public static void playSoundEffect(InputStream path) {
|
||||
|
||||
if (soundOK == true) {
|
||||
|
||||
try {
|
||||
|
||||
File soundPath = new File(path);
|
||||
//File soundPath = new File(path);
|
||||
InputStream soundPath = path;
|
||||
|
||||
if (soundPath.exists()) {
|
||||
if (soundPath!=null) {
|
||||
|
||||
AudioInputStream audioInput = AudioSystem.getAudioInputStream(soundPath);
|
||||
InputStream bufferedIn = new BufferedInputStream(soundPath);
|
||||
|
||||
AudioInputStream audioInput = AudioSystem.getAudioInputStream(bufferedIn);
|
||||
Clip clipSound = AudioSystem.getClip();
|
||||
clipSound.open(audioInput);
|
||||
clipSound.start();
|
||||
|
@ -22,6 +22,7 @@ public class MenuController implements Initializable{
|
||||
@FXML private AnchorPane rootPane;
|
||||
@FXML private ImageView titre;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
InputStream input;
|
||||
@ -32,8 +33,9 @@ public class MenuController implements Initializable{
|
||||
|
||||
@FXML
|
||||
public void commencerPartie(MouseEvent mouseEvent) throws IOException{
|
||||
InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
|
||||
|
||||
EffetSonore.playSoundEffect("src//ihm//ressources//musique//BEEP1.wav");
|
||||
EffetSonore.playSoundEffect(fileSound1);
|
||||
|
||||
System.out.println("Passage à l'écran de choix des joueurs");
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/Choix_joueur.fxml");
|
||||
@ -49,7 +51,10 @@ public class MenuController implements Initializable{
|
||||
}
|
||||
|
||||
public void afficherRegle(MouseEvent mouseEvent) {
|
||||
EffetSonore.playSoundEffect("src//ihm//ressources//musique//BEEP1.wav");
|
||||
|
||||
InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
|
||||
|
||||
EffetSonore.playSoundEffect(fileSound1);
|
||||
System.out.println("blaaaa");
|
||||
|
||||
}
|
||||
|
@ -34,14 +34,10 @@ public class ParametreController implements Initializable {
|
||||
String filepathMusique = "/ihm/ressources/musique/The_Red_Fox_Tavern.wav"; // lien vers la musique : https://www.youtube.com/watch?v=LBpKUIyOHdo
|
||||
InputStream fileMusique = getClass().getResourceAsStream("/ihm/ressources/musique/The_Red_Fox_Tavern.wav");
|
||||
|
||||
|
||||
File repertoire = new File("src//ihm//ressources");
|
||||
File repertoire2;
|
||||
String liste[] = repertoire.list();
|
||||
|
||||
/*
|
||||
public void ParametreController() {
|
||||
EffetSonore sound = soundEffects;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
@ -54,6 +50,8 @@ public class ParametreController implements Initializable {
|
||||
|
||||
@FXML
|
||||
public void enregistre(MouseEvent mouseEvent) throws IOException, Exception {
|
||||
|
||||
InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
|
||||
|
||||
//Pour la musique
|
||||
if (fileMusique!=null) {
|
||||
@ -120,7 +118,7 @@ public class ParametreController implements Initializable {
|
||||
|
||||
}*/
|
||||
|
||||
EffetSonore.playSoundEffect("src//ihm//ressources//musique//BEEP1.wav"); //emet un bruit sur le bouton si les effets sonores sont activés
|
||||
EffetSonore.playSoundEffect(fileSound1); //emet un bruit sur le bouton si les effets sonores sont activés
|
||||
|
||||
// Quitter les paramètres
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml");
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ihm.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -15,14 +16,12 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.stage.Stage;
|
||||
import main.Configuration;
|
||||
@ -52,8 +51,7 @@ public class PlayersController implements Initializable{
|
||||
|
||||
private int nbJoueursH = 0;
|
||||
private int nbJoueursV = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* recup<EFBFBD>re chaque bouton textField et Checkebox a partir des hbox
|
||||
*/
|
||||
@ -119,7 +117,8 @@ public class PlayersController implements Initializable{
|
||||
// Creer une configuration
|
||||
//View.applyConfiguration(new Configuration(joueurs, nbJoueursV, nbJoueursH));
|
||||
|
||||
EffetSonore.playSoundEffect("src//ihm//ressources//musique//BEEP1.wav");
|
||||
InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
|
||||
EffetSonore.playSoundEffect(fileSound1);
|
||||
|
||||
System.out.println(this.joueurs);
|
||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||
@ -144,6 +143,12 @@ public class PlayersController implements Initializable{
|
||||
gj.lancerPartie();
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
InputStream fileSound2 = getClass().getResourceAsStream("/ihm/ressources/musique/BeepError.wav");
|
||||
EffetSonore.playSoundEffect(fileSound2);
|
||||
System.out.println("Il manque des joueurs pour lancer une partie.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -155,6 +160,10 @@ public class PlayersController implements Initializable{
|
||||
*/
|
||||
public void ajoutJoueur(int indice){
|
||||
System.out.println("Ajout du joueur " + (indice+1));
|
||||
|
||||
InputStream fileSound3 = getClass().getResourceAsStream("/ihm/ressources/musique/Beep2.wav");
|
||||
EffetSonore.playSoundEffect(fileSound3);
|
||||
|
||||
plus.get(indice).setText("-");
|
||||
txt.get(indice).setEditable(true);
|
||||
txt.get(indice).setStyle("-fx-background-color: white;");
|
||||
@ -162,8 +171,9 @@ public class PlayersController implements Initializable{
|
||||
|
||||
if (ia.get(indice).isSelected()) {
|
||||
nbJoueursV++;
|
||||
}else
|
||||
}else {
|
||||
nbJoueursH++;
|
||||
}
|
||||
|
||||
if (nbJoueursH + nbJoueursV >= 4) {
|
||||
btnCommencer.setStyle("-fx-background-color: #1d1d1d; -fx-text-fill: #d8d8d8;");
|
||||
@ -177,6 +187,10 @@ public class PlayersController implements Initializable{
|
||||
*/
|
||||
public void enleverJoueur(int indice) {
|
||||
System.out.println("Desistement du joueur " + (indice+1));
|
||||
|
||||
InputStream fileSound3 = getClass().getResourceAsStream("/ihm/ressources/musique/Beep2.wav");
|
||||
EffetSonore.playSoundEffect(fileSound3);
|
||||
|
||||
plus.get(indice).setText("+");
|
||||
txt.get(indice).setEditable(false);
|
||||
txt.get(indice).setText("");
|
||||
|
BIN
src/ihm/ressources/musique/Beep2.wav
Normal file
BIN
src/ihm/ressources/musique/Beep2.wav
Normal file
Binary file not shown.
BIN
src/ihm/ressources/musique/BeepError.wav
Normal file
BIN
src/ihm/ressources/musique/BeepError.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user