Playing audio on Web pages

Sound files, which come in a variety of formats, are handled differently and inconsistently by different browsers and on different computers. For some measure of predictability and control, users can bring audio into Dreamweaver by first inserting it into a SWF file (created by Macromedia Flash). The SWF file will be played with the Flash plug-in, which comes with most browsers. Flash is a streaming technology, so audio files can start playing even before the entire file has been completely downloaded.

JavaScript control of audio embedded in an SWF file

A SWF file can be controlled with JavaScript behaviors. For instance, the clicking of a button can trigger the playing of a SWF file which houses an audio file. Unfortunately, a few browsers do not allow JavaScript to control embedded elements such as Flash movies. (See Not all browsers support JavaScript control of embedded content [TechNote 15431] for more information.)

Below is a chart showing which browsers support JavaScript control of embedded elements:

Supported browsers

Windows

Macintosh

Internet Explorer 4.x

Internet Explorer 5.x

Netscape 4.x

Netscape 6

Bringing an MP3 audio file into Dreamweaver using a Flash SWF file

The tutorials in this series use both Flash 5 and Dreamweaver 4 to add audio to a Web page. They each use one kind of audio, MP3 (Motion Picture Experts Group Audio), which is embedded in a SWF file in Flash and then played or controlled in Dreamweaver. Other audio formats (such as WAV for Windows or AIFF for Macintosh) can also be added to the SWF file. The tutorials include:

Using Flash to add background music to a Web page (TechNote 15345)

After embedding an MP3 audio file into a Flash SWF file, you can then add the SWF file to a Dreamweaver document for background sound.
Using Flash to play audio when a button is clicked (TechNote 15326)

Trigger the playing of the SWF file by attaching a JavaScript control behavior to a button or linked text.

Using Flash to play audio in a specific frame on the timeline (TechNote 15347)

Delay the start of the SWF file by placing a behavior on the Dreamweaver timeline.

Additional information

For more information about working with audio in Flash, see the following Flash TechNotes and articles:

  How to create a simple sound toggle (TechNote 14821)
  Supported audio import formats (TechNote 14068)
  Streaming and file optimization techniques for Flash Player

For more information about working with audio in Dreamweaver, see the following Dreamweaver TechNotes and articles:





Keywords: tn_15660

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy