最佳答案
我最近一直在使用 HTML5音频,尽管我可以让它播放声音,但它只会播放一次。无论我尝试什么(设置属性、事件处理程序等) ,似乎都不能让它进行循环。
下面是我使用的基本代码:
//myAudio is declared at a global scope, so it doesn't get garbage collected.
myAudio = new Audio('someSound.ogg');
myAudio.loop = true;
myAudio.play();
我正在使用 Chrome (6.0.466.0 dev)和 Firefox (4 beta 1)进行测试,它们似乎都很乐意忽略我的循环请求。有什么想法吗?
更新 : 现在所有主流浏览器的循环属性都是 支持。