Multimedia Controls

Dreamweaver offers behaviors for controlling sounds and multimedia assets (Shockwave and Flash).

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 ...

Get Dreamweaver in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.