Mar*_*tin 5 html javascript audio html5 howler.js
所以我试图用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>
Run Code Online (Sandbox Code Playgroud)
应该
var pong = new Howl({
src: ['sound.mp3', 'sound.ogg']
});
Run Code Online (Sandbox Code Playgroud)