7

So i'm trying to test out using Howler.js to play an audio file. When I run this html file and press the button I get an error in console saying "An array of source files must be passed with any new 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>
Rich
  • 3,156
  • 3
  • 19
  • 29
Martin
  • 1,336
  • 4
  • 32
  • 69

3 Answers3

8

Should be

var pong = new Howl({
     src: ['sound.mp3', 'sound.ogg']
});
  • Thank you very much. I spent hours to figure out what was wrong.It should be 'src' not 'url.' Great! – passion Jul 07 '20 at 13:09
0

Just for future solution hunters, src property is not working with all browsers. I used chrome canary and it worked.

Ali
  • 468
  • 1
  • 8
  • 19
0

In your soundsData object, are you using src: ['sound1.mp3'] or something similar? Note that v2 has a breaking change where you have to rename urls to src