0

I'm working on a project for a programming class, and I want to add a video file. I've tried using JMF, except when I try to play a video (using one of the formats listed on the Java website), it gives me the error:

Unable to handle format: XVID, 320x213, FrameRate=29.9, Length=204480 0 extra bytes
Unable to handle format: mpeglayer3, 22050.0 Hz, 0-bit, Stereo, Unsigned, 8000.0 framerate,FrameSize=4608 bits
Failed to realize: com.sun.media.PlaybackEngine@39b27b
Error: Unable to realize com.sun.media.PlaybackEngine@39b27b
Could not realize media player

This is the code I use to test the player:

public MediaPanel(String path) {

    try {
        videoPath = new File(path).toURI().toURL();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    setLayout(new BorderLayout());
    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

    try {
        Player mediaPlayer = Manager.createRealizedPlayer(videoPath);
        Component video = mediaPlayer.getVisualComponent();
        Component controls = mediaPlayer.getControlPanelComponent();

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

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

        mediaPlayer.start();
    } catch (NoPlayerException NoPlayerException) {
        System.err.println("No media player found");

    } catch (CannotRealizeException CannotRealizeException) {
        System.err.println("Could not realize media player");
    } catch (IOException IOException) {
        System.err.println("Error reading from the source");
    }
}

MediaPanel player = new MediaPanel("intro.avi");

I assume my two options are to make a video with the exact specifications listed on the Java website (because apparently just the file extension isn't enough), or use another method to display video.

How can I fix this? Do I need to make a video exactly as the specifications note (see link at bottom)?

NOTE: The class I'm in uses and older version of java that DOESN'T contain javaFX. Please don't recommend this unless there is a way I can add it without having the school reinstall a newer version of Java.

Aaron
  • 992
  • 3
  • 15
  • 33
  • 1
    [vlcj](http://code.google.com/p/vlcj/) (VLC embedded in Java) – MadProgrammer May 24 '13 at 03:30
  • @AndrewThompson He didn't -- I'm working on this as an addition to my final project. – Aaron May 24 '13 at 03:31
  • @AndrewThompson Having non working code doesn't add to the project. I would appreciate help with my problem, not a commentary on your thoughts about my education. – Aaron May 24 '13 at 23:14

0 Answers0