网站位于:http://ajf.me/stuff/eva在撰写本文时。源代码是这样的:
<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>eva</title>
</head>
<body style="background-color: black; background-image: url('eva.png'); background-repeat: no-repeat; background-position: center center; height: 100%; margin: 0px; padding: 0px;">
<audio autoplay loop>
<source src="eva.mp3" type="audio/mpeg" />
<source src="eva.ogg" type="audio/ogg" />
<source src="eva.wav" type="audio/wav" />
</audio>
</body>
</html>
音频在 Chrome、IE9 和 Firefox 中播放良好,但在后者中不循环播放。音频文件不能变形,因为它是由 Audacity 制作的。为什么它不循环还有其他解释吗?
最佳答案
你可以这样做
<audio autoplay loop>
属性不需要有任何其他内容。
编辑
据此,Firefox 不喜欢 loop
.它提出了一个 js 解决方案:
document.getElementById('audio_2').addEventListener('ended', function(){
this.currentTime = 0;
}, false);
http://forestmist.org/2010/04/html5-audio-loops/
编辑
HTML5 音频循环现在适用于 firefox。在 26.0 版中确认(可能更早)
关于html - 为什么我的 HTML5 音频不循环播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7747526/