Reputation: 8103
What is SIMPLE and good practice to play background music in Rails App. It's a really simple rails website. It has several static pages. How do I playing music on background?
thanks!
I am not looking for detailed answer or code. I just want somebody kindly point me some links, or some keywords I can search. I googled around and did not find what I want/ Or I didnt realize that was I need.
Upvotes: 1
Views: 1703
Reputation: 1579
with HTML 5, you can now use the tag like this. You can place this on any page that you want your music to play on. (layouts/application.html.erb if you want site-wide)
<audio src="public/my_audio_file.mp3" autoplay controls loop>
<p>Your browser does not support HTML5 audio playback</p>
</audio>
This link provides further details and options https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video
Upvotes: 2
Reputation: 29349
Add this to the pages on which you want the sound
<embed src="path/to/background.mp3" autostart="true" loop="true" hidden="true"><embed>
Add it to the layout if you want it in all the pages
Upvotes: 1