Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howler.js error: ' An array of source files must be passed with any new Howl '

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>
like image 820
Martin Avatar asked Jun 03 '17 22:06

Martin


1 Answers

Should be

var pong = new Howl({
     src: ['sound.mp3', 'sound.ogg']
});
like image 62
Jonathan Bartlett Avatar answered Nov 11 '22 01:11

Jonathan Bartlett