PDA

View Full Version : javafx not playing my sound



3v3rgr33n
December 14th, 2012, 10:49 PM
Hi

I've been playing around with javafx today trying to make a music player.
I keep getting the following Exception, I don't even understand what this "ibavformat.so.52" file is


** (process:11801): WARNING **: Failed to load plugin '/usr/local/java/jre1.7.0_07/lib/i386/fxavcodecplugin-52.so': libavformat.so.52: cannot open shared object file: No such file or directory
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(P latformImpl.java:153)
at com.sun.javafx.application.PlatformImpl.runLater(P latformImpl.java:148)
at javafx.application.Platform.runLater(Platform.java :52)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.ja va:450)
at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:365)
at zola.uct.Sax.BlueSax.play(BlueSax.java:129)
at zola.uct.Sax.BlueSax.actionPerformed(BlueSax.java: 121)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unk nown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mou seReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

I was just trying to play a ".wav" file. Here's my play method


@args The path of the sound file
public void play(String path){
File sound = new File(path);
Media song = new Media(sound.toURI().toString());
MediaPlayer player = new MediaPlayer(song);
player.play();
}

Unterseeboot_234
December 17th, 2012, 09:28 PM
Your snippet code's method looks OK.

What I have learned in JavaFX 2.2 is ALL, ANY and EVERY JRE plug-in must be deleted from your current hard drive to use the beta FX 2.2.

The new JRE has the package path inside the jars for FXSDK 2.2 beta

com.oracle.*

The original JRE has the package path inside FXSDK 2.1.0

com.sun.*

The new 2.2 stops all code from execution with FX version < 2.2 and logs out to Terminal with warnings to edit your code. Thus, any textbook about JavaFX has deprecated code, but not in Media / MediaPlayer.

So, check your JRE plug-in.

3v3rgr33n
December 19th, 2012, 10:13 AM
Thanx for the reply, I resorted to using JLayer instead of javafx for mp3 playback.