You are not logged in.

#1 2018-09-03 12:34:36

remus
Member
Registered: 2015-11-03
Posts: 32

Playing music with JavaFX broke (once again)

I’ve written a small custom music player in Java, using JavaFX.

At first it worked fine, then suddenly it threw an exception when trying to play an audio file. After a bit of searching (I don’t think I had to resort to posting here) I found the solution in the ArchWiki: install "libavutil-52" and "ffmpeg-compat-55" from AUR and that’s it. It worked fine after that. (Was at the beginning of June.)

Now, though, it broke again, and doesn’t want to play any audio files (I tried all formats I could find – MP3, M4A, OGG, FLAC). The exceptions look as follows:

ERROR An error occurred during playback of file /path/to/file:
MediaException: MEDIA_UNSUPPORTED : [] ERROR_MEDIA_AUDIO_FORMAT_UNSUPPORTED: ERROR_MEDIA_AUDIO_FORMAT_UNSUPPORTED
        at javafx.scene.media.Media._setError(Media.java:513)
        at javafx.scene.media.MediaPlayer.lambda$handleError$2(MediaPlayer.java:1736)
        at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$5(GtkApplication.java:139)
        at java.lang.Thread.run(Thread.java:748)
ERROR An error occurred during playback of file /path/to/file:
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 MusicPlayer.setMediaPlayer(MusicPlayer.java:384)
        at MusicPlayer.next(MusicPlayer.java:315)
        at MusicPlayer.play(MusicPlayer.java:240)
        at MusicPlayer.playOrPause(MusicPlayer.java:280)
        at MusicPlayer.access$2400(MusicPlayer.java:26)
        at MusicPlayer$Controller.executeCommand(MusicPlayer.java:591)
        at MusicPlayer$Controller.run(MusicPlayer.java:570)
        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

I couldn’t find any recent information on how to fix this. Does anyone have a clue what could be the problem? (Anyone else experiencing such issues after the latest Pacman updates?)

Offline

#2 2018-09-03 13:25:05

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 5,714

Re: Playing music with JavaFX broke (once again)

In general it's quite likely that one of the involved encoder/decoder libraries (like x264) got updated. When that happens it is your responsibility to rebuild dependant AUR packages.

However which JavaFX implementation are you using? Which java version?

Offline

#3 2018-09-03 14:05:35

remus
Member
Registered: 2015-11-03
Posts: 32

Re: Playing music with JavaFX broke (once again)

Ah, right, forgot to mention that: Neither of the two AUR packages has an update. (But that could, of course, soon change.)
Or could re-building and re-installing the package still change something?

My Java packages are:
local/java-environment-common 3-1
local/java-openjfx 8.u172-2
local/java-runtime-common 3-1
local/jdk8-openjdk 8.u181-1
local/jre8-openjdk 8.u181-1
local/jre8-openjdk-headless 8.u181-1
(I also have Java 7 installed, but I’m using 8.)

Last edited by remus (2018-09-03 14:06:09)

Offline

#4 2018-09-03 15:24:06

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 5,714

Re: Playing music with JavaFX broke (once again)

Yes it will change something, the mentioned package is notorious for breaking ABI with every release and bumping it's soname. You have to rebuild relevant AUR packages so that they properly link against the correct ABI version again.

However if you are currently using the repo version of openjfx, that one hasn't seen an update in a while itself, so it might actually be the openjfx package that needs the rebuild.

Last edited by V1del (2018-09-03 15:25:32)

Offline

#5 2018-09-04 10:05:09

remus
Member
Registered: 2015-11-03
Posts: 32

Re: Playing music with JavaFX broke (once again)

OK, thanks for the additional information!
I had already seen that "java-openjfx" hadn’t had an update in a while – forgot to mention that, too.

Anyways, I now tried to re-build and re-install the two AUR packages, but ffmpeg-compat-55 failed to build (see my comment there). So maybe that is related and once the package is updated this will work again?
I also tried just re-installing "java-openjfx", but, predictably, that didn’t really do anything.

Offline

#6 2018-09-04 14:26:08

anderberin
Member
Registered: 2016-02-08
Posts: 2

Re: Playing music with JavaFX broke (once again)

Same problem here...
AUR package ffmpeg-compat-55 failed to build with libx264 error...

Offline

#7 2018-09-04 14:42:41

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 5,714

Re: Playing music with JavaFX broke (once again)

FWIW you could try to use e.g. ABS to rebuild the openjfx package yourself, maybe it simply needs a rebuild against the repo ffmpeg package (though if that was the case we would've likely already seen this happen, so there might be more to it)

Offline

#8 2018-09-04 15:50:37

remus
Member
Registered: 2015-11-03
Posts: 32

Re: Playing music with JavaFX broke (once again)

Thanks for the suggestion!
Would be interesting getting more into custom package development (i.e., looking at ABS more closely), but I fear I currently lack the time for that. Still, I’ll keep it in mind, in case no solution pops up of its own accord in the next few days.

Offline

Board footer

Powered by FluxBB