I’ve never played with JavaFX sound before but I’m not getting any results… What’s wrong with this code:
public class SoundThing {
public void play() {
Media sound;
try {
sound = new Media(SoundThing.class.getResource("/resource/sound/duck.mp3").toURI().toString());
} catch (URISyntaxException e) {
throw new RuntimeException();
}
System.out.println("playing sound");
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.play();
}
}
I don’t get any exceptions, just no sound.