开发者

How do i make my Audio loop in my website?

Here is my code:

<div id="div6" style="position: absolute; top: 700px; left: 100px;"> <audio controls="controls; loop:true"> <source src=开发者_高级运维"../media/ChealseSmile.ogg" type="audio/ogg"/> <source src="song.mp3" type="audio/mpeg"/> Your browser does not support the audio element. </audio> </div>

What do i have to add to the audio code to make it loop or autostart?

As a bonus, could someone also tell me how to make a playlist out of this code?


<audio loop="loop" /> 


<audio loop id="music" controls autoplay="autoplay">
   <source src="music.oog" type="audio/ogg">
   <source src="music.mp3" type="audio/mpeg">
   <embed height="2" width="2" src="engine1/granadosorienta_pianol.mp3">
</audio>

Then you can add this JS for old FF browsers if you want to support them

<!--- Fix the FF Audio Loop bug --!>
  document.getElementById('music').addEventListener('ended', function(){
  this.currentTime = 0;
  this.play();
}, false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜