Playing audio files

I’m creating a small game in PureScript (base on Halogen and SVG). I would like to add some sound effects… The sound would play on a Halogen event. It could be read from a .ogg or .mp3 file.
Any suggestion how to go that?


IMHO opinion the browsers Audio API is quite simple:

var audio = new Audio('soundfile-url');;

not sure if there is a package for that but I’d go and wrap it into a FFI module and use this.

I asked myself exactly this question two days ago :open_mouth:
If you don’t mind the dependency on purescript-web-html (which you probably already depend on), you can do this without the need for any FFI:

audioEl <- Web.HTML.HTMLAudioElement.create' "soundfile-url"
let mediaEl = Web.HTML.HTMLAudioElement.toHTMLMediaElement audioEl mediaEl