9.3. Introduction to Shockwave
Shockwave for Director is a software component that enables compatible browsers such as Netscape Navigator and Microsoft Internet Explorer 2.0 and higher to play multimedia Director movies over the Web. Shockwave is designed to work with standard HTTP servers and is ideal for streaming short- to medium-length audio files and advanced multimedia presentations and games.
Shockwave movies are built within Director using the Score window, where all media elements are placed as cast members on channels or tracks along a timeline, as shown in Figure 9-14. Director is a powerful tool for orchestrating multiple media types such as video, animation, and sound into complex interactive presentations.
Director uses Lingo script to create sophisticated interactive games and presentations. Originally it was designed to provide CD-ROM developers with an advanced cross-platform authoring solution for building multimedia presentations. Shockwave uses Director's Lingo scripting to directly interact with the operating system and multimedia functionality of a PC. Lingo enables the development of complex interactive soundtracks with audio fade-ins and fade-outs and panning effects tied to specific user actions. For example, with Lingo you can specify elegant cross-fades of separate audio clips when a user transitions from one scene or web page to another, instead of abruptly cutting off a sound.
Figure 9-14. The Score window used for orchestrating interactive events in Director
The drawback to broadcasting Shockwave-based presentations is that they tend to be too large and cumbersome for 28.8 Kbps modems. As Internet bandwidth increases with xDSL and cable, Shockwave will play a more prominent role in web multimedia.
9.3.1. Using Shockwave "internal" sounds: embedded cast members versus streamed SWA sounds
You can incorporate two basic forms of audio into Shockwave movies: embedded internal sounds (such as buttons, loops, and short transition sounds) and streamed audio with Director's Shockwave Audio (SWA). SWA is a variant of MPEG 3-based compression that adds support for storing cue point data in the audio file. Director allows you to attach cue points along an audio file that trigger events such as the start of a video clip or animation sequence. You can also use third-party solutions for playing audio through Shockwave, including RealAudio with the RealMedia Xtra, RMF files with the Beatnik Xtra, QuickTime audio, and even audio embedded into Flash movies.
Short button sound effects and loops are incorporated into Shockwave as embedded audio cast members, similar to event-driven sounds in Flash. Embedded audio clips play instantaneously when triggered by a user action. They also allow for greater Lingo scripting control than does streamed sound. Any short sound that is directly linked to the action of a user and requires instant playback should be placed in your Shockwave movie as an embedded audio file. Note, however, that despite Shockwave compression ratios of 44:1, embedded sounds still add tremendous size to your Director files, so use them sparingly.
With Director 6 and later, embedded audio can be delivered as a streaming cast member. This means you can orchestrate the download of different cast members so that content appears quickly while cast members from later scenes download in the background. Plan your streaming Shockwave movie carefully so any cast member that Lingo calls up will have previously downloaded into the cast member library. Director 7 also adds support for imported SWA cast members. In previous versions, SWA compression was applied to all audio cast members when the file was "burned" into a Shockwave (.dcr) file, and only one compression ratio could be applied to all the audio cast members. .dcr is the file type extension for movies exported from Director.
In Director 7, you can create SWA cast members at rates as low as 8 Kbps using audio-editing tools like Sound Forge, SoundEdit 16, or Peak, and then import the compressed cast members into Director. As of Director 7.0.2 and higher, you can import MP3 files in addition to SWA files.
Streaming sounds need at least a three-to-five-second buffer time before playback and are thus mainly used for longer-playing audio files. The preload buffer time required for smooth playback of streaming audio prevents this type of audio from being used for button sounds or loops.
9.3.2. Creating transparent Shockwave loops
One of the quickest ways to incorporate Shockwave audio into your web pages is to use a 1 x 2-pixel Shockwave movie to play audio loops or short greetings. To add a compelling soundtrack, use a transparent Shockwave movie with invisible frames to make one audio loop play across several web pages. By using transparent frames, you can use different ambient loops thematically throughout your web site.
Using different loops for various groups of web pages is a great technique for adding variety to a web site and a way to avoid the risk of annoying people with loops that stop playing when they click from one web page to another.
To get started, open the folder bgkdloop, found in the Shockwave or Director directories. It contains:
Drag the file bgkdloop.htm onto your browser icon, preferably Netscape or Explorer 3.0 or higher. After the page loads, it goes black and your SWA file begins to stream automatically. When you play the file back, you may see a tiny dot in the top-left corner of your browser window; this is the 1 x 2-pixel frame of the Shockwave movie.
The web page with the Shockwave movie should contain the following object tag:
<OBJECT CLASSID="clsid:166B1BCA-3F9C-11CF-8075-444553540000" CODEBASE="http://active.macromedia.com/director/cabs/sw.cab#version=6,0,0,0" WIDTH="1" HEIGHT="2" NAME="Intro"> <PARAM NAME="SRC" VALUE="./allsongs.dcr"> <EMBED WIDTH="1" HEIGHT="2" SRC="allsongs.dcr" sw1="off" swURL="intro.swa" swTEXT="" swPreLoadTime="5" sw2="1" sw3="0"> </OBJECT>
If the sound is playing properly, start adding pictures and text to your web page.
9.3.3. Shockwave streaming audio
There have been several major innovations in the latest versions of Shockwave. Shockwave movies exported from Director 5 and earlier versions had the capacity to stream only audio. Graphics and animations had to download in their entirety before they could play back. Thus, if you were streaming a music video, the graphic content would have to download first before the music video began to play. An average 250 KB Shockwave movie exported from Director 5 or lower produced extremely long wait times, causing many people to leave a page before the movie downloaded.
The release of Director 6 marked a major breakthrough. With Director 6 and later, individual cast members are broken into separate packets of data and streamed in the background while a .swa audio file plays. This means that a Shockwave streaming audio file can begin to play almost immediately with its accompanying visual content. This feature allows you to create longer, more complex movies and interactive entertainment.
Director 6 and 7 also have the capability to read markers on your audio file set in Sound Edit16. With this feature, it is possible to sync your streaming audio with the appearance of a designated graphic or animated cast member.
9.3.4. Exporting Shockwave audio files
Use Macromedia's SoundEdit 16 to create Shockwave audio (SWA) files using the SWA Export Xtra. You can also convert WAV audio files to SWA files in Director for Windows. When you create an audio file with the SWA Export Xtra, the new file is compressed using MPEG Layer 3 compression. To use the SWA Export Xtra, follow these steps:
9.3.5. Optimizing your Shockwave audio files
The following tips help ensure the highest quality Shockwave audio:
9.3.6. Quick and easy audio streaming with Shockwave
You can quickly get up and running with Shockwave by using the royalty-free Raspberry Media Player, shown in Figure 9-18, available at http://www.designingwebaudio.com. The Raspberry Media Player provides volume controls, stop, play, and pause buttons, a song selection menu, a status bar, and a blank area for placing your personal logo or custom graphics. With Director 5 or later, simply replace the Raspberry Media logo with your own logo, or replace all the graphics in the Cast Members window to create a new audio player interface, and export your own custom Shockwave player.
Figure 9-18. The Raspberry Media Shockwave Audio Player
To stream your Shockwave audio, customize the Raspberry Media Player and post it on your server with the following files placed in the same folder:
When a user opens an HTML page with a Shockwave movie in their browser, it tells the browser to go to the URL specified by the EMBED tag in custom.htm and downloads the specified movie (custom.dcr). To use the Raspberry Player to stream your SWA files, you need to modify the following HTML EMBED attributes:
<EMBED WIDTH="368" HEIGHT="171" SRC="http://www.raspberrymedia.com/audio/rasplayr.dcr" swURL="http://www.raspberrymedia.com/audio/audio_samples/" swList="sound_sca.swa,sound_eff.swa,world_bea.swa, blues.swa,trance.swa,acoustic.swa,rock.swa,reggae.swa" swTEXT="Sound Scape,Sound Effects,WorldBeat,Blues,Trance,Accoustic, Rock,Reggae" swPreLoadTime=5 animate = "NO">
To modify the EMBED tags to play your audio files, open a copy of rasplayr.htm in a text editor and change the following EMBED tags:
As the SWA file streams from the server to your computer, it fills the buffer. As the SWA file plays, it empties the buffer. If these two rates are the same, playback will not be interrupted. If the Internet is slow, the buffer may not be filled as quickly as it is emptied. This can result in playback stopping for a moment as the buffer waits to be filled up again.
Copyright © 2002 O'Reilly & Associates. All rights reserved.