How I play sound clip in mozilla

<script>
//function PlaySound() {   var sound = document.getElementById(sound1);  sound.Play();   alert("ok");}

function playSound( url ){
  var s=document.getElementById("sound").innerHTML="<embed src='"+url+"' hidden=true autostart=true loop=false>";

  s.play();

}
</script>
<!--
<embed src="sound_5.mp3" hidden="true" autostart="false" loop="false" width="0" height="0" id="sound1" enablejavascript="true"/>-->
<input type="button"  onclick="playSound('sound.wav')" value="Play"/>
<div id="sound"></div>

Hi friends,
I want to play sound from above code which is working fine in IE and chrome browser but not works in mozilla firefox. It demands for some plugins and when I install the required plug-ins(Quick TIme), it neither works on mozilla and creates problem in chrome also (page covered with a blue screen.)
So, friends can anyone tell me where I am wrong and what I should do now??
Please help…
Thanks in advance…

dude instead of lengthy coding y dont you add html <audio></audio> tags man…this is much simpler…!!

The <audio> tab may not be available though, which can cause browser problems.

How to deal with that is to use the audio.js polyfill, which adds support for the <audio> tag even if it’s not natively supported.

For example:


<script src="/audiojs/audio.min.js"></script>
<script>
audiojs.events.ready(function () {
    var as = audiojs.createAll();
});
</script>

After that, you can use the <audio> tag and it will work, even if the browser doesn’t support it.


<audio src="sound_5.mp3" preload="auto" />

Thanks for reply…
but I tried below code

<html>
<head>
<script src=“audiojs/audio.min.js”></script>
<script>
audiojs.events.ready(function () {
var as = audiojs.createAll();
});
</script>
</head>
<body >
<audio src=“sound.mp3” preload=“auto” />
</body>
</html>

but it not works at all in any browser. I can see the player image but there are no sound at all in any browser.
I think <audio> and “preload” are attributes of HTML5 that’s why it not works…
but I am not sure about that.
Can you please tell me what should I do now???
Can you please tell where I am wrong??

Have you downloaded the what you need from the audio.js polyfill from their website?

Yes sir…

That download comes with an example index.html file, that demonstrates things and provides details on how to achieve it.
In that index.html file you should find that the audio file in there works for you, which will mean that the technique will be successful for you.

If it works for you, we can then go further in to working out what’s not going right for you.

Sir, that index.html also not works…

What is the web browser & version that is not working with it?

Friends I got the following code

<audio controls>
<source src=“sound_5.ogg” type=“audio/ogg”><!–firefox–>
<source src=“sound_5.mp3” type=“audio/mpeg”>
<img dynsrc=“sound_5.mp3” height=30 width=120 controls>
</audio>

Sir it works everywhere(mozila and chrome) but when I try to run same page via “localhost” (IIS Server) it works perfectly in chrome but stop working in mozilla…
What is problem now???
Please help…

Thanks sir,
it is working fine, I just configure IIS for “ogg” format and that’s it.

Thanks for everything…