Click to See Complete Forum and Search --> : Sound On Button Click


learninghtml
07-05-2003, 10:53 AM
Hi,
I orignally posted this on the HTML forum but thought the JS forum would be more appropriate for this problem...

I have a page where I want users to be able to click a button and hear a particular sound. But I am having problems...

Here's the code...

In the head...
<script type="text/javascript">
<!--
function playsound(sdnumber) {
document.embeds[sdnumber].play();
}
// -->
</script>

In the body...
<embed src="Sounds/doorslam.mp3" hidden=true autostart=false>

and for the button link...

<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('DoorSlam','','Buttons/snd_doorslam_down.gif',1)"

onClick="playsound('0');return false; ">

<img src="Buttons/snd_doorslam_up.gif" alt="A door slamming in a cavernous space. " name="DoorSlam" width="150" height="30" border="0" align="absmiddle"></a>

I've cut out irrelevant code and there is more than one sound (and button). In preview on Dreamweaver it works fine but when uploaded (same browser - IE6) it does two things firstly it invokes my Download Accelerator (DAP) and then displays the following script error....

"Could not complete the operation due to error ffffffce"

The DAP problem I solved by removing the appropriate file association. This will only work on my machine of course. Is there a way of preventing any DA program of 'seeing' the file as a download trigger?

It works fine locally on Internet Exploder 6 when previewing and not at all in Netscrape.

The errors only appear in IE6 when viewed on-line after upload.

Server-side problem?

Website: www.codsalldramaticsociety.co.uk

Page is a test hence it's 'hidden' - Click on the logo top-left corner to access the page.

Please help!

MadCommando
07-05-2003, 11:11 AM
I dont know much about the first part of your question. All I know is I have DAP too and no matter what site, if there's background music it'll try and D/L it and since I don't care for background music I usually cancel the dl. That's somethin you can't help.:D

Greelmo
07-05-2003, 11:27 AM
try this in the html:
<bgsound src="" id="mySound">

and the javascript:

function playsound(buttonsound)
{
document.getElementById('mySound').src=buttonsound;
}

learninghtml
07-05-2003, 12:31 PM
Hi,
thanks mate it works!

There is a delay for downloading the mp3's. Is there anyone to "pre-download" these to get rid of the delay?

Thanks again

Greelmo
07-05-2003, 01:02 PM
yes...
<script type="text/javascript">
var sounda=new Image();
sounda.src="blahblah.mp3";
then you just say
bgsound.src=sounda.src

hope i've helped

learninghtml
07-07-2003, 07:33 PM
Hi,
thanks, but I don't under stand how I can use this if there is more than one sound to download.

I was thinking about using streaming audio. I tried "Helix Producer Basic" which does produce the .rm file but not the .ram file which I believe is need to create the link. I am totally confused!

Thanks

Greelmo
07-07-2003, 11:43 PM
to be honest i've never experimented with streaming audio so i wont be that much help in that department. Sorry.

learninghtml
07-08-2003, 02:09 AM
Hi,
the sounds play as wanted thanks to all of you for your help. But I have just discovered that they don't work in Netscrape.

Here's the code...

In the HEAD...
function playsound(buttonsound)
{
document.getElementById('mySound').src=buttonsound;
}

In the BODY...
<bgsound src="" id="mySound">

Link to the button...
<div align="center"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('DoorSlam','','../Buttons/snd_doorslam_down.gif',1)" onClick="javascript: playsound('../sounds/doorslam.mp3'); return false;">
<img src="../Buttons/snd_doorslam_up.gif" alt="A door slamming in a cavernous space. " name="DoorSlam" width="150" height="30" border="0" align="absmiddle" id="DoorSlam"></a></div>

Code simplified as there are three other buttons and three other associated sounds.

Works in Internet Exploder 6...

Any ideas?...

Thanks (in advance) for your help...

_LOBO_
07-08-2003, 04:28 AM
I want to say just one thing:

Preload music+music in a buttom+mp3 = FLASH

_LOBO_

learninghtml
07-08-2003, 03:58 PM
Hi,
Yes, I am aware of Flash and what it can do. I tried a demo version and found it very confusing. I need to get this working asap. When I have done that I will investigate Flash when I have more time.

Thank you