ajout slider parametre pour la musique
This commit is contained in:
parent
caf0e8db7c
commit
ffa5398c4f
@ -14,7 +14,7 @@ public class Musique {
|
||||
public static long clipTimePosition = 0;
|
||||
|
||||
public static boolean musiqueEnCours = false;
|
||||
static FloatControl volume ;
|
||||
public static FloatControl volume ;
|
||||
|
||||
public static void playMusique(InputStream path) {
|
||||
|
||||
@ -62,4 +62,13 @@ public class Musique {
|
||||
volume.setValue(volume.getValue() -valeur);
|
||||
}
|
||||
|
||||
public static void setVolume(Float fValeur) {
|
||||
volume.setValue(fValeur);
|
||||
}
|
||||
|
||||
public static void setVolume(double dValeur) {
|
||||
float decibel = (float) (Math.log(dValeur) / Math.log(10) * 20);
|
||||
volume.setValue(decibel);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
@ -28,9 +29,13 @@ public class ParametreController implements Initializable {
|
||||
private CheckBox clair;
|
||||
@FXML
|
||||
private ComboBox<String> langues;
|
||||
@FXML
|
||||
private Slider sliderMusique;
|
||||
|
||||
public static boolean cbMusiqueCoche = false; // verifi si la checbox musical est coche
|
||||
public static boolean cbSonCoche = false;
|
||||
public static boolean cbClair = false;
|
||||
public static double slideValue;
|
||||
|
||||
boolean MusiqueLancee = false; //verifi si la musique a déja été lancé une première fois
|
||||
|
||||
@ -45,10 +50,10 @@ public class ParametreController implements Initializable {
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
|
||||
cmusique.setSelected(cbMusiqueCoche);
|
||||
cbEffetSonore.setSelected(cbSonCoche);
|
||||
clair.setSelected(cbClair);
|
||||
|
||||
cmusique.setSelected(cbMusiqueCoche);
|
||||
cbEffetSonore.setSelected(cbSonCoche);
|
||||
clair.setSelected(cbClair);
|
||||
sliderMusique.setValue(slideValue);
|
||||
|
||||
|
||||
langues.getItems().add("Anglais");
|
||||
@ -75,6 +80,7 @@ public class ParametreController implements Initializable {
|
||||
|
||||
} else if (Musique.musiqueEnCours != true) {
|
||||
Musique.resumeMusique(Musique.clip); // si elle a deja été lancé mais mis en pause, reprend a partir du point d'arret
|
||||
Musique.musiqueEnCours = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -162,4 +168,15 @@ public class ParametreController implements Initializable {
|
||||
System.out.println("on baisse le son");
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void slideVolumeMusique(MouseEvent mouseEvent) throws IOException{
|
||||
|
||||
if(Musique.musiqueEnCours == true) {
|
||||
Musique.setVolume(sliderMusique.getValue());
|
||||
slideValue = sliderMusique.getValue();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ public class PauseController implements Initializable {
|
||||
System.out.println("fichier audio non trouvé");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Pour les effets sonores
|
||||
if (cbEffet.isSelected() == true) {
|
||||
System.out.println("\tEffets sonores activé");
|
||||
|
@ -5,12 +5,13 @@
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Slider?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<Pane fx:id="rootPane" prefHeight="595.0" prefWidth="758.0" styleClass="background" stylesheets="@style/menu.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ParametreController">
|
||||
<Pane fx:id="rootPane" onMouseClicked="#slideVolumeMusique" prefHeight="595.0" prefWidth="758.0" styleClass="background" stylesheets="@style/menu.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ParametreController">
|
||||
<children>
|
||||
<HBox alignment="TOP_CENTER" layoutX="146.0" layoutY="171.0" prefHeight="242.0" prefWidth="507.0" spacing="10.0">
|
||||
<children>
|
||||
@ -18,23 +19,7 @@
|
||||
<children>
|
||||
<CheckBox fx:id="clair" mnemonicParsing="false" styleClass="checkBox" text="%mode.claire" />
|
||||
<CheckBox fx:id="cmusique" mnemonicParsing="false" styleClass="checkBox" text="%musique" />
|
||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="195.0">
|
||||
<children>
|
||||
<Button mnemonicParsing="false" onMouseClicked="#monterVolume" styleClass="bouton" stylesheets="@style/menu.css" text="Volume +">
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<Button layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onMouseClicked="#baisserVolume" styleClass="bouton" stylesheets="@style/menu.css" text="Volume -">
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
</children>
|
||||
</HBox>
|
||||
<Slider fx:id="sliderMusique" blockIncrement="1.0" majorTickUnit="1.0" max="1.0" minorTickCount="10" onMouseClicked="#slideVolumeMusique" showTickLabels="true" showTickMarks="true" value="0.1" />
|
||||
<CheckBox fx:id="cbEffetSonore" mnemonicParsing="false" styleClass="checkBox" text="%effet" />
|
||||
<VBox prefHeight="86.0" prefWidth="195.0" spacing="10.0">
|
||||
<children>
|
||||
|
Loading…
x
Reference in New Issue
Block a user