Używając javafx.scene.media* chcę napisać odtwarzacz muzyki, mam jednak problem ze sliderem. Chcę za pomocą dwóch sliderów zmieniać odpowiednie wartości:
sliderProgress.valueProperty().addListener((observable, oldValue, newValue) -> {
System.out.println("Slider Value Changed (newValue: " + newValue.intValue() + ")");
});
sliderVolume.valueProperty().addListener((observableValue, number, t1) -> {
Main.player.setVolume(t1.doubleValue());
});
Jednak cały czas program rzuca na starcie wyjątek:
xception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImpl.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$2/1867750575.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
[path]/musicplayer/sample.fxml:6
Plik sample.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="musicplayer.Controller">
<children>
<HBox layoutX="44.0" layoutY="305.0" prefHeight="28.0" prefWidth="316.0" spacing="10.0">
<children>
<Button fx:id="buttonPlay" layoutX="98.0" layoutY="340.0" mnemonicParsing="false" onAction="#buttonPlayClicked" prefHeight="25.0" prefWidth="63.0" text="Play" />
<Button fx:id="buttonStop" layoutX="194.0" layoutY="340.0" mnemonicParsing="false" onAction="#buttonStopClicked" prefHeight="25.0" prefWidth="69.0" text="Stop" />
<Button fx:id="buttonMute" layoutX="288.0" layoutY="340.0" mnemonicParsing="false" onAction="#buttonMuteClicked" prefHeight="25.0" prefWidth="73.0" text="Mute" />
<Button fx:id="buttonOpenFile" layoutX="355.0" layoutY="340.0" mnemonicParsing="false" onAction="#buttonOpenFileClicked" prefHeight="25.0" prefWidth="77.0" text="Open file" />
</children>
</HBox>
<Slider fx:id="sliderVolume" layoutX="28.0" layoutY="103.0" orientation="VERTICAL" value="80.0" />
<Slider fx:id="sliderProgress" layoutX="46.0" layoutY="352.0" prefHeight="15.0" prefWidth="316.0" />
<Label fx:id="labelVolume" layoutX="26.0" layoutY="77.0" text="Vol." />
</children>
</Pane>