Dreamweaver offers behaviors for controlling sounds and multimedia assets (Shockwave and Flash).
16.2.1 Playing Sound
You can use the Play Sound behavior to add sound to your web site. To play a simple beep, you could attach the behavior to a button and trigger it using the onMouseDown event. To play background music, you could attach the behavior to the <body> tag and trigger it using the onLoad event.
Applying the Play Sound behavior opens the Play Sound dialog box (not shown), with which you can specify the sound file to play. Web delivery typically requires compressed formats such as .mid (MIDI), .mp3 (MPEG-3), .mod (Amiga MOD format used by WinAmp), or .ra (RealAudio). Other formats include .wav (WAVE), .au (Sun's sound format), and .aif (AIFF).
Another common format is .swa (Shockwave audio), which is similar to .mp3 and typically played back using either the Flash or Shockwave plugin instead of the Play Sound behavior. In fact, all audio playback requires a browser plugin and can be notoriously inconsistent across platforms and browsers. Generally, Flash is your best bet for simple audio playback, although Shockwave offers more advanced control at the expense of a larger, less-popular plugin. If you use the Play Sound behavior, set the server MIME type for the sound file's type, and test your web page thoroughly in all target browsers on all platforms.
The Play Sound behavior adds code in several places. Like all behaviors, it adds a function call to the object used to trigger the event. For example, the onClick event, which triggers the MM_controlSound function, might be added to a button as follows :
Dreamweaver also adds the MM_controlSound function to the document's head content.
The selected sound file is embedded in your HTML page as follows:
<embed name='CS991467446390' src='/images/paws.wav', loop=false, autostart=false mastersound, hidden=true width=0 true=0> </embed>
Dreamweaver automatically assigns a cryptic name (CS991467446390 in this case) for the name attribute of the <embed> tag. This name is used in the function call to find the embedded sound object. If you change the name, update it in both places.
16.2.2 Control Shockwave or Flash
The Control Shockwave or Flash behavior can play, stop, rewind, or go to a specified frame in a Shockwave or Flash movie. Shockwave or Flash frames are used for animation and are not directly related to HTML frames. To apply the behavior, at least one Shockwave or Flash asset must be present in the document (see Chapter 5). The behavior is typically applied to an image acting as a play or stop button. To use this behavior:
Figure 16-2 shows the Control Shockwave or Flash dialog box.
Figure 16-2. Control Shockwave or Flash behavior parameters
To go to a named frame in a Shockwave movie, append # frameName to the Shockwave URL (i.e., the src attribute of the <embed> tag and the movie attribute in the <object> tag), such as: