This is the code i'm trying to execute:
public void playSound (){
Media media = new Media(new File(audioFile).toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
mediaPlayer.play();
}
(And yes, I know the program doesn't leave the method, but I wanted to see first if the Media object works)
This is the value of the audioFile instance:
this.audioFile = "C:\\(...)\\Pomodoro\\src\\Sounds\\calm.wav";
I'm trying to call this method when a timer reaches zero. But I get the following error message when my Media object is instantiated:
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module @0x2e23a125) cannot access class com.sun.glass.utils.NativeLibLoader (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.utils to unnamed module @0x2e23a125
Any suggestion on how to proceed?
I use JavaFX sdk - 20.0.1 and Java jdk-19
I asked ChatGPT for some advice, and it suggested that I should add '--add-exports javafx.graphics/com.sun.glass.utils=ALL-UNNAMED' in the VM-options run configuration. But that didn't help. I got the same error message.