Media control and StreamedContent cannot play video/audio

UI Components for JSF
Post Reply
kruyvanna
Posts: 2
Joined: 02 Feb 2010, 13:29

02 Feb 2010, 14:15

Hi,

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:
Image

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;
    }
}
Below is the index.xhtml

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>
Below is the web.xml
<?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>
When I view source, I see that the src="org.primefaces.model.DefaultStreamedContent@72be6280".
<embed pluginspage="http://www.apple.com/quicktime/download/" src="org.primefaces.model.DefaultStreamedContent@72be6280" height="225" width="250"></embed>
But in the show case, the src is in different format.
<embed pluginspage="http://www.apple.com/quicktime/download/" src="/prime-showcase/ui/media.jsf?primefacesDynamicContent=mediaController.media" height="225" width="250"></embed>
What is wrong?

-------
Server:Glassfish V3
JSF 2
PrimeFaces 2RC
OS:MacOS X and Windows 7
Last edited by kruyvanna on 02 Feb 2010, 16:27, edited 1 time in total.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 Feb 2010, 16:19

Streamed content support for media is added after 2.0.RC release, you need a nightly build of 2.0.0-SNAPSHOT. That will fix the problem.

kruyvanna
Posts: 2
Joined: 02 Feb 2010, 13:29

02 Feb 2010, 16:28

Thank you for your quick reply. :D

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 Feb 2010, 16:43

You are welcome, let us know if you still have troubles.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 37 guests