ramr
ramr

Reputation: 1019

Autoplaying music on website with out getting any permissions.

I would like to auto play a music in the background of my error 404 page. However I need it to sync up to a little animation. I've used the

<embed> 

tag. However it asks for the permission to run quicktime. By the time the user would accept it, the animation would be over. I've also tried autoplaying a youtube video, but it usually takes 3-5 seconds to buffer depending on one's internet connection. This is too long. Is there any solution to auto play a song with out any permissions?

Upvotes: 4

Views: 401

Answers (2)

Pere
Pere

Reputation: 2013

Using the <audio> tag, this will work on most browsers:

<![if (!IE)|(gte IE 9)]>
<audio id="speak" autoplay>
  <source src="speak_a.ogg" type="audio/ogg" />
  <source src="speak_a.mp3" type="audio/mpeg" />
</audio>
<![endif]>
<!--[if lt IE 9]>
<bgsound id="speak" name="speak" autostart="true" loop="1">
<script>document.all['speak'].src='speak_a.mp3'</script>
<![endif]--> 

Also see my other related answer in How can I incorporate audio in a website using HTML5?

Upvotes: 1

Joel Peltonen
Joel Peltonen

Reputation: 13432

I guess you could do it without flash using 100% HTML5 depending on your requirements (what browser support you need). That will

Here's a nice example: http://hungry-media.com/code/html5-audio-sync/

(Related to this blog post: http://hungry-media.com/2010/09/synchronizing-audio-with-html5/)

Upvotes: 2

Related Questions