音频文件无法在页面加载中使用 [英] Audio file not working on page load
本文介绍了音频文件无法在页面加载中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
document.getElementById('audio_1').addEventListener('ended', function() {
this.play();
this.currentTime = 0;
}, false);
在这种音乐中,页面加载不会开始,它会重复n次,一旦开始..但不会一次加载页面
In this music does not start on page load, it repeats n number of times, once started..but not once page load
推荐答案
您永远不会开始播放.您需要调用.play()
onload或在<audio>
标签中使用autoplay
属性.
You never start the playback. You need to call .play()
onload or use the autoplay
attribute in your <audio>
tag.
哦,无需任何JavaScript,您就可以轻松实现循环.只需在<audio>
标记中使用loop
属性即可.
Oh, and you can achieve looping much easier without any JavaScript. Simply use the loop
attribute in your <audio>
tag.
这篇关于音频文件无法在页面加载中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文