Oops! Eclipse + JSP + Applet + JMF Quick Start
Reference:
http://community.csdn.net/Expert/topic/5481/5481629.xml?temp=.1175043
applet的class文件最好不要放在web-inf目录下,因为这是个特殊目录
视频测试文件:
/Files/pixysoft/test.rar
Quick Start:
新建一个Dynamic Web Project项目,叫做Oops_JMF_Applet,然后修改project – properties,default output folder为:Oops_JMF_Applet/WebContent/classes
添加以下引用,全部可以在JMF包里面找到
在src目录下面增加一个文件:PlayerApplet.java
import java.applet.*;
import java.awt.*;
import java.net.*;
import javax.media.*;
public class PlayerApplet extends Applet implements ControllerListener
{
Player player = null;
public void init()
{
setLayout(new BorderLayout());
String mediaFile = getParameter("FILE");
try
{
URL mediaURL = new URL(getDocumentBase(), mediaFile);
player = Manager.createPlayer(mediaURL);
player.addControllerListener(this);
}
catch (Exception e)
{
System.err.println("Got exception " + e);
}
}
public void start()
{
player.start();
}
public void stop()
{
player.stop();
player.deallocate();
}
public void destroy()
{
player.close();
}
public synchronized void controllerUpdate(ControllerEvent event)
{
if (event instanceof RealizeCompleteEvent)
{
Component comp;
if ((comp = player.getVisualComponent()) != null)
add("Center", comp);
if ((comp = player.getControlPanelComponent()) != null)
add("South", comp);
validate();
}
}
}
在WebContent下面添加一个文件index.jsp。注意codebase问题
<html>
<body>
<APPLET CODE=PlayerApplet WIDTH=320 HEIGHT=300
codebase="/Oops_JMF_Applet/classes/">
<PARAM NAME=FILE VALUE="test.mpg">
</APPLET>
</body>
</html>
程序clean一下,在webContent目录下面添加一个test.mpg文件,然后选择index.jsp,Run on Server,选一个tomcat服务器,ok!
可惜不能截图。。。
posted on 2007-09-15 01:24
张辰 阅读(1095)
评论(0) 编辑 收藏 所属分类:
Dr. Oops