Reputation: 2333
I'm creating this fun little website and I want NyanCat.mp3 to play as soon as the user enters the website and I do not want the controls to be shown.Unfortunately with the code I've got, it only works if the user has controls. I also want it to loop.
Without Controls - Does not work
<audio loop="loop">
<source src="NyanCat.mp3" type="audio/mpeg" />
</audio>
With Controls - Does work
<audio loop="loop" controls="controls">
<source src="NyanCat.mp3" type="audio/mpeg" />
</audio>
Upvotes: 1
Views: 8171
Reputation: 1303
Option 1
Use jQuery to your job. call on page load function. Here is code jQuery
Option 2
Use a external plugin to your job. Here is a Wordpress plugin
Option 3
The MSDN way of doing it. Refer this Play audio without audio tag visibility
Hope this helps :)
Upvotes: 0
Reputation: 819
If you don't want the controls to be shown, delete the controls
atribute, but add the autoplay
atribute instead:
<audio loop="loop" autoplay="autoplay">
<source src="NyanCat.mp3" type="audio/mpeg" />
</audio>
Anyway, it's always a good idea to give the user the control to play/stop the music.
Upvotes: 1