If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

JMF question: question about the unrealized player

Dear all,

I am a newbie in JMF and just got a problem in running my first JMF java program.

I wanted to create a player and play some video. And I happened to get some code which could run properly. But after my further exploration, it seems that I could not understand some of the part. Could anyone please enlighten there? Thanks in advance.

Questions:

1. when I add in thePlayer.realize(); after thePlayer.start(); in method start(), I get compilation error as such

++++++++++++++++
C:\\test>java MPlayer
javax.media.NotRealizedError: Cannot get gain control on an unrealized player
at com.sun.media.MediaPlayer.getGainControl(MediaPlayer.java:58)
at MPlayer.start(MPlayer.java:215)
at MPlayer.<init>(MPlayer.java:158)
at MPlayer.main(MPlayer.java:252)
Exception in thread "main" javax.media.NotRealizedError: Cannot get
gain control on an unrealized player
at com.sun.media.MediaPlayer.getGainControl(MediaPlayer.java:58)
at MPlayer.start(MPlayer.java:215)
at MPlayer.<init>(MPlayer.java:158)
at MPlayer.main(MPlayer.java:252)
++++++++++++++++++

I understand that the problem is that player is not realized yet. But may I ask what is the importance to realize the player? Meanwhile, when I read about some relavant meterial, I got to know that player has many phases like unrealized, realized, prefetched. May I ask if I need to know each and every phase well before I could realy write my own player using JMF? If it is, could you kindly give me some hint to find relavant meterial regarding that?

I know that since the MPlayer class is implementing ActionListener, ControllerListener, so it has to implement actionPerformed. But May I ask what will be the action which will trigger this listener? I have tried playing with it. I still could not figure it out.

}
/* (non-Javadoc)
* @see javax.media.ControllerListener#controllerUpdate(javax.media.ControllerEvent)
*/
/**
* This controllerUpdate function must be defined in order to
* implement a ControllerListener interface. This
* function will be called whenever there is a media event
*/
public void controllerUpdate(ControllerEvent event) {
Object controlComponent = null;
// If we're getting messages from a dead player,
// just leave
if (thePlayer == null)
return;

// When the player is Realized, get the visual
// and control components and add them to the Applet
if (event instanceof RealizeCompleteEvent) {
//if (progressBar != null) {
//panel.remove(progressBar);
//progressBar = null;
System.out.println("Realized");
if (thePlayer.getVisualComponent() != null) {