hey guys i came across a tutorial online that shows how to make a java media player using JMF..the problem is when i run the program and open the file i get the following error..i googled this and found no help can anyone please tell me whats wrong ? T_T ..i found this code online while looking for tutorials !

error

Unable to handle format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
Failed to realize: com.sun.media.PlaybackEngine@56278e83
Error: Unable to realize com.sun.media.PlaybackEngine@56278e83

here is the code !

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.media.*;

public class MediaPlayerDemo extends JFrame {
   private Player player;
   private File file;

   public MediaPlayerDemo()
   {
      super( "Demonstrating the Java Media Player" );

      JButton openFile = new JButton( "Open file to play" );
      openFile.addActionListener(
         new ActionListener() {
            public void actionPerformed( ActionEvent e )
            {
               openFile();
               createPlayer();
            }
         }
      );
      getContentPane().add( openFile, BorderLayout.NORTH );
  
      setSize( 300, 300 );
      show();
   }

   private void openFile()
   {      
      JFileChooser fileChooser = new JFileChooser();

      fileChooser.setFileSelectionMode(
         JFileChooser.FILES_ONLY );
      int result = fileChooser.showOpenDialog( this );

      // user clicked Cancel button on dialog
      if ( result == JFileChooser.CANCEL_OPTION )
         file = null;
      else
         file = fileChooser.getSelectedFile();
   }

   private void createPlayer()
   {
      if ( file == null )
         return;

      removePreviousPlayer();

      try {
         // create a new player and add listener
         player = Manager.createPlayer( file.toURL() );
         player.addControllerListener( new EventHandler() );
         player.start();  // start player
      }
      catch ( Exception e ){
         JOptionPane.showMessageDialog( this,
            "Invalid file or location", "Error loading file",
            JOptionPane.ERROR_MESSAGE );
      }
   }

   private void removePreviousPlayer()
   {
      if ( player == null )
         return;

      player.close();

      Component visual = player.getVisualComponent();
      Component control = player.getControlPanelComponent();

      Container c = getContentPane();
     
      if ( visual != null ) 
         c.remove( visual );

      if ( control != null ) 
         c.remove( control );
   }

   public static void main(String args[])
   {
      MediaPlayerDemo app = new MediaPlayerDemo();

      app.addWindowListener(
         new WindowAdapter() {
            public void windowClosing( WindowEvent e )
            {
               System.exit(0);
            }
         }
      );
   }

   // inner class to handler events from media player
   private class EventHandler implements ControllerListener {
      public void controllerUpdate( ControllerEvent e ) {
         if ( e instanceof RealizeCompleteEvent ) {
            Container c = getContentPane();
         
            // load Visual and Control components if they exist
            Component visualComponent =
               player.getVisualComponent();

            if ( visualComponent != null )
               c.add( visualComponent, BorderLayout.CENTER );

            Component controlsComponent =
               player.getControlPanelComponent();

            if ( controlsComponent != null )
               c.add( controlsComponent, BorderLayout.SOUTH );

            c.doLayout();
         }
      }
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.