C
Christian Otteneuer
Hallo NG,
I am not sure if I am right in these newsgroup. I have the following
problem: I want to add the MediaPlayer from JMF to my Swing GUI.
Therefor, I have written two simple classes:
// My SwingApplication:
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.*;
public class SwingApplication {
public SwingApplication() {
Frame mf = new Frame();
MediaPlayerObject m = new MediaPlayerObject();
JPanel panel = new JPanel();
panel.add(m);
mf.add(panel);
mf.setSize(new Dimension(1024,768));
mf.setVisible(true);
}
public static void main (String[] args) {
SwingApplication sw = new SwingApplication();
}
}
// My MediaPlayerObject
import javax.media.bean.playerbean.MediaPlayer;
import javax.swing.JPanel;
public class MediaPlayerObject extends JPanel {
public MediaPlayer player;
String videofile = "d:/myvideofile.mpg";
MediaPlayerObject() {
if (player != null)
player.close ();
player = new MediaPlayer();
player.setMediaLocation("file:///" + videofile);
player.setPlaybackLoop(false);
//player.addControllerListener (this);
player.prefetch ();
this.add(player);
player.start ();
}
}
The MediaPlayerObject starts playing my video and it is added to my
JPanel in the SwingApplication class.
Now the problem: When I start class, I can hear the video. But I have to
change the size of the whole frame first until I can also see it. What
can I do that I can see it immediately?
Hope, someone can help me?
Cheers,
Chris
I am not sure if I am right in these newsgroup. I have the following
problem: I want to add the MediaPlayer from JMF to my Swing GUI.
Therefor, I have written two simple classes:
// My SwingApplication:
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.*;
public class SwingApplication {
public SwingApplication() {
Frame mf = new Frame();
MediaPlayerObject m = new MediaPlayerObject();
JPanel panel = new JPanel();
panel.add(m);
mf.add(panel);
mf.setSize(new Dimension(1024,768));
mf.setVisible(true);
}
public static void main (String[] args) {
SwingApplication sw = new SwingApplication();
}
}
// My MediaPlayerObject
import javax.media.bean.playerbean.MediaPlayer;
import javax.swing.JPanel;
public class MediaPlayerObject extends JPanel {
public MediaPlayer player;
String videofile = "d:/myvideofile.mpg";
MediaPlayerObject() {
if (player != null)
player.close ();
player = new MediaPlayer();
player.setMediaLocation("file:///" + videofile);
player.setPlaybackLoop(false);
//player.addControllerListener (this);
player.prefetch ();
this.add(player);
player.start ();
}
}
The MediaPlayerObject starts playing my video and it is added to my
JPanel in the SwingApplication class.
Now the problem: When I start class, I can hear the video. But I have to
change the size of the whole frame first until I can also see it. What
can I do that I can see it immediately?
Hope, someone can help me?
Cheers,
Chris