I've set up a media player that plays a certain media file from a path in the program's directory. This runs in the Init
method of a Netbeans JavaFX application (Basically it calls init after loading the FXML
graph)
public static final Path APPLICATION_AUDIOTRACK = Paths.get("Audio", "L.I.F.T.mp3");
Media media = new Media(APPLICATION_AUDIOTRACK.toUri().toString());
this.mediaPlayer = new MediaPlayer(media);
this.mediaPlayer.play();
This works just fine (Audio plays, everything good) in the Netbeans environment, but when I try to run the standalone jar (After copying the jar from the dist folder after clean & build to the main program directory) I get this when running it:
Exception in thread "JavaFX Application Thread" MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414)
at com.protonmail.sarahszabo.formattool.core.Main_PanelController.lambda$initialize$2(Main_PanelController.java:190)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:274)
at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
... 9 more
Some notes about this:
Nowhere here does there appear to be anything wrong with the code per se, I get the feeling that i'm missing something subtle.
The jar was moved to the main program directory (As opposed to the dist folder that Netbeans makes automagically). I don't think that this is a library issue either (I do have some dependencies on Apache IO Commons), but the
lib
folder was moved as well, and this doesn't appear to be related to any lib issue as far as I can tell.I'm running this on Kubuntu 17.10. I've heard that previously x64 *buntu systems were unsupported on JRE 8, but I think that that post is dated (Over a year old: JavaFX media player on Ubuntu 16.04).
EDIT 0: I have glib-2.0
& libavcodec57
installed (Upon recommendation of: https://stackoverflow.com/a/35872444/2058221).