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

shen23132379 shen23132379 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
第一次进入页面可以正常显示视屏 但是当页面刷新时就会又调用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;
}
...全文

相关推荐

大模型+数字仓储解决方案.pptx

大模型+数字仓储解决方案.pptx

公众号:优享智库

中小企业在引进外部技术进行产业化时,标准的技术转移操作流程是什么?.docx

科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

MES车间级工业4.0智能制造管理系统.pptx

MES车间级工业4.0智能制造管理系统.pptx

公众号:优享智库

5G 工业互联网规划方案.pptx

5G 工业互联网规划方案.pptx

公众号:优享智库

考虑电动汽车移动储能特性的多区域电网功率波动平抑优化调控研究(Python代码实现)

内容概要:本文研究了考虑电动汽车移动储能特性的多区域电网功率波动平抑优化调控方法,并提供了相应的Python代码实现。通过将电动汽车视为具有时空灵活性的可移动储能单元,构建了综合考虑电网负荷、可再生能源出力不确定性及用户出行需求的优化模型。该模型利用电动汽车集群的协同调度能力,在满足出行约束的前提下实现削峰填谷,有效平抑多区域电网功率波动,降低系统运行成本并提升新能源消纳能力。采用数学优化方法求解该模型,实现了对多区域电网功率波动的协同优化调控,增强了高比例新能源接入背景下电网运行的稳定性与经济性。; 适合人群:具备一定电力系统基础知识和Python编程能力的研究生、科研人员及从事智能电网、电动汽车与能源互联网相关领域的工程技术人员。; 使用场景及目标:①研究电动汽车作为分布式储能参与电网调峰调频的可行性与优化调度策略;②实现多区域电网功率波动的协同优化控制;③为高比例可再生能源接入背景下的电网稳定运行提供技术支持与决策参考。; 阅读建议:此资源以Python代码实现为核心,结合理论模型与仿真验证,建议读者在学习过程中重点关注优化模型的构建逻辑、约束条件设置及目标函数设计,并结合实际算例进行代码调试与结果分析,以深入理解电动汽车参与电网调控的机制与效果。

欢多天天写代码
评论 2
收藏 已收藏
分享
返回顶部
shen23132379
Java EE 67,535 成员 225,843 内容