What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Using Sounds in your Web Pages...


theKeeper

Guru
Messages
2,308
Likes
63
As an alternative to using Flash, there are good and efficient ways to use sounds in your Web pages...

...whether it's for bg sounds/music, or for sounds heard when a button is clicked on. The following mini-tute runs through how to setup this function in your pages.

Here's the script/code you need for your project, and below that is a link to a DogPile search page where you can learn more about this stuff (take note of what keywords i used in the search box).

(replace the following sound file names)

In the HEADER of your document, put this code:

Code:
<bgsound src="oompaloompa.mp3">
This will loud a desired mp3 file in the bg of the document when the page is called. This can be used either alone, or in conjunction with the following button sound effect.

In your document, put this code into the HEADER section:

Code:
<script language="JavaScript" type="text/javascript">
<!-- 
function playSound(soundobj) {
var thissound= eval("document."+soundobj);
thissound.Play();
}
-->
</script>
 
<embed src="click.wav" autostart="false" hidden="true" name="mySound">
And here's what the html link code would be on your page: (replace the link url & link text)

Code:
<a href="oompaloompa.html" onMouseOver="playSound('mySound')">Play My Sound!</a>
If you want the sound to be activated by a mouse click, then replace the onMouseOver above with onClick.

The coolest thing about this method is that by having the sound called through a mouseOver, instead of a click, you make sure the sound gets played before the clicked link can leave the current page.

Just make sure you do 2 extra things for this:
  • 1) Make your button sound effect very small in file size -- i.e. no more than 6kb if possible. Use 11khz and 16bit mono for your wav settings.

    2) Use a preLoad script to load the sound file when the page loads, so that it'll be ready to go as soon as a button gets clicked.[/list:u] Let me know if you have any trouble with this. Just read carefully though and it should be fairly easy to pull off.

    Have fun!

    Checkout this page for more learnin'.
    http://www.dogpile.com/info.dogpl/search/web/onclick+play+sound
 

Back
Top