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

2
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by ankit.pandey3
0

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

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

0

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

0

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

0

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

0

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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.