Play media on Shoes4 with JavaFX MediaPlayer
For Shoes4 the video method is not yet available so if you want to play an mp3 file for example on Shoes4 you can use the MediaPlayer class from JavaFX.
There is only one trick that you’re not allowed to miss and the trick is that you have to create a new instance of JFXPanel because the MediaPlayer is depending on the JavaFX interface. Otherwise you will experience an
java.lang.IllegalStateException: Toolkit not initialized exception.
For example to play
file.mp3 you can run the following code: