<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...

uninstall the plugin asap or better more try a restore point (but the exact one if it is created) also,
than try this 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>

uninstall the plugin asap or better more try a restore point (but the exact one if it is created) also,
than try this 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>

Thanks for your code friend, it works fine...
but sound plays when I press play button which is not required.
I want sound automatically plays on page load..
and friend I have another requirement also, I want to hide this player image.
It means user can hear sound but should not see player at all..
Please help...

remove "controls" statements.
Put "autoplay" instead.

remove "controls" statements.
Put "autoplay" instead.

Thanks for replying sir,
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...

Try with absolute addresses of file sources instead of relative ones you might be using right now.

Try with absolute addresses of file sources instead of relative ones you might be using right now.

I tried absolute path but it stops working in chrome also...
Now, any idea???
Please sir...

you've introduced some new kind of error there. File Protocol not specified{?}

But it doesn't matter, in case you are planning to publish it on internet it will play perfectly with relative paths anyway.

you've introduced some new kind of error there. File Protocol not specified{?}

But it doesn't matter, in case you are planning to publish it on internet it will play perfectly with relative paths anyway.

Thanks sir,
it is working fine, I just configure IIS for "ogg" format and that's it.

Thanks for everything...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.