package com.shi.audioTest;import java.awt.*;import javax.media.*;import javax.swing.*;public class Audiotest2 { /**
 * @param args
 */
public static void main(String[] args) {
MainFrame2 mf=new MainFrame2("file:///D:/1.avi");
mf.setResizable(true);
mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class MainFrame2 extends JFrame implements ControllerListener
{
  
private JPanel contentPane;
Component vc=null;
Component cc=null;
Player player=null;
public MainFrame2(String mediaURL)
{
try{
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
player=Manager.createPlayer(new MediaLocator (mediaURL)); }catch(Exception e)
{
System.out.println("NO "+mediaURL+" File ");
e.printStackTrace();
}
if(player==null)
{
System.out.println("Could not creat the player !");
System.exit(-1);
}
player.addControllerListener(this); player.prefetch();
}
public void controllerUpdate(ControllerEvent e) {
if(e instanceof ControllerClosedEvent)
{
System.out.println(e.toString());
System.exit(0);
}
if(e instanceof EndOfMediaEvent)
{
player.setMediaTime(new Time(0));
player.start();
return;
}
if(e instanceof RealizeCompleteEvent)
{
player.start();
vc=player.getVisualComponent();
if(vc!=null)
{
System.out.println("sdfdsfdsf");
this.add(vc,BorderLayout.CENTER);
cc=this.getContentPane();
if(cc!=null)
{
this.getContentPane().add(cc,BorderLayout.SOUTH);
this.pack();
this.setResizable(false);
this.setVisible(true);
}
}
}
}

}
有声音,但为什么没图像?为什么vc=null?