Results 1 to 1 of 1
- 05-12-2008, 10:41 PM #1
Member
- Join Date
- May 2008
- Posts
- 9
- Rep Power
- 0
JMF : Unable to handle format: MJPG, 320x240, FrameRate=15.0, Length=33792 0
hi there :)
i have a problem with self made media player ..
when running a simple AVI file with that code , it tells me the error posted above
actually it runs the sound of the video but not the video
any ideas ?
here is the code
Java Code:import java.awt.*; import java.awt.event.*; import javax.media.*; import javax.media.format.*; import javax.media.protocol.*; public class VideoPlayer1 extends Frame implements ControllerListener, ActionListener { Player videoPlayer; String filename; /** Creates new VideoPlayer1 */ public VideoPlayer1(String s1) { super(s1); //handle window event handler addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { dispose(); System.exit(0); } }); //create the menu MenuBar mb = new MenuBar(); setMenuBar(mb); Menu fileMenu = new Menu("File"); mb.add(fileMenu); MenuItem itemPlay = new MenuItem("Play"); itemPlay.addActionListener(this); fileMenu.add(itemPlay); MenuItem itemStop = new MenuItem("Stop"); itemStop.addActionListener(this); fileMenu.add(itemStop); MenuItem itemExit = new MenuItem("Exit"); itemExit.addActionListener(this); fileMenu.add(itemExit); } //add the event handler public void actionPerformed(ActionEvent ae) { String action = ae.getActionCommand().toString(); if (action.equals("Play")) { play(); } if (action.equals("Stop")) { stop(); } if (action.equals("Exit")) { dispose(); System.exit(0); } } private void stop() { if (videoPlayer != null) { videoPlayer.stop(); } } //play the video public void play() { try { //ask the user for a file name FileDialog fd =new FileDialog(this, "Choose Video", FileDialog.LOAD); fd.show(); //assemble the filename filename = fd.getDirectory() + fd.getFile(); //create the player videoPlayer = Manager.createPlayer( new MediaLocator("file:///" + filename)); //add a listener for player state changes videoPlayer.addControllerListener(this); videoPlayer.start(); }catch (Exception e) { System.out.println("Error " + e); } } //play public synchronized void controllerUpdate( ControllerEvent event) { System.out.println("Event: " + event); if (event instanceof RealizeCompleteEvent) { Component comp; if ((comp = videoPlayer.getVisualComponent()) != null) { add("Center", comp); }else System.out.println("Unable to get visual component"); if ((comp = videoPlayer.getControlPanelComponent()) != null) { add("South", comp); } validate(); } } }Java Code:public static void main(String[] args) { VideoPlayer1 vp1 = new VideoPlayer1("VideoPlayer1"); //show the frame containing the video vp1.show(); //size the window vp1.setSize(300,301); vp1.setLocation(250,300); }
Similar Threads
-
How to handle socket Exception
By mayank0512 in forum NetworkingReplies: 14Last Post: 12-21-2010, 11:31 PM -
Better way to handle exceptions
By javaplus in forum Advanced JavaReplies: 2Last Post: 01-16-2008, 06:47 PM -
Determining Midi Length
By Usagi in forum New To JavaReplies: 0Last Post: 12-08-2007, 11:45 PM -
how to handle exceptions
By paty in forum Advanced JavaReplies: 2Last Post: 08-05-2007, 04:17 AM -
Help with method length
By toby in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks