Below code works if I write it in a simple .html file but it doesn't work from .xhtml. I've read about this and I think that code must work properly because HTML5 is indepent but really video isn't showed.
HTML file and XHTML file share the same code with the difference html show video and xhtml not
Project use Spring 4, Spring WeFlow 2.4, JSF 2.2 and Primefaces 5
From console I get this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080/home/rafa/aio_data/28/videos/V1/video_cE9GTCb7Sh.mp4
Obviously, file is on my laptop but it's a external resource outside project folders. So, I need something like file:///home/rafa/Desktop/video.html what is displayed on simple HTML5
Anyone know display it?
<video width="320" height="240" controls>
<source src="/home/rafa/aio_data/28/videos/V1/video_cE9GTCb7Sh.mp4" type="video/mp4">
</video>
HTML created by server
<div id="videoContainer" class="videoContainer">
<ui:repeat>
<video width="320" height="240">
<source src="/home/rafa/aio_data/28/videos/V1/video_cE9GTCb7Sh.mp4" type="video/mp4">
</video>
</ui:repeat>
</div>
Edit: I've tried to show it using Webservlet because I could display picture using p:graphicImage, but this way was failed. A black box is showed even though webservlet catch properly the file.
Webservlet
@WebServlet("/video/*")
public class VideoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletContext sc=getServletContext();
String multimediaPath=sc.getInitParameter("multimediaPath");
String filename=request.getPathInfo().substring(1);
File file=new File(multimediaPath, filename);
if(file.exists() && file.isFile()){
response.setHeader("Content-Type", getServletContext().getMimeType(filename));
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
//Preventing browser image cache
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
Files.copy(file.toPath(),response.getOutputStream() );
}else{
//ARREGLAR
}
//}
}
}
New HTML video tag
<video width="320" height="240">
<source src="#{request.requestURL.substring(0, request.requestURL.length() - request.requestURI.length())}#{request.contextPath}/video/#{selectedSpace.idSpace}/videos/V1/video_cE9GTCb7Sh.mp4" type="video/mp4" />
</video>