Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  26] [ 4]  / answers: 1 / hits: 31837  / 12 Years ago, wed, august 15, 2012, 12:00:00

I'm playing an MP3 using the <audio> tag in HTML5.



<audio controls=controls autoplay=autoplay>
<source src=song.mp3 type=audio/mp3 />
</audio>


This works fine, but I am wondering how I can put a delay in before the song starts to autoplay? I know there's not a delay attribute, but I'm thinking it could be accomplished via javascript?


More From » jquery

 Answers
6

Try this, really simple but you should move the JS outside the markup...



<audio controls=controls onloadeddata=var audioPlayer = this; setTimeout(function() { audioPlayer.play(); }, 8000)>
<source src=Kalimba.mp3 type=audio/mp3 />
</audio>

[#83619] Tuesday, August 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
turnerf

Total Points: 620
Total Questions: 101
Total Answers: 109

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
turnerf questions
;