> I need help from someone PLEASE with getting a video into a Java file! I
> just now "perfected" getting audio into a Java file, but alas, I have
> never been able to see a video using Java code to do it. Can anyone help
> me with this?
Go snag yourself a copy of Java Media Framework and install it. Then
you can use the program below to see your video file. This is my debug
program to see all of the events and things. You can strip most of it
out but this should get you started.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.media.*;
import javax.media.control.*;
import javax.media.format.*;
public class VideoPlayer extends Frame {
Player player;
public VideoPlayer(String[] args) {
super("Video Player");
setLayout(new BorderLayout());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
if (player != null) {
player.stop();
player.close();
System.exit(0);
}
}
});
ControllerListener cl = new ControllerAdapter() {
public void configureComplete(ConfigureCompleteEvent cce) {
System.out.println("configure complete event");
}
public void controllerError(ControllerErrorEvent cee) {
System.out.println("controller error event");
}
public void controllerClosed(ControllerClosedEvent cce) {
System.out.println("controller closed event");
System.exit(0);
}
public void deallocate(DeallocateEvent de) {
System.out.println("deallocate event");
}
public void endOfMedia(EndOfMediaEvent eome) {
System.out.println("end of media event");
}
public void formatChange(FormatChangeEvent fce) {
System.out.println("format change event");
pack();
}
public void internalError(InternalErrorEvent iee) {
System.out.println("internal error");
}
public void mediaTimeSet(MediaTimeSetEvent mtse) {
System.out.println("media time set event");
}
public void prefetchComplete(PrefetchCompleteEvent pce) {
System.out.println("prefetch complete event");
}
public void realizeComplete(RealizeCompleteEvent rce) {
System.out.println("realize complete event");
Component c = player.getVisualComponent();
if (c != null)
add(c,BorderLayout.CENTER);
else
System.out.println("no visual component");
c = player.getControlPanelComponent();
if (c != null)
add(c,BorderLayout.SOUTH);
FormatControl formatControl = (FormatControl)
player.getControl("javax.media.control.FormatControl");
if (formatControl != null) {
c = formatControl.getControlComponent();
if (c != null)
add(c,BorderLayout.EAST);
else
System.out.println("no format control component");
} else
System.out.println("no format control");
pack();
setVisible(true);
}
public void restarting(RestartingEvent re) {
System.out.println("restarting event");
}
public void sizeChange(SizeChangeEvent sce) {
System.out.println("size change event");
}
public void start(StartEvent se) {
System.out.println("start event");
}
public void stop(StopEvent se) {
System.out.println("stop event");
}
public void transition(TransitionEvent te) {
System.out.println("transition event");
int state = te.getCurrentState();
switch (state) {
case Processor.Configuring:
System.out.println(" configuring");
break;
case Processor.Configured:
System.out.println(" configured");
break;
case Processor.Prefetching:
System.out.println(" prefetching");
break;
case Processor.Prefetched:
System.out.println(" prefetched");
break;
case Processor.Realizing:
System.out.println(" realizing");
break;
case Processor.Realized:
System.out.println(" realized");
break;
case Processor.Unrealized:
System.out.println(" unrealized");
break;
case Processor.Started:
System.out.println(" started");
break;
}
}
};
try {
MediaLocator ml;
File file = new File(args[0]);
if (file.exists()) {
ml = new MediaLocator(file.toURL());
} else
ml = new MediaLocator(args[0]);
player = Manager.createPlayer(ml);
player.addControllerListener(cl);
player.prefetch();
} catch (NoPlayerException npe) {
System.out.println(npe);
System.exit(0);
} catch (IOException ioe) {
System.out.println(ioe);
System.exit(0);
}
}
public static void main(String[] args) {
new VideoPlayer(args);
}
}

Signature
Knute Johnson
email s/nospam/knute/
Steve Burrus - 09 Apr 2006 20:35 GMT
Hi Knute Johnson, this is steve Burrus and I downloaded/installed last
nite the JMF as you suggested that I do, but u saying this to me :
>>"You can strip most of it out but this should get you started."<< I
have no idea in the world just what I should "strip" out of the Java
code due to the fact that this is absolutely the very first time in my
life that I have ever decided to "dabble" with getting some Java code to
allow me to view a video online!! Thanx in advance for your help.
>>snip<<
Roedy Green - 09 Apr 2006 22:49 GMT
>Hi Knute Johnson, this is steve Burrus and I downloaded/installed last
>nite the JMF as you suggested that I do, but u saying this to me :
[quoted text clipped - 3 lines]
>life that I have ever decided to "dabble" with getting some Java code to
>allow me to view a video online!! Thanx in advance for your help.
It is a fairly hairy API. All you can do is read the javadoc for the
methods Knute used and see if you need that functionality. If you
don't understand, leave it in. It will take several passese before it
all starts to jell what is going on.
Get an IDE that lets you rapidly see the Javadoc for a given method,
e.g. Eclipse.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
>I need help from someone PLEASE with getting a video into a Java file! I
>just now "perfected" getting audio into a Java file, but alas, I have
>never been able to see a video using Java code to do it. Can anyone help
>me with this?
have you read the material at http://mindprod.com/jgloss/jmf.html
yet?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.