1 Reply Latest reply: Aug 30, 2011 9:40 AM by captfoss RSS

    Unable To Handle Format

    884842
      Hi everyone. I am new to using JMF. I recently downloaded the JMF 2.1.1e (using the windows installer version). I ran a simple audio program using command prompt and Netbeans. The code is shown below:
      import java.awt.event.WindowEvent;
      import javax.media.*;
      import java.io.File;
      import java.awt.*;
      import java.awt.event.WindowAdapter;
       
      public class TrivialJMFPlayer extends Frame {
       
          public static void main (String[] args) {
              try {
                  TrivialJMFPlayer f = new TrivialJMFPlayer();
                  f.pack();
                  f.addWindowListener(
                          new WindowAdapter() {
      
                      @Override
                      public void windowClosed(WindowEvent e) {
                          super.windowClosed(e);
                          System.exit(0);
                          
                      }
                          
                          }
                          );
                  f.setVisible (true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
              
          }
          public TrivialJMFPlayer() 
              throws java.io.IOException,
                     java.net.MalformedURLException,
                     javax.media.MediaException {
              FileDialog fd = new FileDialog
                  (this, "TrivialJMFPlayer", FileDialog.LOAD);
              fd.setVisible(true);
              
              File f = new File(fd.getDirectory(), fd.getFile());
              Player p = Manager.createRealizedPlayer
                  (f.toURI().toURL());
              Component c = p.getVisualComponent();
              if(c != null)
                  this.add(c);
              p.start();
          }
      }
      When I run the code using netbeans and eclipse, for any audio file i select, it gives this error message:

      Unable to handle format: ULAW, 8000.0 Hz, 8-bit, Mono, Signed, FrameSize=8 bits
      Failed to prefetch: com.sun.media.PlaybackEngine@2b313906
      Error: Unable to prefetch com.sun.media.PlaybackEngine@2b313906
      (actually this error message shows when I run a .au file. For other formats, its basically the same error, the parameters just changes.)

      When I run the code using command prompt (I'm using windows 7), it succeeds for files of .au and .wav formats. For .mp3 format, it shows the error message shown above.

      I then tried playing all the audio files (.au, .wav, and .mp3) using JMStudio and It worked!!! The error message obviously shows that I added the library correctly and it used them to run. I just do not understand why it cannot play some files in command-prompt and all files in an IDE!!
      I need help please!!!!! I would really appreciate it.
        • 1. Re: Unable To Handle Format
          captfoss
          I just do not understand why it cannot play some files in command-prompt and all files in an IDE!!
          Then you must not be very familiar with working with 3rd party libraries with an IDE...
          When I run the code using netbeans and eclipse, for any audio file i select, it gives this error message:
          When I run the code using command prompt (I'm using windows 7), it succeeds for files of .au and .wav formats. For .mp3 format, it shows the error message shown above.
          Netbeans and Eclipse use their own special PATH variables, which means they don't know where to find JMF.jar. You have to add that JAR file explicitly to your libraries path for your project.

          Further, JMF doesn't play MP3 files unless you also install the MP3 plugin.