Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Build a JavaFX Application It's About Time Sounds About Right

MediaException: Could not create Player!

When I attempt to run the app, then play the sound just as shown in the video, I get a MediaException. However, if I convert to wav, it runs and plays the sound just fine. Any ideas?

Exception in thread "Thread-4" 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 com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer.play(NativeMediaAudioClipPlayer.java:319)
    at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer.clipScheduler(NativeMediaAudioClipPlayer.java:112)
    at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer.access$000(NativeMediaAudioClipPlayer.java:47)
    at com.sun.media.jfxmediaimpl.NativeMediaAudioClipPlayer$Enthreaderator.lambda$static$4(NativeMediaAudioClipPlayer.java:85)
    at java.lang.Thread.run(Thread.java:745)

5 Answers

Eric Schroeder
Eric Schroeder
19,882 Points

I've run into the same problem, not sure which OS you're using but I'm using Ubuntu 16.04. From my digging I think it's a compatibility issue between Java 8 and Ubuntu. Java wants to see libavcodec53 and libavformat53, 16.04 has libavcodec56 and libavformat56. I don't think you can downgrade these packages (I could be wrong) on newer ubuntu versions. I just use .wav file as you did, probably the easiest fix.

Check "JavaFX Media" at the bottom of this page.

Mike Hagedon
Mike Hagedon
15,968 Points

Thanks, Ubuntu 16.10 has the same issue. A .wav file worked!

I had the same issue and I'm running Elementry OS based on ubuntu, using a wav file solves the problem

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hmm... can you make sure that you are importing the right MediaClip class. Make sure it's from JavaFX, not the Applet one.

The same problem on Ubuntu

Jason Force
Jason Force
7,508 Points

Eric Schroeder Found a good link. I had the same problem on Ubuntu (Gnome) 17.04. However, instead of installing more packages (as the docs at that link suggest) I just converted the file to a .wav with VLC and that worked fine for me. Gotta love VLC.