因此,我正在尝试使用Howler.js播放音频文件。当我运行这个html文件并按下按钮时,我在控制台中得到一个错误消息:“一个源文件数组必须与任何新的Howl一起传递。”
html:
<!DOCTYPE html>
<html>
<head>
<title>Play Sound</title>
<script src='./howler.js/dist/howler.js'></script>
</head>
<body>
<button id="btn">Play</button>
<script>
var pong = new Howl({urls: ['sound.mp3', 'sound.ogg']});
document.getElementById('btn').onclick=function(){pong.play();}
</script>
</body>
</html>发布于 2017-06-04 06:15:26
应该是
var pong = new Howl({
src: ['sound.mp3', 'sound.ogg']
});发布于 2017-08-18 00:01:22
仅供将来寻找解决方案的人使用,src属性并不适用于所有浏览器。我用的是铬金丝雀,它起作用了。
发布于 2020-03-28 22:48:05
在你的soundsData对象中,你使用的是src:'sound1.mp3‘还是类似的东西?请注意,v2有一个突破性的变化,您必须将urls重命名为src
https://stackoverflow.com/questions/44348983
复制相似问题