Jsf 无法在primefaces 6.0版中使用primefaces媒体播放视频 public StreamedContent getVideoFile(){ HttpSessionUtil sessionUtil=新的HttpSessionUtil(); 字节[]videoFile=sessionUtil.getFromSessionMap(“视频”); FacesContext context=FacesContext.getCurrentInstance(); if(context.getCurrentPhaseId()==PhaseId.RENDER_响应){ 视频文件=转换默认视频字节(视频文件); 返回新的DefaultStreamedContent(新 ByteArrayInputStream(视频文件),“视频/mp4”); } 如果(videoFile!=null&&videoFile.length>0){ videoFile=新的默认流媒体内容(新) ByteArrayInputStream(视频文件),“视频/mp4”); }否则{ 视频文件=转换默认视频字节(视频文件); videoFile=新的默认流媒体内容(新) ByteArrayInputStream(视频文件),“视频/mp4”); } 返回视频文件; }
xhtml代码:Jsf 无法在primefaces 6.0版中使用primefaces媒体播放视频 public StreamedContent getVideoFile(){ HttpSessionUtil sessionUtil=新的HttpSessionUtil(); 字节[]videoFile=sessionUtil.getFromSessionMap(“视频”); FacesContext context=FacesContext.getCurrentInstance(); if(context.getCurrentPhaseId()==PhaseId.RENDER_响应){ 视频文件=转换默认视频字节(视频文件); 返回新的DefaultStreamedContent(新 ByteArrayInputStream(视频文件),“视频/mp4”); } 如果(videoFile!=null&&videoFile.length>0){ videoFile=新的默认流媒体内容(新) ByteArrayInputStream(视频文件),“视频/mp4”); }否则{ 视频文件=转换默认视频字节(视频文件); videoFile=新的默认流媒体内容(新) ByteArrayInputStream(视频文件),“视频/mp4”); } 返回视频文件; },jsf,primefaces,Jsf,Primefaces,xhtml代码: public StreamedContent getVideoFile() { HttpSessionUtil<byte[]> sessionUtil = new HttpSessionUtil<byte[]>(); byte[] videoFile = sessionUtil.getFromSessionMap("video"); FacesContext context = FacesContext.getCurrentI
public StreamedContent getVideoFile() {
HttpSessionUtil<byte[]> sessionUtil = new HttpSessionUtil<byte[]>();
byte[] videoFile = sessionUtil.getFromSessionMap("video");
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
videoFile = convertDefaultVideoToBytes(videoFile);
return new DefaultStreamedContent(new
ByteArrayInputStream(videoFile), "video/mp4");
}
if(videoFile != null && videoFile.length > 0){
videoFile = new DefaultStreamedContent(new
ByteArrayInputStream(videoFile), "video/mp4");
}else{
videoFile = convertDefaultVideoToBytes(videoFile);
videoFile = new DefaultStreamedContent(new
ByteArrayInputStream(videoFile), "video/mp4");
}
return videoFile;
}
ManagedBean是javax.faces.bean.SessionScoped
视频的最后一个字节[]长度约为480835
目标是视频应在加载屏幕后开始播放。
无法使用p:media播放视频
- 使用的技术堆栈:JSF/Primefaces 6.0/Wildfly10.1.0 Final。问题:
- p:媒体不会加载/播放视频文件
- 错误:[org.primefaces.application.resource.StreamedContentHandler]: 流式传输动态资源时出错。空的
它在Firefox中工作得非常好。非常感谢与此相关的任何帮助。因此它在PF 5.3中起作用了吗?嗨,Kukeltje,现在尝试使用5.3:)是不可行的。我不知道它在firefox中是如何工作的。在不尝试一个页面的情况下,是否存在任何浏览器兼容性因素?好啊但您在标题中明确提到了6.0,并暗示它以前就可以工作。而且,毫无疑问,没有浏览器兼容性因素。试试IE10?IE在“兼容模式”下运行?需要尝试的许多基本IE功能目前,该产品仅与Chrome、Safari和Firefox兼容。因此,IE也被排除在外。对此,我深表歉意:(嗨,Kukeltje,我也试过IE。但它不能播放。我放了一个视频(480KB)在本地驱动器中并已尝试。它仅在firefox中播放,如上所述。Chrome和IE no.我将内容类型更改为视频/mpeg。在Chrome中,文件将自动下载为dynamiccontent.properties。我是否需要在web.xml中指定mime类型。任何建议/建议都将受到高度赞赏。
<p:media value="#{vesumeBean.videoFile}" width="100%" height="400"
player="quicktime">
<f:param name="autoPlay" value="true" />
</p:media>