Autoplay an audio with HTML5 embed tag while the player is invisible

Nima picture Nima · Nov 24, 2013 · Viewed 127.2k times · Source

I want to autoplay a MP3 audio file and I don't want the player to be visible.

<div id="music"><embed src="Comfortably_Numb.mp3" autostart=true loop=false></div>

When I added display:none to the audio tag using css, it doesn't play the music at all. Could someone explain me hot to play the music without displaying the player?

Answer

Vinith picture Vinith · Nov 24, 2013

Alternatively you can try the basic thing to get your need,

<audio autoplay loop>
      <source src="johann_sebastian_bach_air.mp3">
</audio>

For further reference click here