.wav file.

L

Luis Flores III

I would like to make a .wav file play in the browser (i really don't
want to have to have a player open or even embbed itself, unless of
course it were to just not be shown, like a hidden field in a form)
when clicking on a link. Is there anyways to do this, I am pretty sure
Javascript would be the way to go to accomplish this, but please
correct me if I am wrong. Thanks

Luis
 
E

Evertjan.

Luis Flores III wrote on 23 nov 2004 in comp.lang.javascript:
I would like to make a .wav file play in the browser (i really don't
want to have to have a player open or even embbed itself, unless of
course it were to just not be shown, like a hidden field in a form)
when clicking on a link. Is there anyways to do this, I am pretty sure
Javascript would be the way to go to accomplish this, but please
correct me if I am wrong. Thanks

Embedding is not "shown", like a hidden formfield.

If you mean by "just not be shown",
"not visible with source hacking",
you are luckily out of luck.
 
V

VK

for IE:
The clear case of "the more is not better" =="media insanity".
A while ago I had the same problem, and the only solution I could produce
was using the <bgsound> tag.
It has much more options than usually thought, read MSDN. In brief,
myBgSound.src = someSrc assignment makes the sound to play again.
so
<bgsound id="myBgSound" src="aNullLength.wav">
and later
myBgSound.src = "someNewSrc.wav"
equals to play() command

AFAIK it's the only way to play sounds without popups, unnecessary downloads
etc.

For Gesko clones I cannot help. At that time it was NN4 with built-it Java
Beatnik Player, and it wasn't such a problem.
I don't know how it works now.
 
A

Andrew Poulos

Luis said:
I would like to make a .wav file play in the browser (i really don't
want to have to have a player open or even embbed itself, unless of
course it were to just not be shown, like a hidden field in a form)
when clicking on a link. Is there anyways to do this, I am pretty sure
Javascript would be the way to go to accomplish this, but please
correct me if I am wrong. Thanks

I've used this:

<object
style="visibility:hidden;"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"

codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
standby="Loading..."
type="application/x-oleobject">
<param name="FileName" value="media/wav_sample.wav">
<param name="AutoStart" value="true">

<embed type="audio/x-wav"
src="media/wav_sample.wav"
hidden="true"
autostart="true">
</embed>
</object>


Andrew Poulos
 
P

Phillip Parr

Put this at the top of your web page...


<embed id="sound1" src="rain.wav" autostart="false" hidden="true">


then this is how to play it...


<script language="javascript">
<!--
document.getElementById("sound1").Play();
-->
</script>


or to play it with a link...


<a href="#"
onClick="javascript:document.getElementById("sound1").Play();">Click here to
here rain</a>


Hope this helps
Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top