MultiMedia and the Web

Main Page | Session 10 | Sound | Video | Animation

Sound

External Files

Linking to an external sound file is the same as linking to any other external file. Create a link which points to the file on the server, such as:

<P> Listen to an excerpt from School House Rock's <A HREF="sounds/SHRConjunctionJunction.au">Conjunction Junction</A> (.au format, 66Kb).

Listen to an excerpt from School House Rock's Conjunction Junction (.au format, 66Kb).

The primary sound file formats in use are:
Format Extension Description
AU/µ-law .au fully cross-platform, developed by Sun Microsystems; low quality 8-bit sound
AIFF/AIFC .aiff, .aif sound format used on Macintosh computers
WAVE/WAV .wav waveform sound recording, varying quality levels, primarily supported by Windows
MPEG Audio .mp2 multi-platform, but with limited support
MIDI .mid multi-platform; wide support; electronic music format, not recording
RealAudio .rmi streaming audio designed for the web; requires a special server for streaming and different linking methods

If the person viewing your page links to the sound file and has the appropriate plug-in or helper application set up with their browser for the sound file type, they will be able to hear the sound.

Inline Sounds

Newer browsers support sounds embedded within an HTML document. Microsoft's Internet Explorer supports the HTML tag (an MSIE extension) call BGSOUND, which may be used to play AU, WAV and MIDI sound files. The syntax of this tag is:

<BGSOUND SRC="sounds/SHRConjunctionJunction.au" LOOP=1>

Neither Netscape Navigator nor Communicator support the BGSOUND tag. Instead, use the EMBED tag for Netscape version 2.0 or newer as follows:

<EMBED SRC="sound%20file%20location/index.html" ALIGN=LEFT|RIGHT|TOP|BOTTOM BORDER=nn CONTROLS=TRUE|FALSE FRAMEBORDER=YES|NO HEIGHT=nn HIDDEN=TRUE|FALSE HSPACE=nn NAME=appletName PALETTE=FOREGROUND|BACKGROUND PLUGINSPAGE=url TYPE=MIMEtype VSPACE=nn WIDTH=nn LOOP=1> </EMBED>

The EMBED tag offers more control over an inline file than BGSOUND tag and is much more versatile. While BGSOUND is strictly for sounds, the EMBED tag may be used to display the output of many different plug-ins within the HTML document, providing the plug-in is installed in the user's browser.

The following table provides a description of the various attributes of the EMBED tag.

Attribute Values Description
SRC url url to the file to embed in the document
ALIGN LEFT|RIGHT|TOP|BOTTOM positioning of output, same as for an IMG tag
AUTOSTART TRUE|FALSE indicates whether the plug-in should start playback automatically or wait for the user to start it
BORDER number number of pixels wide to make the border around the output
CONTROLS TRUE|FALSE toggle the display of plug-in controls on or off
FRAMEBORDER YES|NO toggle display of border around the embed frame
HEIGHT number number of pixels in height of the display frame; same effect as HEIGHT in IMG tag
HIDDEN TRUE|FALSE toggles display of frame on or off
HSPACE number number of pixels to the left and right of the frame; same as IMG tag
NAME NAME=appletName name of embed object for reference, ie. from JavaScript
PALETTE FOREGROUND|BACKGROUND specifies which color palette to use, applicable only in Windows
PLUGINSPAGE url url to the instruction page for installing the required plug-in
TYPE MIMEtype used instead of SRC for some types of plug-ins to identify the type of embed document
VSPACE number number of pixels to the top and bottom of the frame; same as IMG tag
WIDTH number number of pixels in width of the display frame; same effect as WIDTH in IMG tag
LOOP number number indicating how many times to repeat playing the embed. -1 means infinite loop
MASTERSOUND none no value; indicates this embed is the main sound source on the page
VOLUME 0 to 100 sets the playback volume of sound files between 0 and 100% of full volume

Not all of the atttributes apply to every plug-in, and some plug-ins provide other attributes not listed in the table. To get the maximum usage out of the EMBED tag, find out the specific requirements and parameters associated with the various plug-ins you may be utilizing. AU format sound file excerpt of School House Rock's Conjunction Junction

The space between the beginning and ending EMBED tags is used for browsers that do not support EMBED. These browsers will simply ignore the EMBED tag as unknown and display the contents instead. A browser that does support the EMBED will ignore the contents.

This is especially important if using the BGSOUND tag, since Internet Explorer version 3.01 and newer also supports the EMBED tag (though not all of the attributes that are supported by Netscape are supported by IE), and will try to play both the EMBED and the BGSOUND tags. By nesting the BGSOUND tag inside the EMBED tag, newer version of IE will play the EMBED sound, as will Navigator, and older versions of IE that do not support EMBED, but do support BGSOUND, will play the BGSOUND tag.

The above sound sound tag looks like this:

<EMBED SRC="sounds/SHRConjunctionJunction.au" ALIGN=RIGHT CONTROLS=TRUE HEIGHT=60 HIDDEN=FALSE HSPACE=125 AUTOSTART=TRUE NAME=testSound PALETTE=FOREGROUND VSPACE=20 WIDTH=145 VOLUME=50 MASTERSOUND LOOP=2> AU format sound file excerpt of School House Rock's Conjunction Junction <BGSOUND SRC="sounds/SHRConjunctionJunction.au" LOOP=1> </EMBED>

You should always set the volume low (30 to 50%) and let the user turn the volume up if necessary, rather than "blow" them out of their chair when your page loads. When your sound file plays and the volume is changed by the plug-in, that changes the actual system volume on the user's computer, not just the volume for your sound file!

In addition, it is good practice to not set the loop value too high (1 to 5 times, depending upon the sound). Some people become easily distracted (or annoyed) with a constantly repeating sound and will not likely stay long, or return. This is even more important if you HIDE the controls (HIDDEN=TRUE) preventing them from turning your sound off.


Video

External Files

Linking to an external video file is the same as linking to any other external file. Create a link which points to the file on the server, such as:

<P> Watch the USS Enterprise <A HREF="video/st11.html">jump into Hyperspace</A> (.avi format, 337Kb).

Watch the USS Enterprise jump into Hyperspace (.avi format, 337Kb).

The primary video file formats in use are:
Format Extension Description
MPEG .mpeg, .mpg current standard on the web, though generally no sound as there are few mpeg players that handle sound
QuickTime .mov Apple's QuickTime format, gaining more widspread use; full support for sound as well
AVI .avi Windows video file format; full support for sound as well

If the person viewing your page links to the video file and has the appropriate plug-in or helper application set up with their browser for the video file type, they will be able to see (and possibly hear) the video.

Inline Video

Internet Explorer supports the followin 4 attributes of the image tag:

  1. DYNSRC
  2. CONTROLS
  3. LOOP
  4. START

These attributes enable the IMG tag to support inline AVI files embedded in HTML documents.

The DYNSRC attribute tells the browser where to find the AVI file. CONTROLS included in the IMG tag causes a simple set of controls to be displayed for stopping and starting the AVI. LOOP causes the AVI to repeat. -1 or INFINITE as a value of LOOP causes infinite repetition. START can have the values of FILEOPEN (default) or MOUSEOVER. FILEOPEN causes the AVI to start playing immediately upon the page loading, MOUSEOVER cause the AVI to start playing only when the mouse is passed over it.

Here is a sample of using the DYNSRC attributes with an IMG tag:

<IMG DYNSRC="video/st11.html" SRC="images/voyshp01.jpg" ALT="Start Trek" START=MOUSEOVER CONTROLS LOOP=2>

Start Trek

Notice that in Netscape, the jpeg image specified for the SRC attribute is displayed rather than the DYNSRC. To display video in Netscape, use the EMBED tag, similar to using sound files, as follows:

The EMBED tag poses a special problem between Internet Explorer and Netscape HTML documents. Both browsers support this tag for AVI files, but the viewers used in the page is dramatically different for display size. If you specify a height and width, the video will be distorted in Internet Explorer ir sized for Netscape, or there will be wasted space on the page if sized for Internet Explorer.

There is no real easy work around for this, other creating different pages. Not specifying the HEIGHT and WIDTH of the video frame causes the display to default to a square approximately 50 by 50 pixels in size, no matter the size of the AVI file.

Here is the EMBED tag used for this example:

<EMBED SRC="video/st11.html" ALIGN=RIGHT CONTROLS=TRUE HEIGHT=60 HSPACE=125 AUTOSTART=TRUE NAME=testVideo VSPACE=20 WIDTH=160 LOOP=2> </EMBED>


Animation

Inline (Embedded) Animation

Animation would not be overly useful if not embedded in the web page itself. So, there is no discussion here relating to external animation, other than you can crete links to files, such as animated GIFs, the same as any other external file.

Marquees

One of the simplest methods of creating your own animation is using the MARQUEE element. This is an Internet Explorer extension, which is not supported by other browsers.

The syntax of the MARQUEE tag is:

<MARQUEE BEHAVIOR=SCROLL|SLIDE|ALTERNATE DIRECTION=LEFT|RIGHT LOOP=INFINITE|-1|1 OR MORE SCROLLAMOUNT=NUMBER OF PIXELS SCROLLDELAY=NUMBER OF MILLISECONDS BGCOLOR=COLOR NUMBER OR NAME HEIGHT=NUMBER OF PIXELS WIDTH=NUMBER OF PIXELS HSPACE=NUMBER OF PIXELS VSPACE=NUMBER OF PIXELS ALIGN=TOP|MIDDLE|BOTTOM>Text to be displayed! </MARQUEE>

Here is a sample marquee. The text will move if viewed in Internet Explorer, or be displayed as regular text in any other browser. Text to be displayed!

Here is the HTML which created this marquee:

<FONT COLOR="#AA0000" SIZE="+2"> <MARQUEE BEHAVIOR=SCROLL DIRECTION=RIGHT LOOP=-1 SCROLLAMOUNT=25 SCROLLDELAY=200 BGCOLOR="#FFFF00" HEIGHT=30 WIDTH=200 HSPACE=12 VSPACE=6 ALIGN=MIDDLE>Text to be displayed! </MARQUEE></FONT>

Animated GIFs

Another popular method for including animations is using a special feature of GIF graphics which allows a GIF file to store multiple images and control the speed at which they are displayed. In order to create an animated GIF, you must create each "frame" or image required to form the animation as separate GIF files, then combine into an animated GIF using a program such as Alchemy Mindwork's GIF Construction Set.

This shareware program may be found at http://www.mindworkshop.com/alchemy/gifcon.html.

Detail instructions on creating animated GIFs are beyond the scope of this course. To use animated GIFs, simply use the IMG tag and reference the animated GIF as the SRC rather than a single image GIF file. If the browser supports animated GIFs, then the animation will run, otherwise, only the first image in the set will be displayed as a static image.

Remember that animated GIFs are considerably larger than a static image because each file stores ALL of the images involved in the animation, which must be downloaded whether the browser supports animated GIFs or not.

Animations Using Java

Sun Microsystems provides a set of java classes which may be downloaded and used to create animations combining sound and images. To use these classes you require the APPLET tag combined with PARAM tags. The APPLET tag's primary attributes are: CODE, WIDTH and HEIGHT. The PARAM tag requires the two attributes: NAME and VALUE. Anything placed between the opening and closing APPLET tags will be displayed by browsers that do not support Java and be ignored by browsers that so support Java.

Here is the code for the above Java animation:

<applet code=Animator.class width=460 height=160> <param name=imagesource value="images/Beans"> <param name=backgroundcolor value="0xFFFFEE"> <param name=endimage value=10> <param name=soundsource value="audio"> <param name=soundtrack value=spacemusic.au> <param name=sounds value="1.au_2.au_3.au_4.au_5.au_6.au_7.au_8.au_9.au_0.html"> <param name=pause value=200> </applet>

Visit Sun at http://www.javasoft.com/applets/applets/Animator/index.html to learn more about these classes (and others).


Main Page | Session 10 | Sound | Video | Animation