Java Primefaces 6.2光电摄像头-Firefox/Safari网络摄像头错误
我正在尝试使用Primeface的PhotoCam(版本6.2),以他们的showcase为例,该摄像头在Firefox(开发者版63.0b13)或Safari版本12上不适合我。。而且也不能在移动设备上使用Safari(移动设备在iOS12上) 它被部署到一个使用https的站点上,并在Chrome中工作,在桌面和移动浏览器上都可以 我现在正在使用showcase演示,可以在这里找到(代码也发布在下面): 我甚至下载了showcase war文件并尝试了该版本,但没有成功的改变 有人能帮忙吗 发生了什么事 在Firefox上:Java Primefaces 6.2光电摄像头-Firefox/Safari网络摄像头错误,java,jsf,primefaces,Java,Jsf,Primefaces,我正在尝试使用Primeface的PhotoCam(版本6.2),以他们的showcase为例,该摄像头在Firefox(开发者版63.0b13)或Safari版本12上不适合我。。而且也不能在移动设备上使用Safari(移动设备在iOS12上) 它被部署到一个使用https的站点上,并在Chrome中工作,在桌面和移动浏览器上都可以 我现在正在使用showcase演示,可以在这里找到(代码也发布在下面): 我甚至下载了showcase war文件并尝试了该版本,但没有成功的改变 有人能帮忙吗
- 我得到允许摄像头访问的提示,单击“确定”李>
- 我得到运行Adobe Flash的提示,我同意李>
- 接受两者后,相机的“盒子”只是白色的李>
- 单击“捕获”时,收到的错误是“Webcam.js错误:Webcam尚未加载”李>
- 注意:控制台在页面加载时返回“return语句[Learn More]后无法访问的代码”,但没有其他消息 在接受两个提示后显示
- 我得到允许摄像头访问的提示,单击“确定”李>
- 我收到错误“Webcam.js错误:无法访问Webcam:TypeError:Type错误TypeError:Type错误”
- 我收到错误“Webcam.js错误:无法访问Webcam:error: 无效约束错误:无效约束“
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui" template="/common/template.xhtml">
<ui:define name="title">PhotoCam</ui:define>
<ui:define name="content">
<h:form>
<h:panelGrid columns="3" cellpadding="5">
<p:photoCam widgetVar="pc" listener="#{photoCamView.oncapture}" update="photo"/>
<p:commandButton type="button" value="Capture" onclick="PF('pc').capture()"/>
<p:outputPanel id="photo">
<p:graphicImage name="demo/images/photocam/#{photoCamView.filename}.jpeg"
rendered="#{not empty photoCamView.filename}"/>
</p:outputPanel>
</h:panelGrid>
</h:form>
</ui:define>
我非常感谢你在这方面的帮助
(我也在Primefaces论坛上发布了这篇文章,希望这里或那里的人能帮助我。当我弄明白这一点时,我会更新这两个网站)
克里斯蒂娜我最近刚刚将Photocam更新为其JS插件的最新版本,并修复了IE11的类似错误。请看这里:
我强烈建议您从GitHub试用PrimeFaces的6.3-SNAPSHOT版本,并让我们知道此最新版本是否解决了您的问题。只需从下载webcam.js并将其放在您的xhtml文件夹中即可。 然后将
添加到xhtml文件中
public class PhotoCamView {
private String filename;
private String getRandomImageName() {
int i = (int) (Math.random() * 10000000);
return String.valueOf(i);
}
public String getFilename() {
return filename;
}
public void oncapture(CaptureEvent captureEvent) {
filename = getRandomImageName();
byte[] data = captureEvent.getData();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
String newFileName = externalContext.getRealPath("") + File.separator + "resources" + File.separator + "demo" +
File.separator + "images" + File.separator + "photocam" + File.separator + filename + ".jpeg";
FileImageOutputStream imageOutput;
try {
imageOutput = new FileImageOutputStream(new File(newFileName));
imageOutput.write(data, 0, data.length);
imageOutput.close();
}
catch(IOException e) {
throw new FacesException("Error in writing captured image.", e);
}
}}