2

Here is my embed tag

<embed src="http://localhost:8084/MIS/js/status_no.mp3" hidden="true" autostart="true" loop="false" class="playSound">

When I remove hidden property, sound gets played but when i set hidden property to true, sound does not play. I do not want to show the player to the user.

sonam
  • 3,720
  • 12
  • 45
  • 66

5 Answers5

1
<audio>
    <source src="../js/Alarm_Buzzer.ogg" type="audio/ogg"></source>
</audio>

This worked for me in both chrome as well as firefox. Firefox did not support mp3 files but chrome did.

sonam
  • 3,720
  • 12
  • 45
  • 66
0

You can try to hide it with CSS:

.playSound { display: none; }

Also I'd like to suggest using the audio tag, it's meant for this type of content.

Dimitar Dimitrov
  • 14,868
  • 8
  • 51
  • 79
  • 1
    thanks for your reply but audio tag does not seem to work on firefox. it works well on chrome though. Any suggestions for that – sonam Jul 07 '13 at 07:41
  • @sonam For FF, check this: http://stackoverflow.com/questions/10675332/is-there-any-way-that-html-audio-tag-could-play-mp3-in-firefox – Dimitar Dimitrov Jul 07 '13 at 07:44
0

I would recommend converting your code into something like this and this works on all browsers

 <audio autoplay>
  <source src="http://localhost:8084/MIS/js/status_no.ogg" type="audio/ogg">
  <source src="http://localhost:8084/MIS/js/status_no.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio> 

This code will work on all browsers, it will also be hidden and will start automatically.

Mohammad Dohadwala
  • 301
  • 1
  • 3
  • 10
0

If you add controls="controls" in audio tag then the audio player will be visible to the user. so for your case just don't add controls.

<audio  src="http://a.tumblr.com/tumblr_mfezft44rf1rge0duo1.mp3" autoplay="autoplay" loop="false" class="playSound"></audio>

Hope this helps!

Ritesh Nair
  • 3,327
  • 1
  • 17
  • 24
-1
<embed src="https://www.youtube.com/v/watch?v=KA_8oaTpxac&autoplay=1&amp;loop=1" type="application/x-shockwave-flash" 

wmode="transparent" height="1" width="1">

I think this works but note : Very important
if video on you tube : the line is :

https://www.youtube.com/watch?v=vid number

but you have to write it in this form in the code

https://www.youtube.com/v/watch?v=vid id

and will work fine

Manos Nikolaidis
  • 21,608
  • 12
  • 74
  • 82