importjava.applet.*;importjava.awt.*;importjava.io.*;importjava.net.*;importjavax.media.*;publicclassaudio1extendsAppletimplementsControllerListener{URLurl=null;Playerply...
import java. applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.media.*;
public class audio1 extends Applet implements ControllerListener
{ URL url=null;
Player ply=null;
Component vcmpt=null;
Component ccmpt=null;
public void init(){ setBackground(Color.cyan);
try{
url =new URL(getDocumentBase(),"hello.avi");
ply=Manager.createPlayer(url);//创建播放器
if(ply!=null) ply.addControllerListener(this);
else System.out.println("failed to Create Palyer");
}catch(Exception e) { }
}
public void start(){
if(ply!=null)ply.prefetch();//预获取
}
public synchronized void controllerUpdate(ControllerEvent e){
if(e instanceof RealizeCompleteEvent){//判断 e 是不是RealizeCompleteEvent得对象 if((vcmpt=ply.getVisualComponent())!=null) add(ccmpt,"");//添加可视组件vcmpt if((ccmpt=ply.getControlPanelComponent())!=null)//添加控制面板组件
add(ccmpt,"");
validate();//显示所添加的组件;
} else if (e instanceof PrefetchCompleteEvent)ply.start();
}
public void stop(){
if(ply!=null){
ply.stop(); ply.deallocate(); } } }
这是一个小的播放器,运行后显示这样:java.io.IOException: File Not Found
java.io.IOException: File Not Found
展开