jsp中嵌入APPLET 使用jmf 刷新页面时会出现java.io.IOException: Capture device in use

shen23132379 2010-01-27 11:18:43
第一次进入页面可以正常显示视屏 但是当页面刷新时就会又调用APPLET 驱动又会重新加载 但是又不允许重复加载驱动
请问有什么方法可以解决 谢谢
错误如下:
MediaNode event thread java.lang.InterruptedException
MediaNode event thread java.lang.InterruptedException
java.io.IOException: Capture device in use
java.io.IOException: Capture device in use
javax.media.NoPlayerException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.io.IOException: Capture device in use
at javax.media.Manager.createPlayerForContent(Manager.java:1362)
at javax.media.Manager.createPlayer(Manager.java:417)
at javax.media.Manager.createRealizedPlayer(Manager.java:553)
at AppletTest.AppletTest.getJContentPane(AppletTest.java:106)
at AppletTest.AppletTest.init(AppletTest.java:64)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.awt.IllegalComponentStateException: contentPane cannot be set to null.
at javax.swing.JRootPane.setContentPane(Unknown Source)
at javax.swing.JApplet.setContentPane(Unknown Source)
at AppletTest.AppletTest.init(AppletTest.java:64)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.ThreadDeath
at java.lang.Thread.stop(Unknown Source)
at java.lang.ThreadGroup.stopOrSuspend(Unknown Source)
at java.lang.ThreadGroup.stop(Unknown Source)
at sun.awt.AppContext.dispose(Unknown Source)
at sun.applet.AppletClassLoader.release(Unknown Source)
at sun.plugin.security.PluginClassLoader.release(Unknown Source)
at sun.applet.AppletPanel.release(Unknown Source)
at sun.applet.AppletPanel.sendEvent(Unknown Source)
at sun.plugin.AppletViewer.onPrivateClose(Unknown Source)
at sun.plugin.AppletViewer$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

代码如下:

private CaptureDeviceInfo[] getDevices() { //得到所有驱动
Vector devices = CaptureDeviceManager.getDeviceList(null);
CaptureDeviceInfo[] info = new CaptureDeviceInfo[devices.size()];
for (int i = 0; i < devices.size(); i++) {
info[i] = (CaptureDeviceInfo) devices.get(i);
}
return info;
}
private CaptureDeviceInfo[] getVideoDevices() { //筛选视屏驱动

CaptureDeviceInfo[] info = getDevices();
CaptureDeviceInfo[] videoDevInfo;
Vector vc = new Vector();
for (int i = 0; i < info.length; i++) {
Format[] fmt = info[i].getFormats();
for (int j = 0; j < fmt.length; j++) {
if (fmt[j] instanceof VideoFormat) {
vc.add(info[i]);
}
break;
}
}
videoDevInfo = new CaptureDeviceInfo[vc.size()];
for (int i = 0; i < vc.size(); i++) {
videoDevInfo[i] = (CaptureDeviceInfo) vc.get(i);
}
return videoDevInfo;
}
private JPanel getJContentPane() { //把驱动加载到player中
DataSource videoDataSource=null;
if (jContentPane == null) {
BorderLayout borderLayout = new BorderLayout();
jContentPane = new JPanel();
jContentPane.setLayout(borderLayout);
MediaLocator ml = null;
try{
if (getVideoDevices()[0] != null) {
ml = getVideoDevices()[0].getLocator();
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp = player.getVisualComponent();
if (comp != null){
jContentPane.add(comp, BorderLayout.CENTER);
}
else
{
message="111";
return null;
}
}
else
{
message="222";
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
return jContentPane;
}
...全文
211 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shen23132379 2010-02-01
  • 打赏
  • 举报
回复
有没有会的啊 帮下忙啊
lovesi3344 2010-01-28
  • 打赏
  • 举报
回复
帮顶

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧