[ Team LiB ] Previous Section Next Section

Recipe 17.6 Embedding a QuickTime Movie in a JSP

Problem

You want to embed a QuickTime movie in your JSP.

Solution

Use the embed tag nested inside the object tag. The object tag has to contain the CLASSID attribute with the proper value.

Discussion

Similar to using the Java Plug-in, a JSP uses the embed tag inside of an HTML object tag to properly load one of Apple Computer's QuickTime movies. You must include the CLASSID attribute value exactly as Example 17-9 specifies. You also must include the same CODEBASE attribute value. If the user has an Internet Explorer Windows browser, but has not yet installed the QuickTime ActiveX control, the CODEBASE attribute value specifies where the user can download it.

Example 17-9. Embedding a QuickTime movie in a JSP
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<jsp:useBean id="date" class="java.util.Date" />

<html>
<head><title>QuickTime in a JSP</title></head>
<body>
<h2>Ladies and Gentlemen, The Who</h2>

<OBJECT CLASSID=
    "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="320"
    HEIGHT="256" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">

<PARAM name="SRC" VALUE="http://www.parkerriver.com/films/who_bene2.mov">

<PARAM name="AUTOPLAY" VALUE="true">

<PARAM name="CONTROLLER" VALUE="true">

<EMBED SRC=
   "http://www.parkerriver.com/films/who_bene2.mov" 
    WIDTH="240" HEIGHT="196" 
    AUTOPLAY="true" CONTROLLER=
    "true" PLUGINSPAGE="http://www.apple.com/quicktime/download/">

</EMBED>

</OBJECT>

<br /><c:out value="${date}"/>

</body>
</html>

If the browser uses Netscape-style plug-ins, then the embed tag will initiate the loading of the QuickTime movie. The JSP in Example 17-6 properly loaded the movie into the Safari web browser on my Macintosh laptop, for instance. One of the advantages of the embed tag is that you can use a number of proprietary attributes that the embedded object, such as QuickTime, understands. Example 17-9 specifies that the movie should start playing as soon as the browser has loaded enough data (AUTOPLAY="true") as well as that the browser should show the movie controls, which lets the user stop or start the movie (CONTROLLER="true").

Figure 17-4 shows the QuickTime movie embedded in the JSP of Example 17-9.

Figure 17-4. A QuickTime movie embedded in a JSP
figs/jsjc_1704.gif

See Also

Apple Computer's guide on embedding QuickTime in Web pages: http://www.apple.com/quicktime/authoring/embed.html; Recipe 17.3-Recipe 17.5 on embedding a Flash file; Recipe 17.7 on embedding an SVG file in a JSP; Recipe 17.8 on embedding a background soundtrack.

    [ Team LiB ] Previous Section Next Section