Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Including Sound in a Web Page

January 4, 1999

Inserting an audio or MIDI file into a Web page is a piece of cake. Just link to it. For example:

<A HREF= "bark.wav">

Usually, when you click on such a link, the browser's internal little audio appsky will pop up and play the sound. Explorer supports .wav, .au, .aiff and .mid files, while Netscape supports .wav and .mid. Try it by clicking on these links:

Dog Bark in .wav Format

Dog Bark in .au Format

Much more control over playback is offered by the EMBED tag. EMBED takes various attributes that allow you to control the appearance of the onscreen player, or hide it altogether. You can also set the sound to play automatically when the page is loaded. For example:

<EMBED SRC="BARK.WAV" HEIGHT="40" WIDTH="200">

will cause a 40x200 player to appear at the desired point in the page, which will play a wave file called "bark."

<EMBED SRC="BARK.WAV" HIDDEN="TRUE" AUTOSTART="TRUE">

will cause the file to play when the page loads, and no onscreen console will appear. Another way to do the same thing, but which only works in Explorer, is to use a BGSOUND tag right after the BODY tag, for example:

<bgsound src="bark.wav" loop=5>


Dog Bark in Wave Format


Dog Bark in .au Format

The EMBED tag can take various other attributes, including SMALLCONSOLE (displays a smaller console), LOOP (allows you to specify a number of repeats for the sound), STARTTIME and ENDTIME (the last two allow you to start or end playback at a specified time within the audio file). It's a bit of a crapshoot whether any of these attributes will be supported by any particular browser version, so use them with care, if at all.

Audio can be handled by most of the popular Web scripting languages, including Java, Visual Basic, Javascript and others. It's easy to make a link play a sound in response to mouse movements. First, embed your sound file in the page using a tag like this:

<EMBED SRC="bark.wav" HIDDEN=TRUE AUTOSTART="false" MASTERSOUND NAME="soundfile">

The MASTERSOUND attribute is used when you want to be able to control the same sound file from any of several different triggers on the page, in this case three different mouse events. The NAME attribute allows this file to be called by Javascript.

Now that the sound file is there, ready for Javascript to call it by name, simply include a "javascript:document" statement in your anchor tag, as follows:

<A HREF="#"
 onClick="javascript:document.soundfile.play()"
 onMouseOver="javascript:document.soundfile.play()"
 onMouseOut="javascript:document.soundfile.play()">
Text or Image
</A>

Of course, you could also set the onClick, onMouseOver and onMouseOut events to different sounds. Just give each a different NAME with an EMBED tag. Test 'er out by mousing the animal below. This only works in recent versions of Netscape, and Explorer 5.

The Wussell Cat in her Flowerbox

Now that we've established that we can include sound in a Web page, let's ask whether we should. Some sites will find links to sound clips here and there to be valuable and entertaining, and some mouseover sounds certainly make a page feel more interactive. Unfortunately, much of the cool scripting and such only works in the very latest browsers.

Does your Web site need a "background track?" Probably not. Music is dynamic and sequential, and it complements other dynamic, sequential media. If a Web site were like a film or TV spot, then it would cry out for a soundtrack. But most Web sites (at the moment) are a lot more like magazine articles than anything else, and a magazine doesn't need a soundtrack. Unless sound is an integral part of the information you're trying to publish on your site, many designers will find that there's no logical way to tie music into the Web page content. A soundtrack is often more of an irrelevant distraction than a complement to a site.

Streaming Audio
Audio for the Worldwide Web
The Next Wave


Up to => Home / Multimedia / Sound / Audio




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers