I followed the Media Show Casehttp://www.primefaces.org:8080/prime-sh ... /media.jsf, but I use my own video.
I get an error: 404 Resource is not available as seen below:
The following is my bean code.
Code: Select all
@ManagedBean
public class MediaController {
private InputStream inputStream;
public MediaController() throws FileNotFoundException {
// InputStream stream = this.getClass().getResourceAsStream("video.mp4");
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("video.mp4");
media = new DefaultStreamedContent(inputStream);
}
public StreamedContent getMedia() {
return media;
}
public void setMedia(StreamedContent media) {
this.media = media;
}
}
Code: Select all
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Testing Media</title>
<p:resources />
</head>
<h:body>
<h3>MP4 Movie</h3>
<p:media value="#{mediaController.media}" width="250" height="225" player="quicktime"/>
</h:body>
</html>
When I view source, I see that the src="org.primefaces.model.DefaultStreamedContent@72be6280".<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>
org.primefaces.resource.ResourceServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>com.sun.faces.allowTextChildren</param-name>
<param-value>true</param-value>
</context-param>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
But in the show case, the src is in different format.<embed pluginspage="http://www.apple.com/quicktime/download/" src="org.primefaces.model.DefaultStreamedContent@72be6280" height="225" width="250"></embed>
What is wrong?<embed pluginspage="http://www.apple.com/quicktime/download/" src="/prime-showcase/ui/media.jsf?primefacesDynamicContent=mediaController.media" height="225" width="250"></embed>
-------
Server:Glassfish V3
JSF 2
PrimeFaces 2RC
OS:MacOS X and Windows 7