|This page provides information about including active content in your pages.
Elements and attributes are discussed below. For specific examples of code
see the Multimedia page. The Multimedia
page also provides links and a glossary. This page expands on the material
presented in the Multimedia page, addressing several media categories not
covered in the previous class.
Browsers are capable of displaying text, html, gif and jpeg files in the browser window. For other types of files browsers rely on plug-ins and helper applications. Some plug-ins are included with newer generation browsers. All necessary plug-ins are available by downloading online, although not all computers are capable of playing sound or video files. For more details about plug-ins and computer requirements see the Plug-ins page.
When a Web author expects a browser to utilize an unsupported file type it is important to use the correct extension for the file, so the browser handles it correctly. If no plug-in is available the browser may call on a helper application to display the file. The browser user controls which plug-ins and applications are called upon to open programs. Although almost any application can be specified as a helper, it is best to specify small, fast programs. When no application is available the browser offers the opportunity to download and save the file.
Adding Sound. There are two ways to add sounds to Web pages -- as a streaming file that plays while downloading, or as a file that plays after downloading. The WAV file format is readable by both Macintosh and Windows operating systems, and therefore recommended for non-streaming sound. The other popular formats, RA and RM (RealAudio and RealMedia), are used for streaming content. RealMedia is the most common steaming format. Steaming audio/video files are more complicated, and may also require a special server. Authors need to confirm the capabilities of their intended server if considering streaming content, especially if using more than a few small files.
Embedding Sound. The following sound file parameters are used within the <EMBED> tag.
This example places a console in the page to play a wav file. It also provides a pluginspage attribute, a link to the URL where the client can obtain the QuickTime plug-in, a unlikely need with a .wav file format.
<BGSOUND SRC="music.wav" loop=infinite>
RealMedia Sound Files. Adding RealMedia sound to a page requires three components,
the html code indicating a metafile, the text file known as the metafile, and
the sound file. A link for a RealMedia file points to the metafile instead of
the media file. A metafile can be created with a text editor. In the metafile
type insert the complete path to one or more RealMedia files you want to play.
Save the file as a text only file (ASCII) with the file extension .ram if linking
to the sound file, or as .rpm if embedding the sound file. Linking is a better
supported method. Linking is accomplished by specifying the metafile.ram, as
in <A HREF="mysound.ram">Play Sound.</A>.
Video Files. To add external video use a standard text or image link, as in <A HREF="video.avi"> 4 MB video </A>. Because videos can be large files a common courtesy is to specify the file size, thereby providing users with some idea of download time. To add internal video use <EMBED SRC="video.avi"> with height and width attributes of the video size in pixels, as well as the AUTOSTART, LOOP and ALIGN attributes in the tag. Internet Explorer does not support standard internal video tags.
Flash Movies. The example below illustrates the code of an HTML page displaying a Flash movie. A Flash movie can be displayed in a web browser if an HTML document uses the <EMBED> and <OBJECT> tags and the appropriate parameters. The <OBJECT> and <EMBED> tags are ordered with the <EMBED> and </EMBED> tags placed just before the </OBJECT> tag.
All the settings in the <EMBED> tag are attributes inside the tag.
In the <OBJECT> tag there are four attributes, height, width, classid and codebase that are included in the tag..
All the other <OBJECT> attributes are parameters and are listed in separate <PARAM....> tags between the <OBJECT> and </OBJECT> tags.
This example HTML file illustrates embedding a Flash file.
<HTML><HEAD></HEAD><BODY> <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
APPLETS are programs written in the Java programming language. Java is an object-oriented programming language developed by Sun Microsystems. Java is intended to be a cross-platform language. Java applets can run inline inside second generation and later Web browser. Applets can be included in an HTML page and displayed if you use a Java technology-enabled browser. The applet's code is transferred to your system and executed by the browser's Java Virtual Machine. For a complete description of the use of APPLET code see SUN Microsystem's The Applet Tag page. The links below provide access to Java Applets. Here is an example of a simple APPLET tag:
<applet code="SomeApplet.class" width=40 height=40></<applet>.
The following applet creates a clock. The parameters allow for the modification of colors. The applet "JavaClock.class" is located in the "active/clock/classes/" folder. If the .class file is not in the same folder as the web page the codebase="" attribute is necessary.