0

I am trying to play mp3 file in java program using javafx. I installed dependencies libavcodec53 and libavformat53 mentioned here. I used following code

public void play(String path_to_song){ JFXPanel fxPanel = new JFXPanel(); String song = new File(path_to_song).toURI().toString(); Media audio =null; audio = new Media(song); MediaPlayer mediaPlayer = new MediaPlayer(audio); mediaPlayer.play(); }

But I still got error "Error media audio format unsupported"

Exception in thread "main" MediaException: MEDIA_UNSUPPORTED : com.sun.media.jfxmedia.MediaException: "Error media audio format unsupported" : com.sun.media.jfxmedia.MediaException: "Error media audio format unsupported" at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:125) at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:474) at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:383) at playback.Player.play(Player.java:39) at engine.Execute.main(Execute.java:15) Caused by: com.sun.media.jfxmedia.MediaException: "Error media audio format unsupported" at com.sun.media.jfxmediaimpl.MediaUtils.nativeError(MediaUtils.java:331) at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia.init(GSTMedia.java:50) at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia.<init>(GSTMedia.java:33) at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer.<init>(GSTMediaPlayer.java:39) at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTPlatform.prerollMediaPlayer(GSTPlatform.java:100) at com.sun.media.jfxmediaimpl.platform.PlatformManager.createMediaPlayer(PlatformManager.java:173) at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:264) at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:139) at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:431)

Any ideas?

0

Solved by upgrading Java. It was bug in current version back than.

https://stackoverflow.com/questions/24848752/javafx-mp3-playback-ubuntu-14-04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.