Sound in the JavaFX toolkit is broken

This is the exception raised every time I try to use the MediaPlayer which is used for playing audio and video files.

javafx.scene.media.MediaException: com.sun.media.jfxmedia.MediaException: Could not create player!
	at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146) ~[jfxrt.jar:?]
	at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511) ~[jfxrt.jar:?]
	at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414) ~[jfxrt.jar:?]
	[ Redacted paths here ]
	at javax.swing.SwingWorker$1.call(SwingWorker.java:295) [?:1.8.0_151]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151]
	at javax.swing.SwingWorker.run(SwingWorker.java:334) [?:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_151]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
	at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:224) ~[jfxrt.jar:?]
	at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:104) ~[jfxrt.jar:?]
	at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467) ~[jfxrt.jar:?]
	... 13 more

This issue happens even with the pulseaudio plug, and the following added in stage-packages.

- gstreamer1.0-pulseaudio
- gstreamer1.0-plugins-base
- gstreamer1.0-plugins-good
- gstreamer1.0-libav
- libgstreamer-plugins-base1.0-0
- libgstreamer-plugins-good1.0-0
- libpulse0
- libavcodec-ffmpeg56
- libavformat-ffmpeg56
- libflac8
- libogg0
- libopus0
- liborc-0.4-0
- libspeex1
- libtheora0
- libvorbis0a
- libvpx3
- libwavpack1
- libmp3lame0

Moreover, this happens with both the Oracle JRE, and the OpenJDK with OpenJFX. This happens for .wav and .mp3 files, so clearly it’s not related to the kind of file you try to throw at it.

This is quite problematic as JavaFX is pitched as “the future of Java” most of the time, and is the modern go-to when it comes to Java GUI toolkits. Do note that only the media part of JavaFX (audio and probably videos) is broken.

(Note : I am putting this in the snapd category as I am not sure what is faulty here. It seems that the build has nothing to do as everything seems to be packaged correctly, just runtime fails.)

As a side note : running the bundled java from the prime/ folder seems to work, but I think it’s pulling some kind of library from the system but I can’t figure out which, even with strace).

This is a followup to my previous post, as I realise the issue is bigger than just my use case.

Does it work when you install the snap with --devmode?

No, it does not work when using --devmode

Should I open a bug on launchpad? This is such a niche problem that I am not sure if it needs a bug report or not

I’m not sure what the bug would be about, though.

Can you build a minimal thing that exposes the issue? (I know ‘minimal’ and ‘java’ or not concepts that get along well…)

Hey sorry to bother you, did you find a fix to this issue ? I have the same problem and my app is quite reliant on audio.