I have the following code. No sound is being played I have no idea what I am doing wrong. I have a file called "Test" in the directory specified. It is of .mp3 format.
@Override
public void start(Stage stage) throws Exception
{
Media sound = new Media("file:///C:/Users/name/Music/HQ/Test.mp3");
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.setAutoPlay(true);
VBox root = new VBox();
root.getChildren().addAll();
Scene scene = new Scene(root, 500, 500);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
You have to call
mediaPlayer.play();
somewhere.setAutoPlay()
only sets the autoPlay-property.