help with getting my movie in
ive created a simple gui and want to input an mpeg file but carnt get
it working, can anyone help me rearrange my code or explain how to do
it or what the prob is many thanks i have been tryin alsorts so i ts a
bit of a mess lol :P
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.*;
import java.net.*;
public class KD1 extends JFrame
{
public KD1() throws Exception
{
URL iliketheway = null;
Player myPlayer = null;
//iliketheway = new URL( "D:\\Documents and Settings\\ben\\My
Documents\\Modelworks\\MyProjects\\I Like The Way.mpg" );
//myPlayer = Manager.createPlayer(iliketheway);
myPlayer = Manager.createPlayer( new MediaLocator( "D:\\Documents
and Settings\\ben\My Documents\\Modelworks\\MyProjects\\I Like The
Way.mpg" ));
Component myVisual = null;
Component myControls = null;
JPanel visualPanel = null;
myVisual = myPlayer.getVisualComponent();
if (myVisual != null)
{
visualPanel = new JPanel();
visualPanel.setLayout(new FlowLayout());
visualPanel.add(myVisual);
myControls = myPlayer.getControlPanelComponent();
if (myControls != null)
{
}
}
getContentPane().setLayout(new BorderLayout() );
JPanel t = new JPanel(new BorderLayout());
ImageIcon icon = new ImageIcon("H:\\PROJECT\\TRANSITION.JPG") ;
JButton transition = new JButton(icon);
JButton play = new JButton("PLAY");
play.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println( "start playing" );
}
}
);
JButton stop = new JButton("STOP");
stop.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println( "stop playing" );
}
}
);
JLabel title = new JLabel("karaokedrive version 1", JLabel.CENTER);
getContentPane().setBackground(Color.yellow);
getContentPane().add(title, BorderLayout.NORTH );
getContentPane().add(t, BorderLayout.CENTER );
t.add(transition, BorderLayout.CENTER);
getContentPane().add(play, BorderLayout.SOUTH );
getContentPane().add(stop, BorderLayout.SOUTH );
getContentPane().add(visualPanel, BorderLayout.CENTER );
getContentPane().add(myControls, BorderLayout.SOUTH );
// start
addWindowListener(
new WindowAdapter()
{
public void windowClosing( WindowEvent we )
{
System.out.println( "i will not quit" );
}
}
);
// end of window listener bit
}
public static void main( String Args[] )throws Exception
{
KD1 myFrame = new KD1();
int width = 700;
int height = 500;
myFrame.setSize(width, height);
myFrame.setVisible( true );
}
}