Audio on a webpage

There are many ways to add audio to your webpage. We'll cover a few simple methods here.

Linking to an audio file

The simplest way is probably to link to an audio file. When a user clicks on the link, the file is downloaded and (usually) played by a plug-in in the user's browser. For example:
Html example to link to an audio file

Embedding audio with the Embed tag

The "embed" tag can be used to add audio with some minimal controls to your webpage. The "src" field indicates the location of the audio file to be played. The "loop" field indicates whether to loop the audio file. The "hidden" field indicates whether transport controls should be hidden.
For example, here's a webpage that loads and plays an annoying looping background sound:
Example with looping background sound

So that can be pretty annoying. It's best to use hidden looping sounds sparingly. The default for the "loop" field is false. If the "autostart" field is true, then the audio plays once and does not loop. The default for the "hidden" field is true; transport controls will be displayed on the webpage, and the user can control the audio. For example:
Example with autostart and transport control

Using the QuickTime Player/Plug-in

QuickTime is a powerful media player available for Macs and PCs. Your browser's default audio player will handle many common audio file formats. However, there are advantages to specifying in your webpage a cross-platform plug-in player like QuickTime. QuickTime plays most of the common audio formats, and a variety of video formats (which will not convern us). It can also handle MIDI files (but you have to import them into QuickTime format first). It can be configured to use the Roland GS instrument set, which is a nice General MIDI software synthesizer that comes with QuickTime. QuickTime's Fast Start feature enables a file to start playing while it is downloading, which is handy for playing, for example, MP3 files over a dialup connection. The way the webpage is displayed also becomes pretty consistent across platforms.

If you do not have QuickTime already, download the free version from:
QuickTime download
and install it. The QuickTime Pro 4 Player, which has more capabilities than the free version, is available in the lab (contact instructor if you can't find it). In addition to playing most of the common formats, yit also allows a user to save as some common formats at variable bit rates; I find it to be a useful audio converter even when I'm not working with QuickTime.

The "embed" tag is also used to embed audio or other media for the QuickTime player. However, a browser's default plugin for handling audio may not be QuickTime. Fortunately, a browser can be "tricked" into invoking the QuickTime plugin by specifying a dummy .qti file for the "src" parameter, and using the "qtsrc" parameter to indicate the real audio file that should be played. (You can copy ~whsu/public_html/csc635/WEBTUT/UNeedQT4.qti to use as a dummy .qti file.)

For example, here's a page that will always use QuickTime to play an MP3 file. Note that the file does not have to be downloaded entirely before it starts playing.
QuickTime example